[Commits] Rev 3164: Merge MySQL 5.1.66 -> MariaDB 5.1.65 in file:///home/tsk/mprog/src/5.1-merge-all/

timour at askmonty.org timour at askmonty.org
Tue Nov 6 11:53:25 EET 2012


At file:///home/tsk/mprog/src/5.1-merge-all/

------------------------------------------------------------
revno: 3164 [merge]
revision-id: timour at askmonty.org-20121106095255-10b1yftq16je2ry1
parent: knielsen at knielsen-hq.org-20121101152009-xxomgrzoogy2lq5w
parent: joerg.bruehe at oracle.com-20120911104732-gjcmqg1t2yext74e
committer: timour at askmonty.org
branch nick: 5.1-merge-all
timestamp: Tue 2012-11-06 11:52:55 +0200
message:
  Merge MySQL 5.1.66 -> MariaDB 5.1.65
removed:
  extra/yassl/taocrypt/src/crypto.cpp sp1f-crypto.cpp-20060927122942-jhqjrntneclhxupnrtw2bsyttxycbtfa
added:
  mysql-test/suite/federated/include/ mysqltestsuitefedera-20120725083005-v19l682pq0xix0cu-1
  mysql-test/suite/innodb_plugin/r/innodb_information_schema_buffer.result innodb_information_s-20120719095748-xlgfshffy8rfn1b3-1
  mysql-test/suite/innodb_plugin/t/innodb_information_schema_buffer.test innodb_information_s-20120719063750-hzxuv5y7t2sx0kxv-1
renamed:
  mysql-test/suite/federated/federated.inc => mysql-test/suite/federated/include/federated.inc sp1f-federated.inc-20050715234236-7cak5zlq4fbqk4syuamsude7yrayh4ym
  mysql-test/suite/federated/federated_cleanup.inc => mysql-test/suite/federated/include/federated_cleanup.inc sp1f-federated_cleanup.in-20050715234237-umi6dcbw4iddewrgdfttonz62cg7io35
modified:
  CMakeLists.txt                 sp1f-cmakelists.txt-20060831175236-433hkm7nrqfjbwios4ancgytabw354nr
  Docs/INSTALL-BINARY            sp1f-installbinary-20071102002932-lm64vo6qp4t3tz7t2edp2mrg5udn2xsy
  client/mysql.cc                sp1f-mysql.cc-19700101030959-5sipizk7ehvbsi3tywrkdords5qy5zdl
  client/mysql_upgrade.c         sp1f-mysql_upgrade.c-20060428040559-3xcugp4nhhb6qfwfacoqw3d4ibgbeboz
  client/mysqladmin.cc           sp1f-mysqladmin.c-19700101030959-ud6encjcx2oypzvp7ptmojbi3xdos2fs
  client/mysqlbinlog.cc          sp1f-mysqlbinlog.cc-19700101030959-b3vgyo47ljent5mhbyj6ik33bi4bukad
  client/mysqlcheck.c            sp1f-mysqlcheck.c-20010419220847-mlhe2ixwl5ajjyneyciytsdsis3iujhl
  client/mysqldump.c             sp1f-mysqldump.c-19700101030959-thxq2iabzu3yo5snymsubfeclf7v5rac
  client/mysqlimport.c           sp1f-mysqlimport.c-19700101030959-m6nmuvl5kbp2qmdqtmu5mxafegtn7ipv
  client/mysqlshow.c             sp1f-mysqlshow.c-19700101030959-b6rjdpnvma7hacca2ibkkibowbi4hulk
  client/mysqlslap.c             sp1f-mysqlslap.c-20051130000206-7t375hf5mtlqof5xd4nj76yckxvxykhv
  client/mysqltest.cc            sp1f-mysqltest.c-20001010065317-ix4zw26srlev7yugcz455ux22zwyynyf
  client/sql_string.h            sp1f-sql_string.h-19700101030959-oscd4vjvtuwjf22oosfpfmvc2f3km2dx
  configure.in                   sp1f-configure.in-19700101030959-mgdpoxtnh2ewmvusvfpkreuhwvffkcjw
  extra/perror.c                 sp1f-perror.c-19700101030959-chqjfrsdcoaezse75ogqywl264efjt3v
  extra/yassl/src/ssl.cpp        sp1f-ssl.cpp-20050428132310-dxnfnbmwz6rpnkj4agjb5nvfhhg345nq
  extra/yassl/taocrypt/src/Makefile.am sp1f-makefile.am-20050428132317-n6as7nf4jxpgraczrckxwabzeylmdwk4
  include/welcome_copyright_notice.h welcome_copyright_no-20101005135656-p7fnkc5dqg336mkn-1
  mysql-test/Makefile.am         sp1f-makefile.am-20001206082022-36vvdlhec52v4kcxab5ees7yomxvj4dl
  mysql-test/r/openssl_1.result  sp1f-ssl.result-20010831211351-xa6w74zno32dlg3iwugerlalsvrsq5hn
  mysql-test/r/subselect.result  sp1f-subselect.result-20020512204640-zgegcsgavnfd7t7eyrf7ibuqomsw7uzo
  mysql-test/suite/federated/federated_archive.test sp1f-federated_archive.te-20050902184012-ntkrqr6yhmpxn3z3zjdwrsqv6y2k4dj4
  mysql-test/suite/federated/federated_bug_13118.test sp1f-federated_bug_13118.-20050916231733-s6sn7sacgnfyblqgs5kftws636t3oxik
  mysql-test/suite/federated/federated_bug_25714.test sp1f-federated_bug_25714.-20070724063540-o64ivn4wawpbeo67hvs4rklm44kx37nu
  mysql-test/suite/federated/federated_bug_32426.test federated_bug_32426.-20100818073917-70shrxkcz9jcp3bp-2
  mysql-test/suite/federated/federated_bug_35333.test federated_bug_35333.-20101130044345-6iy956b10epshtep-1
  mysql-test/suite/federated/federated_bug_585688.test federated_bug_585688-20110210203420-2syulkl42au7ndcp-2
  mysql-test/suite/federated/federated_debug.test federated_debug.test-20090930202805-kt19apxdz61tx0ln-1
  mysql-test/suite/federated/federated_innodb.test sp1f-federated_innodb.tes-20070628230259-ltfvjsjq24lq46yxq3s52xbsrtecrmm3
  mysql-test/suite/federated/federated_partition.test federated_partition.-20110210203420-2syulkl42au7ndcp-5
  mysql-test/suite/federated/federated_server.test sp1f-federated_server.tes-20061202004730-idhp5qb6ntspupkz2wftb5aguipv27kk
  mysql-test/suite/federated/federated_transactions.test sp1f-federated_transactio-20051109135140-zf5q2d5zwjjbj7gcwinjfct37x4uio2n
  mysql-test/suite/federated/federatedx.test sp1f-federated.test-20041211200119-aht6hujozcouca6joz5eaiq55jk6psb5
  mysql-test/suite/innodb/r/innodb_misc1.result innodb_misc1.result-20100427060759-ki8xd97303uicinf-1
  mysql-test/t/openssl_1.test    sp1f-ssl.test-20010831211355-mk47pipvythsqcor32yidzoopgdewdo6
  scripts/mysql_secure_installation.pl.in sp1f-mysql_secure_install-20071228215050-nnco3kgp33fxs7ja6zdy6xh56zszi2cc
  scripts/mysql_secure_installation.sh sp1f-mysql_secure_install-20020609041239-b4zztmtqycjs24aubuhwun6np5wuuesy
  sql/filesort.cc                sp1f-filesort.cc-19700101030959-mfm2vmdgqqru7emm2meeecleb2q3zdso
  sql/gen_lex_hash.cc            sp1f-gen_lex_hash.cc-19700101030959-ihtnj4jrxjs2tzorsl4bywh4hmrzhz4n
  sql/ha_partition.cc            sp1f-ha_partition.cc-20050718113037-eoky4qluumb5dmdyg5z6n2fvdkgutxms
  sql/ha_partition.h             sp1f-ha_partition.h-20050718113038-4xxwqkuu2xgxqtrwfbc43zgfyfcwzjsq
  sql/handler.cc                 sp1f-handler.cc-19700101030959-ta6zfrlbxzucylciyro3musjsdpocrdh
  sql/item_strfunc.cc            sp1f-item_strfunc.cc-19700101030959-yl2pwnrngmla3nmlgiuiwrztx3iu4ffl
  sql/item_subselect.cc          sp1f-item_subselect.cc-20020512204640-qep43aqhsfrwkqmrobni6czc3fqj36oo
  sql/log_event.h                sp1f-log_event.h-19700101030959-clq6ett55tcqbpys2i4cpfrdccq7j4om
  sql/mysqld.cc                  sp1f-mysqld.cc-19700101030959-zpswdvekpvixxzxf7gdtofzel7nywtfj
  sql/share/charsets/Index.xml   sp1f-index.xml-20030103103530-5pd7ad4tu3otejnum6ecdnadu4n3jb3b
  sql/spatial.cc                 sp1f-spatial.cc-20020222112439-yecm64geoygpvzrlc2mg7hdtbvtlmhoe
  sql/spatial.h                  sp1f-spatial.h-20020222112440-72iyz2ld6nl3qbitdm4dorewo3urjci7
  sql/sql_prepare.cc             sp1f-sql_prepare.cc-20020612210720-gtqjjiu7vpmfxb5xct2qke7urmqcabli
  sql/sql_select.cc              sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb
  sql/sql_show.cc                sp1f-sql_show.cc-19700101030959-umlljfnpplg452h7reeyqr4xnbmlkvfj
  sql/sql_string.h               sp1f-sql_string.h-19700101030959-nogsoxwv222e4vm4toic7cabeb4swajz
  storage/federated/ha_federated.cc sp1f-ha_federated.cc-20041211200120-gu52ex5sicbua5vtoocuki3ltllsvm2c
  storage/innobase/btr/btr0pcur.c 2 at cee13dc7-1704-0410-992b-c9b4543f1246:trunk%2Fbtr%2Fbtr0pcur.c
  storage/innobase/handler/ha_innodb.cc 2 at cee13dc7-1704-0410-992b-c9b4543f1246:trunk%2Fhandler%2Fha_innodb.cc
  storage/innodb_plugin/ChangeLog 2425 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog
  storage/innodb_plugin/btr/btr0btr.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0btr.c
  storage/innodb_plugin/btr/btr0cur.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0cur.c
  storage/innodb_plugin/btr/btr0pcur.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0pcur.c
  storage/innodb_plugin/buf/buf0buf.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0buf.c
  storage/innodb_plugin/handler/ha_innodb.cc 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fhandler%2Fha_innodb.cc
  storage/innodb_plugin/handler/i_s.cc 1864 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fhandler%2Fi_s.cc
  storage/innodb_plugin/handler/i_s.h 1864 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fhandler%2Fi_s.h
  storage/innodb_plugin/ibuf/ibuf0ibuf.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fibuf%2Fibuf0ibuf.c
  storage/innodb_plugin/include/buf0buf.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbuf0buf.h
  storage/innodb_plugin/include/buf0buf.ic 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbuf0buf.ic
  storage/innodb_plugin/include/fil0fil.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ffil0fil.h
  storage/innodb_plugin/include/log0log.h 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0log.h
  storage/innodb_plugin/include/univ.i 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Funiv.i
  storage/innodb_plugin/page/page0cur.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpage%2Fpage0cur.c
  storage/innodb_plugin/page/page0page.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpage%2Fpage0page.c
  storage/innodb_plugin/row/row0ins.c 2 at 16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Frow%2Frow0ins.c
  storage/innodb_plugin/row/row0merge.c 1414 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Frow%2Frow0merge.c
  storage/innodb_plugin/scripts/install_innodb_plugins.sql 2428 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fscripts%2Finstall_innodb_plugins.sql
  storage/innodb_plugin/scripts/install_innodb_plugins_win.sql 2951 at 16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fscripts%2Finstall_innodb_plugins_win.sql
  support-files/mysql.spec.sh    sp1f-mysql.spec.sh-19700101030959-man6e3acwxvf62bdqvkpcpsvdtokf3ff
  vio/viosslfactories.c          sp1f-viosslfactories.c-20010520120431-walfvbsc6adzg7cj5g6xl3r73ycxspmb
-------------- next part --------------
=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	2011-11-21 17:13:14 +0000
+++ b/CMakeLists.txt	2012-11-06 09:52:55 +0000
@@ -437,6 +437,10 @@ IF(WITH_EMBEDDED_SERVER)
 ENDIF(WITH_EMBEDDED_SERVER)
 ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
 
+IF(EXISTS ${CMAKE_SOURCE_DIR}/internal/CMakeLists.txt)
+  ADD_SUBDIRECTORY(internal)
+ENDIF()
+
 # Set up the installer
 SET(CPACK_PACKAGE_NAME "MariaDB")
 STRING(REPLACE "-MariaDB" "" CPACK_PACKAGE_VERSION ${VERSION})

=== modified file 'Docs/INSTALL-BINARY'
--- a/Docs/INSTALL-BINARY	2010-04-28 13:10:25 +0000
+++ b/Docs/INSTALL-BINARY	2012-11-06 09:52:55 +0000
@@ -31,7 +31,7 @@ also applies.
        first.
 
    If you run into problems and need to file a bug report,
-   please report them to: http://bugs.launchpad.net/maria
+   please report them to: http://mariadb.org/jira
 
    See the instructions in Section 1.6, "How to Report Bugs or Problems."
 

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-11-23 17:32:14 +0000
+++ b/client/mysql.cc	2012-11-06 09:52:55 +0000
@@ -1,6 +1,6 @@
-/* Copyright (C) 2000-2009 MySQL AB
-   Copyright 2000, 2010-2011, Oracle and/or its affiliates.
-   Copyright 2000-2010 Monty Program Ab
+/*
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2012, Monty Program Ab.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -119,6 +119,7 @@ extern "C" {
 #endif
 
 #include "completion_hash.h"
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
 
 #define PROMPT_CHAR '\\'
 #define DEFAULT_DELIMITER ";"
@@ -1176,7 +1177,7 @@ int main(int argc,char *argv[])
           mysql_thread_id(&mysql), server_version_string(&mysql));
   put_info((char*) glob_buffer.ptr(),INFO_INFO);
 
-  put_info(COPYRIGHT_NOTICE, INFO_INFO);
+  put_info(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"), INFO_INFO);
 
 #ifdef HAVE_READLINE
   initialize_readline((char*) my_progname);
@@ -1604,7 +1605,7 @@ static void usage(int version)
 
   if (version)
     return;
-  printf("%s", COPYRIGHT_NOTICE);
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   printf("Usage: %s [OPTIONS] [database]\n", my_progname);
   my_print_help(my_long_options);
   print_defaults("my", load_default_groups);
@@ -2826,7 +2827,7 @@ static int com_server_help(String *buffe
                            char *line __attribute__((unused)), char *help_arg)
 {
   MYSQL_ROW cur;
-  const char *server_cmd= buffer->ptr();
+  const char *server_cmd;
   char cmd_buf[100 + 1];
   MYSQL_RES *result;
   int error;
@@ -2841,9 +2842,12 @@ static int com_server_help(String *buffe
                 *++end_arg= '\0';
         }
         (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS);
-    server_cmd= cmd_buf;
   }
-  
+  else
+    (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help ", help_arg, NullS);
+
+  server_cmd= cmd_buf;
+
   if (!status.batch)
   {
     old_buffer= *buffer;
@@ -2911,6 +2915,11 @@ static int com_server_help(String *buffe
     else
     {
       put_info("\nNothing found", INFO_INFO);
+      if (strncasecmp(server_cmd, "help 'contents'", 15) == 0)
+      {
+         put_info("\nPlease check if 'help tables' are loaded.\n", INFO_INFO); 
+         goto err;
+      }
       put_info("Please try to run 'help contents' for a list of all accessible topics\n", INFO_INFO);
     }
   }

=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2011-11-21 17:13:14 +0000
+++ b/client/mysql_upgrade.c	2012-11-06 09:52:55 +0000
@@ -1,7 +1,5 @@
 /*
-   Copyright (C) 2000 MySQL AB
-   Copyright (c) 2006, 2011, Oracle and/or its affiliates.
-   Copyright (C) 2010-2011 Monty Program Ab
+   Copyright (c) 2006, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -21,6 +19,8 @@
 #include <sslopt-vars.h>
 #include "../scripts/mysql_fix_privilege_tables_sql.c"
 
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 #define VER "1.2"
 
 #ifdef HAVE_SYS_WAIT_H
@@ -235,6 +235,7 @@ get_one_option(int optid, const struct m
   case '?':
     printf("%s  Ver %s Distrib %s, for %s (%s)\n",
            my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
+    puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
     puts("MySQL utility for upgrading databases to new MySQL versions.\n");
     my_print_help(my_long_options);
     exit(0);

=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2011-11-21 17:13:14 +0000
+++ b/client/mysqladmin.cc	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <mysql.h>
 #include <sql_common.h>
+#include <welcome_copyright_notice.h>           /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
 #define ADMIN_VERSION "8.42"
 #define MAX_MYSQL_VAR 512
@@ -692,8 +693,7 @@ static int execute_commands(MYSQL *mysql
     case ADMIN_VER:
       new_line=1;
       print_version();
-      puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
-      puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
+      puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
       printf("Server version\t\t%s\n", mysql_get_server_info(mysql));
       printf("Protocol version\t%d\n", mysql_get_proto_info(mysql));
       printf("Connection\t\t%s\n",mysql_get_host_info(mysql));
@@ -1072,8 +1072,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   puts("Administration program for the mysqld daemon.");
   printf("Usage: %s [OPTIONS] command command....\n", my_progname);
   my_print_help(my_long_options);

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2012-08-22 09:40:39 +0000
+++ b/client/mysqlbinlog.cc	2012-11-06 09:52:55 +0000
@@ -36,6 +36,8 @@
 #include "mysql_priv.h" 
 #include "log_event.h"
 #include "sql_common.h"
+#include "my_dir.h"
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
 
 #define BIN_LOG_HEADER_SIZE     4
 #define PROBE_HEADER_LEN        (EVENT_LEN_OFFSET+4)
@@ -1273,10 +1275,7 @@ static void print_version()
 static void usage()
 {
   print_version();
-  puts("By Monty and Sasha, for your professional use\n\
-This software comes with NO WARRANTY:  This is free software,\n\
-and you are welcome to modify and redistribute it under the GPL license.\n");
-
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   printf("\
 Dumps a MySQL binary log in a format usable for viewing or for piping to\n\
 the mysql command line client.\n\n");
@@ -1773,6 +1772,7 @@ static Exit_status check_header(IO_CACHE
   uchar header[BIN_LOG_HEADER_SIZE];
   uchar buf[PROBE_HEADER_LEN];
   my_off_t tmp_pos, pos;
+  MY_STAT my_file_stat;
 
   delete glob_description_event;
   if (!(glob_description_event= new Format_description_log_event(3)))
@@ -1782,7 +1782,16 @@ static Exit_status check_header(IO_CACHE
   }
 
   pos= my_b_tell(file);
-  my_b_seek(file, (my_off_t)0);
+
+  /* fstat the file to check if the file is a regular file. */
+  if (my_fstat(file->file, &my_file_stat, MYF(0)) == -1)
+  {
+    error("Unable to stat the file.");
+    return ERROR_STOP;
+  }
+  if ((my_file_stat.st_mode & S_IFMT) == S_IFREG)
+    my_b_seek(file, (my_off_t)0);
+
   if (my_b_read(file, header, sizeof(header)))
   {
     error("Failed reading header; probably an empty file.");

=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c	2011-11-21 17:13:14 +0000
+++ b/client/mysqlcheck.c	2012-11-06 09:52:55 +0000
@@ -1,6 +1,5 @@
-/* Copyright (C) 2000 MySQL AB & Jani Tolonen
-   Copyright (c) 2001, 2011, Oracle and/or its affiliates.
-   Copyright (C) 2010- 2011 Monty Program Ab
+/*
+   Copyright (c) 2001, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,6 +22,7 @@
 #include <mysql_version.h>
 #include <mysqld_error.h>
 #include <sslopt-vars.h>
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
 /* Exit codes */
 
@@ -222,13 +222,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts("By Jani Tolonen, 2001-04-20, MySQL Development Team.\n");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
-  puts("and you are welcome to modify and redistribute it under the GPL license.\n");
-  printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
-  printf("OR     %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
-         my_progname);
-  printf("OR     %s [OPTIONS] --all-databases\n\n", my_progname);
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   puts("This program can be used to CHECK (-c, -m, -C), REPAIR (-r), ANALYZE (-a),");
   puts("or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be");
   puts("used at the same time. Not all options are supported by all storage engines.");

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2012-08-22 09:40:39 +0000
+++ b/client/mysqldump.c	2012-11-06 09:52:55 +0000
@@ -54,6 +54,8 @@
 #include "mysqld_error.h"
 #include "../sql/ha_ndbcluster_tables.h"
 
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 /* Exit codes */
 
 #define EX_USAGE 1
@@ -583,8 +585,7 @@ static void short_usage_sub(void)
 static void usage(void)
 {
   print_version();
-  puts("By Igor Romanenko, Monty, Jani & Sinisa and others.");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   puts("Dumping structure and contents of MySQL databases and tables.");
   short_usage_sub();
   print_defaults("my",load_default_groups);

=== modified file 'client/mysqlimport.c'
--- a/client/mysqlimport.c	2011-11-21 17:13:14 +0000
+++ b/client/mysqlimport.c	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -34,6 +34,8 @@
 #include <my_pthread.h>
 #endif
 
+#include <welcome_copyright_notice.h>   /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 
 /* Global Thread counter */
 uint counter;
@@ -202,7 +204,8 @@ static void usage(void)
   puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
   puts("Copyright 2008-2011 Oracle and Monty Program Ab.");
   print_version();
-  printf("\n\
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
+  printf("\
 Loads tables from text files in various formats.  The base name of the\n\
 text file must be the name of the table that should be used.\n\
 If one uses sockets to connect to the MySQL server, the server will open and\n\

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2011-11-21 17:13:14 +0000
+++ b/client/mysqlshow.c	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <sslopt-vars.h>
+#include <welcome_copyright_notice.h>   /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
 static char * host=0, *opt_password=0, *user=0;
 static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0;
@@ -255,9 +256,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts("Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.");
-  puts("Copyright 2008-2011 Oracle and Monty Program Ab.");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   puts("Shows the structure of a MySQL database (databases, tables, and columns).\n");
   printf("Usage: %s [OPTIONS] [database [table [column]]]\n",my_progname);
   puts("\n\

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2012-05-17 10:12:33 +0000
+++ b/client/mysqlslap.c	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2005, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2005, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -95,6 +95,7 @@
 #include <sys/wait.h>
 #endif
 #include <ctype.h>
+#include <welcome_copyright_notice.h>   /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
 #ifdef __WIN__
 #define srandom  srand
@@ -708,8 +709,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts("Copyright (C) 2005 MySQL AB");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license.\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2005"));
   puts("Run a query multiple times against the server.\n");
   printf("Usage: %s [OPTIONS]\n",my_progname);
   print_defaults("my",load_default_groups);

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2012-08-22 09:40:39 +0000
+++ b/client/mysqltest.cc	2012-11-06 09:52:55 +0000
@@ -54,6 +54,8 @@
 #include <signal.h>
 #include <my_stacktrace.h>
 
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
+
 #ifdef __WIN__
 #include <crtdbg.h>
 #define SIGNAL_FMT "exception 0x%x"
@@ -6237,8 +6239,7 @@ void print_version(void)
 void usage()
 {
   print_version();
-  printf("MySQL AB, by Sasha, Matt, Monty & Jani and others\n");
-  printf("This software comes with ABSOLUTELY NO WARRANTY\n\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   printf("Runs a test against the mysql server and compares output with a results file.\n\n");
   printf("Usage: %s [OPTIONS] [database] < test_file\n", my_progname);
   my_print_help(my_long_options);

=== modified file 'client/sql_string.h'
--- a/client/sql_string.h	2011-11-21 17:13:14 +0000
+++ b/client/sql_string.h	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2010, Oracle and/or its affiliates
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -195,8 +195,12 @@ class String
   }
   bool real_alloc(uint32 arg_length);                   // Empties old string
   bool realloc(uint32 arg_length);
-  inline void shrink(uint32 arg_length)         // Shrink buffer
+
+  // Shrink the buffer, but only if it is allocated on the heap.
+  inline void shrink(uint32 arg_length)
   {
+    if (!is_alloced())
+      return;
     if (arg_length < Alloced_length)
     {
       char *new_ptr;
@@ -212,7 +216,7 @@ class String
       }
     }
   }
-  bool is_alloced() { return alloced; }
+  bool is_alloced() const { return alloced; }
   inline String& operator = (const String &s)
   {
     if (&s != this)

=== modified file 'configure.in'
--- a/configure.in	2012-08-22 09:40:39 +0000
+++ b/configure.in	2012-11-06 09:52:55 +0000
@@ -12,7 +12,7 @@ dnl
 dnl When changing the major version number please also check the switch
 dnl statement in mysqlbinlog::check_master_version().  You may also need
 dnl to update version.c in ndb.
-AC_INIT([MariaDB Server], [5.1.65-MariaDB], [], [mysql])
+AC_INIT([MariaDB Server], [5.1.66-MariaDB], [], [mysql])
 
 AC_CONFIG_SRCDIR([sql/mysqld.cc])
 AC_CANONICAL_SYSTEM

=== modified file 'extra/perror.c'
--- a/extra/perror.c	2011-11-21 17:13:14 +0000
+++ b/extra/perror.c	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
 #include "../storage/ndb/src/kernel/error/ndbd_exit_codes.c"
 #include "../storage/ndb/include/mgmapi/mgmapi_error.h"
 #endif
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
 static my_bool verbose, print_all_codes;
 
@@ -115,7 +116,7 @@ static void print_version(void)
 static void usage(void)
 {
   print_version();
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   printf("Print a description for a system error code or a MySQL error code.\n");
   printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n");
   printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname);

=== modified file 'extra/yassl/src/ssl.cpp'
--- a/extra/yassl/src/ssl.cpp	2012-02-13 11:40:12 +0000
+++ b/extra/yassl/src/ssl.cpp	2012-08-11 10:13:04 +0000
@@ -747,7 +747,7 @@ void SSL_CTX_set_verify(SSL_CTX* ctx, in
 int SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,
                                   const char* path)
 {
-    int       ret = SSL_SUCCESS;
+    int       ret = SSL_FAILURE;
     const int HALF_PATH = 128;
 
     if (file) ret = read_file(ctx, file, SSL_FILETYPE_PEM, CA);

=== modified file 'extra/yassl/taocrypt/src/Makefile.am'
--- a/extra/yassl/taocrypt/src/Makefile.am	2012-04-05 08:49:38 +0000
+++ b/extra/yassl/taocrypt/src/Makefile.am	2012-11-06 09:52:55 +0000
@@ -6,7 +6,7 @@ libtaocrypt_la_SOURCES  = aes.cpp aestab
         asn.cpp bftables.cpp blowfish.cpp coding.cpp des.cpp dh.cpp \
         dsa.cpp file.cpp hash.cpp integer.cpp md2.cpp md4.cpp md5.cpp misc.cpp \
         random.cpp ripemd.cpp rsa.cpp sha.cpp template_instnt.cpp \
-        tftables.cpp twofish.cpp crypto.cpp rabbit.cpp hc128.cpp
+        tftables.cpp twofish.cpp rabbit.cpp hc128.cpp
 
 libtaocrypt_la_CXXFLAGS = @yassl_taocrypt_extra_cxxflags@ -DYASSL_PURE_C \
                           @yassl_thread_cxxflags@

=== removed file 'extra/yassl/taocrypt/src/crypto.cpp'
--- a/extra/yassl/taocrypt/src/crypto.cpp	2007-08-28 08:35:55 +0000
+++ b/extra/yassl/taocrypt/src/crypto.cpp	1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-/*
-   Copyright (C) 2000-2007 MySQL AB
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; see the file COPYING. If not, write to the
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-   MA  02110-1301  USA.
-*/
-
-/* put features that other apps expect from OpenSSL type crypto */
-
-
-
-extern "C" {
-
-    // for libcurl configure test, these are the signatures they use
-    // locking handled internally by library
-    char CRYPTO_lock() { return 0;}
-    char CRYPTO_add_lock() { return 0;}
-
-
-    // for openvpn, test are the signatures they use
-    char EVP_CIPHER_CTX_init() { return 0; }
-    char CRYPTO_mem_ctrl() { return 0; }
-}  // extern "C"
-
-
-

=== modified file 'include/welcome_copyright_notice.h'
--- a/include/welcome_copyright_notice.h	2011-11-21 17:13:14 +0000
+++ b/include/welcome_copyright_notice.h	2012-11-06 09:52:55 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -16,12 +16,14 @@
 #ifndef _welcome_copyright_notice_h_
 #define _welcome_copyright_notice_h_
 
+#define COPYRIGHT_NOTICE_CURRENT_YEAR "2012"
+
 /*
   This define specifies copyright notice which is displayed by every MySQL
   program on start, or on help screen.
 */
-
-#define ORACLE_WELCOME_COPYRIGHT_NOTICE(years) \
-  "Copyright (c) " years ", Oracle, Monty Program Ab and others.\n"
+#define ORACLE_WELCOME_COPYRIGHT_NOTICE(first_year) \
+  "Copyright (c) " first_year ", " COPYRIGHT_NOTICE_CURRENT_YEAR \
+   ", Oracle, Monty Program Ab and others.\n"
 
 #endif /* _welcome_copyright_notice_h_ */

=== modified file 'mysql-test/Makefile.am'
--- a/mysql-test/Makefile.am	2011-11-21 17:13:14 +0000
+++ b/mysql-test/Makefile.am	2012-11-06 09:52:55 +0000
@@ -83,6 +83,7 @@ TEST_DIRS = t r include std_data std_dat
         extra/binlog_tests/ extra/rpl_tests \
         suite/binlog suite/binlog/t suite/binlog/r suite/binlog/std_data \
         suite/federated \
+        suite/federated/include \
         suite/funcs_1 suite/funcs_1/bitdata \
         suite/funcs_1/include suite/funcs_1/lib suite/funcs_1/r \
         suite/funcs_1/t suite/funcs_1/views suite/funcs_1/cursors \

=== modified file 'mysql-test/r/openssl_1.result'
--- a/mysql-test/r/openssl_1.result	2010-06-13 22:13:32 +0000
+++ b/mysql-test/r/openssl_1.result	2012-11-06 09:52:55 +0000
@@ -44,9 +44,9 @@ ERROR 42000: DELETE command denied to us
 drop user ssl_user1 at localhost, ssl_user2 at localhost,
 ssl_user3 at localhost, ssl_user4 at localhost, ssl_user5 at localhost;
 drop table t1;
-mysqltest: Could not open connection 'default': 2026 SSL error: ASN: bad other signature confirmation
-mysqltest: Could not open connection 'default': 2026 SSL error: ASN: bad other signature confirmation
-mysqltest: Could not open connection 'default': 2026 SSL error: ASN: bad other signature confirmation
+mysqltest: Could not open connection 'default': 2026 SSL connection error: xxxx
+mysqltest: Could not open connection 'default': 2026 SSL connection error: xxxx
+mysqltest: Could not open connection 'default': 2026 SSL connection error: xxxx
 SSL error: Unable to get private key from ''
 mysqltest: Could not open connection 'default': 2026 SSL connection error
 SSL error: Unable to get certificate from ''

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2012-05-17 10:12:33 +0000
+++ b/mysql-test/r/subselect.result	2012-11-06 09:52:55 +0000
@@ -4555,8 +4555,6 @@ SELECT * FROM t1
 WHERE EXISTS (SELECT DISTINCT a FROM t2 WHERE t1.a < t2.a ORDER BY b);
 pk      a
 1       10
-3       30
-2       20
 DROP TABLE t1,t2;
 CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), KEY b (b));
 INSERT INTO t1 VALUES (1,NULL), (9,NULL);

=== modified file 'mysql-test/suite/federated/federated_archive.test'
--- a/mysql-test/suite/federated/federated_archive.test	2007-12-12 17:19:24 +0000
+++ b/mysql-test/suite/federated/federated_archive.test	2012-07-26 09:39:22 +0000
@@ -1,5 +1,5 @@
 source include/have_archive.inc;
-source federated.inc;
+source suite/federated/include/federated.inc;
 
 
 connection slave;
@@ -54,5 +54,5 @@ connection slave;
 DROP TABLE federated.archive_table;
 
 
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;
 

=== modified file 'mysql-test/suite/federated/federated_bug_13118.test'
--- a/mysql-test/suite/federated/federated_bug_13118.test	2007-12-12 17:19:24 +0000
+++ b/mysql-test/suite/federated/federated_bug_13118.test	2012-07-26 09:39:22 +0000
@@ -1,4 +1,4 @@
-source federated.inc;
+source suite/federated/include/federated.inc;
 
 connection slave;
 --disable_warnings
@@ -37,5 +37,5 @@ connection slave;
 DROP TABLE federated.bug_13118_table;
 
 
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;
 

=== modified file 'mysql-test/suite/federated/federated_bug_25714.test'
--- a/mysql-test/suite/federated/federated_bug_25714.test	2009-02-02 11:36:03 +0000
+++ b/mysql-test/suite/federated/federated_bug_25714.test	2012-07-26 09:39:22 +0000
@@ -4,7 +4,7 @@ if (`select LENGTH("$MYSQL_BUG25714") =
   skip Need bug25714 test program;
 }
 
-source federated.inc;
+source suite/federated/include/federated.inc;
 
 connection master;
 # Disable concurrent inserts to avoid test failures when reading
@@ -59,4 +59,4 @@ SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLA
 
 
 
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federated_bug_32426.test'
--- a/mysql-test/suite/federated/federated_bug_32426.test	2010-08-18 07:52:57 +0000
+++ b/mysql-test/suite/federated/federated_bug_32426.test	2012-11-06 09:52:55 +0000
@@ -1,4 +1,4 @@
-source federated.inc;
+source include/federated.inc;
 
 --echo #
 --echo # Bug #32426: FEDERATED query returns corrupt results for ORDER BY 
@@ -21,4 +21,4 @@ DROP TABLE federated.t1;
 
 connection default;
 
-source federated_cleanup.inc;
+source include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federated_bug_35333.test'
--- a/mysql-test/suite/federated/federated_bug_35333.test	2011-02-20 16:51:43 +0000
+++ b/mysql-test/suite/federated/federated_bug_35333.test	2012-11-06 09:52:55 +0000
@@ -9,7 +9,7 @@
 --echo # to complete while still indicating a problem. This fix applies to any non-fatal system
 --echo # error that occurs during a query against I_S.TABLES.de
 
---source federated.inc
+--source suite/federated/include/federated.inc
 
 --disable_warnings
 # Federated database exists
@@ -74,4 +74,4 @@ DROP TABLE t1;
 --echo # Cleanup
 --echo #
 
---source federated_cleanup.inc
+--source suite/federated/include/federated_cleanup.inc

=== modified file 'mysql-test/suite/federated/federated_bug_585688.test'
--- a/mysql-test/suite/federated/federated_bug_585688.test	2011-02-10 20:40:59 +0000
+++ b/mysql-test/suite/federated/federated_bug_585688.test	2012-11-06 09:52:55 +0000
@@ -1,4 +1,4 @@
-source federated.inc;
+source include/federated.inc;
 
 --echo #
 --echo # Bug #585688: maridb crashes in federatedx code
@@ -49,5 +49,5 @@ DROP TABLE federated.t1;
 
 connection default;
 
-source federated_cleanup.inc;
+source include/federated_cleanup.inc;
 

=== modified file 'mysql-test/suite/federated/federated_debug.test'
--- a/mysql-test/suite/federated/federated_debug.test	2011-01-03 14:33:39 +0000
+++ b/mysql-test/suite/federated/federated_debug.test	2012-11-06 09:52:55 +0000
@@ -1,6 +1,6 @@
 --source include/have_debug.inc
 --source include/long_test.inc
---source federated.inc
+--source include/federated.inc
 
 --echo #
 --echo # Bug#47525: MySQL crashed (Federated)
@@ -37,4 +37,4 @@ DROP TABLE t1;
 
 connection default;
 --echo # Federated cleanup
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federated_innodb.test'
--- a/mysql-test/suite/federated/federated_innodb.test	2008-12-13 19:42:12 +0000
+++ b/mysql-test/suite/federated/federated_innodb.test	2012-07-26 09:39:22 +0000
@@ -4,7 +4,7 @@
 # See Bug #40645 Test main.federated_innodb does not always clean up after itself
 
 source include/have_innodb.inc;
-source federated.inc;
+source suite/federated/include/federated.inc;
 
 #
 # Bug#25513 Federated transaction failures
@@ -36,4 +36,4 @@ connection slave;
 drop table federated.t1;
 
 
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federated_partition.test'
--- a/mysql-test/suite/federated/federated_partition.test	2011-11-30 10:37:28 +0000
+++ b/mysql-test/suite/federated/federated_partition.test	2012-11-06 09:52:55 +0000
@@ -4,7 +4,7 @@
 source have_federatedx.inc;
 source include/have_partition.inc;
 source include/have_innodb.inc;
-source federated.inc;
+source include/federated.inc;
 
 disable_warnings;
 drop table if exists t1;
@@ -50,4 +50,4 @@ drop table federated.t1_2;
 
 --echo End of 5.1 tests
 
-source federated_cleanup.inc;
+source include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federated_server.test'
--- a/mysql-test/suite/federated/federated_server.test	2012-04-05 08:49:38 +0000
+++ b/mysql-test/suite/federated/federated_server.test	2012-11-06 09:52:55 +0000
@@ -4,7 +4,7 @@
 # Slow test, don't run during staging part
 -- source include/not_staging.inc
 -- source include/big_test.inc
--- source federated.inc
+-- source include/federated.inc
 
 connection slave;
 create database first_db;
@@ -343,4 +343,4 @@ drop procedure p1;
 drop server if exists s;
 
 
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federated_transactions.test'
--- a/mysql-test/suite/federated/federated_transactions.test	2011-11-30 10:37:28 +0000
+++ b/mysql-test/suite/federated/federated_transactions.test	2012-11-06 09:52:55 +0000
@@ -1,6 +1,6 @@
 source have_federatedx.inc;
 source include/have_innodb.inc;
-source federated.inc;
+source suite/federated/include/federated.inc;
 
 connection slave;
 DROP TABLE IF EXISTS federated.t1;
@@ -36,4 +36,4 @@ INSERT INTO federated.t1 (id, name) VALU
 SELECT * FROM federated.t1;
 DELETE FROM federated.t1;
 
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;

=== modified file 'mysql-test/suite/federated/federatedx.test'
--- a/mysql-test/suite/federated/federatedx.test	2011-11-30 10:37:28 +0000
+++ b/mysql-test/suite/federated/federatedx.test	2012-11-06 09:52:55 +0000
@@ -6,7 +6,7 @@
 
 # should work with embedded server after mysqltest is fixed
 --source include/not_embedded.inc
---source federated.inc
+--source include/federated.inc
 --source have_federatedx.inc
 
 connection default;
@@ -2001,4 +2001,4 @@ connection slave;
 SET @@GLOBAL.CONCURRENT_INSERT= @OLD_SLAVE_CONCURRENT_INSERT;
 
 connection default;
-source federated_cleanup.inc;
+source suite/federated/include/federated_cleanup.inc;

=== added directory 'mysql-test/suite/federated/include'
=== renamed file 'mysql-test/suite/federated/federated.inc' => 'mysql-test/suite/federated/include/federated.inc'
=== renamed file 'mysql-test/suite/federated/federated_cleanup.inc' => 'mysql-test/suite/federated/include/federated_cleanup.inc'
=== modified file 'mysql-test/suite/innodb/r/innodb_misc1.result'
--- a/mysql-test/suite/innodb/r/innodb_misc1.result	2010-08-04 08:39:53 +0000
+++ b/mysql-test/suite/innodb/r/innodb_misc1.result	2012-11-06 09:52:55 +0000
@@ -774,7 +774,7 @@ c21 CHAR(255), c22 CHAR(255), c23 CHAR(2
 c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
 c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
 ) ENGINE = InnoDB;
-ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
+ERROR 42000: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
 DROP TABLE IF EXISTS t1;
 Warnings:
 Note    1051    Unknown table 't1'

=== added file 'mysql-test/suite/innodb_plugin/r/innodb_information_schema_buffer.result'
--- a/mysql-test/suite/innodb_plugin/r/innodb_information_schema_buffer.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/r/innodb_information_schema_buffer.result	2012-07-25 08:21:39 +0000
@@ -0,0 +1,127 @@
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
+SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
+CREATE TABLE infoschema_buffer_test (col1 INT) ENGINE = INNODB;
+INSERT INTO infoschema_buffer_test VALUES(9);
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test"
+        and PAGE_STATE="file_page" and PAGE_TYPE="index";
+TABLE_NAME      INDEX_NAME      NUMBER_RECORDS  DATA_SIZE       PAGE_STATE      PAGE_TYPE
+test/infoschema_buffer_test     GEN_CLUST_INDEX 1       29      FILE_PAGE       INDEX
+INSERT INTO infoschema_buffer_test VALUES(19);
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test"
+and PAGE_STATE="file_page" and PAGE_TYPE="index";
+TABLE_NAME      INDEX_NAME      NUMBER_RECORDS  DATA_SIZE       PAGE_STATE      PAGE_TYPE
+test/infoschema_buffer_test     GEN_CLUST_INDEX 2       58      FILE_PAGE       INDEX
+CREATE INDEX idx ON infoschema_buffer_test(col1);
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test"
+and PAGE_STATE="file_page" and INDEX_NAME = "idx" and PAGE_TYPE="index";
+TABLE_NAME      INDEX_NAME      NUMBER_RECORDS  DATA_SIZE       PAGE_STATE      PAGE_TYPE
+test/infoschema_buffer_test     idx     2       32      FILE_PAGE       INDEX
+DROP TABLE infoschema_buffer_test;
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test";
+TABLE_NAME      INDEX_NAME      NUMBER_RECORDS  DATA_SIZE       PAGE_STATE      PAGE_TYPE
+CREATE TABLE infoschema_parent (id INT NOT NULL, PRIMARY KEY (id))
+ENGINE=INNODB;
+CREATE TABLE infoschema_child (id INT, parent_id INT, INDEX par_ind (parent_id),
+FOREIGN KEY (parent_id)
+REFERENCES infoschema_parent(id)
+ON DELETE CASCADE)
+ENGINE=INNODB;
+SELECT count(*)
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_child" and PAGE_STATE="file_page"
+and PAGE_TYPE="index";
+count(*)
+2
+DROP TABLE infoschema_child;
+DROP TABLE infoschema_parent;
+show create table information_schema.innodb_buffer_page;
+Table   Create Table
+INNODB_BUFFER_PAGE      CREATE TEMPORARY TABLE `INNODB_BUFFER_PAGE` (
+  `BLOCK_ID` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `SPACE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGE_NUMBER` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGE_TYPE` varchar(64) DEFAULT NULL,
+  `FLUSH_TYPE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `FIX_COUNT` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `IS_HASHED` varchar(3) DEFAULT NULL,
+  `NEWEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `OLDEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `ACCESS_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `TABLE_NAME` varchar(1024) DEFAULT NULL,
+  `INDEX_NAME` varchar(1024) DEFAULT NULL,
+  `NUMBER_RECORDS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `DATA_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `COMPRESSED_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGE_STATE` varchar(64) DEFAULT NULL,
+  `IO_FIX` varchar(64) DEFAULT NULL,
+  `IS_OLD` varchar(3) DEFAULT NULL,
+  `FREE_PAGE_CLOCK` bigint(21) unsigned NOT NULL DEFAULT '0'
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+show create table information_schema.innodb_buffer_page_lru;
+Table   Create Table
+INNODB_BUFFER_PAGE_LRU  CREATE TEMPORARY TABLE `INNODB_BUFFER_PAGE_LRU` (
+  `LRU_POSITION` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `SPACE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGE_NUMBER` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGE_TYPE` varchar(64) DEFAULT NULL,
+  `FLUSH_TYPE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `FIX_COUNT` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `IS_HASHED` varchar(3) DEFAULT NULL,
+  `NEWEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `OLDEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `ACCESS_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `TABLE_NAME` varchar(1024) DEFAULT NULL,
+  `INDEX_NAME` varchar(1024) DEFAULT NULL,
+  `NUMBER_RECORDS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `DATA_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `COMPRESSED_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `COMPRESSED` varchar(3) DEFAULT NULL,
+  `IO_FIX` varchar(64) DEFAULT NULL,
+  `IS_OLD` varchar(3) DEFAULT NULL,
+  `FREE_PAGE_CLOCK` bigint(21) unsigned NOT NULL DEFAULT '0'
+) ENGINE=MEMORY DEFAULT CHARSET=utf8
+show create table information_schema.innodb_buffer_pool_stats;
+Table   Create Table
+INNODB_BUFFER_POOL_STATS        CREATE TEMPORARY TABLE `INNODB_BUFFER_POOL_STATS` (
+  `POOL_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `FREE_BUFFERS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `DATABASE_PAGES` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `OLD_DATABASE_PAGES` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `MODIFIED_DATABASE_PAGES` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PENDING_DECOMPRESS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PENDING_READS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PENDING_FLUSH_LRU` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PENDING_FLUSH_LIST` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGES_MADE_YOUNG` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGES_NOT_MADE_YOUNG` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGES_MADE_YOUNG_RATE` double NOT NULL DEFAULT '0',
+  `PAGES_MADE_NOT_YOUNG_RATE` double NOT NULL DEFAULT '0',
+  `NUMBER_PAGES_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `NUMBER_PAGES_CREATED` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `NUMBER_PAGES_WRITTEN` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `PAGES_READ_RATE` double NOT NULL DEFAULT '0',
+  `PAGES_CREATE_RATE` double NOT NULL DEFAULT '0',
+  `PAGES_WRITTEN_RATE` double NOT NULL DEFAULT '0',
+  `NUMBER_PAGES_GET` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `HIT_RATE` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `YOUNG_MAKE_PER_THOUSAND_GETS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `NOT_YOUNG_MAKE_PER_THOUSAND_GETS` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `NUMBER_PAGES_READ_AHEAD` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `NUMBER_READ_AHEAD_EVICTED` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `READ_AHEAD_RATE` double NOT NULL DEFAULT '0',
+  `READ_AHEAD_EVICTED_RATE` double NOT NULL DEFAULT '0',
+  `LRU_IO_TOTAL` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `LRU_IO_CURRENT` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `UNCOMPRESS_TOTAL` bigint(21) unsigned NOT NULL DEFAULT '0',
+  `UNCOMPRESS_CURRENT` bigint(21) unsigned NOT NULL DEFAULT '0'
+) ENGINE=MEMORY DEFAULT CHARSET=utf8

=== added file 'mysql-test/suite/innodb_plugin/t/innodb_information_schema_buffer.test'
--- a/mysql-test/suite/innodb_plugin/t/innodb_information_schema_buffer.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb_plugin/t/innodb_information_schema_buffer.test	2012-07-25 08:21:39 +0000
@@ -0,0 +1,76 @@
+# Exercise the code path for INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS
+# and INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+
+-- source include/have_innodb_plugin.inc
+
+-- disable_result_log
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
+
+# How many buffer pools we have
+SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
+
+SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
+
+# This gives the over all buffer pool size
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
+
+-- enable_result_log
+
+# Create a table and check its page info behave correctly in the pool
+CREATE TABLE infoschema_buffer_test (col1 INT) ENGINE = INNODB;
+
+INSERT INTO infoschema_buffer_test VALUES(9);
+
+# We should be able to see this table in the buffer pool if we check
+# right away
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test"
+        and PAGE_STATE="file_page" and PAGE_TYPE="index";
+
+# The NUMBER_RECORDS and DATA_SIZE should check with each insertion
+INSERT INTO infoschema_buffer_test VALUES(19);
+
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test"
+and PAGE_STATE="file_page" and PAGE_TYPE="index";
+
+CREATE INDEX idx ON infoschema_buffer_test(col1);
+
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test"
+and PAGE_STATE="file_page" and INDEX_NAME = "idx" and PAGE_TYPE="index";
+
+
+# Check the buffer after dropping the table
+DROP TABLE infoschema_buffer_test;
+
+SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_buffer_test";
+
+# Do one more test
+#--replace_regex /'*[0-9]*'/'NUM'/
+CREATE TABLE infoschema_parent (id INT NOT NULL, PRIMARY KEY (id))
+ENGINE=INNODB;
+
+CREATE TABLE infoschema_child (id INT, parent_id INT, INDEX par_ind (parent_id),
+                               FOREIGN KEY (parent_id)
+                               REFERENCES infoschema_parent(id)
+                               ON DELETE CASCADE)
+ENGINE=INNODB;
+
+SELECT count(*)
+FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+WHERE TABLE_NAME like "%infoschema_child" and PAGE_STATE="file_page"
+and PAGE_TYPE="index";
+
+DROP TABLE infoschema_child;
+DROP TABLE infoschema_parent;
+
+show create table information_schema.innodb_buffer_page;
+show create table information_schema.innodb_buffer_page_lru;
+show create table information_schema.innodb_buffer_pool_stats;
+

=== modified file 'mysql-test/t/openssl_1.test'
--- a/mysql-test/t/openssl_1.test	2010-11-23 06:24:44 +0000
+++ b/mysql-test/t/openssl_1.test	2012-11-06 09:52:55 +0000
@@ -74,25 +74,31 @@ drop table t1;
 #
 --exec echo "this query should not execute;" > $MYSQLTEST_VARDIR/tmp/test.sql
 # Handle that openssl gives different error messages from YaSSL.
---replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/
+#--replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/
+--replace_regex /2026 SSL error.*/2026 SSL connection error: xxxx/
 --error 1
 --exec $MYSQL_TEST --ssl-ca=$MYSQL_TEST_DIR/std_data/untrusted-cacert.pem --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
+--echo
 
 #
 # Test that we can't open connection to server if we are using
 # a blank ca
 #
---replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/
+#--replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/
+--replace_regex /2026 SSL error.*/2026 SSL connection error: xxxx/
 --error 1
 --exec $MYSQL_TEST --ssl-ca= --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
+--echo
 
 #
 # Test that we can't open connection to server if we are using
 # a nonexistent ca file
 #
---replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/
+#--replace_regex /error:00000005:lib\(0\):func\(0\):DH lib/ASN: bad other signature confirmation/
+--replace_regex /2026 SSL error.*/2026 SSL connection error: xxxx/
 --error 1
 --exec $MYSQL_TEST --ssl-ca=nonexisting_file.pem --max-connect-retries=1 < $MYSQLTEST_VARDIR/tmp/test.sql 2>&1
+--echo
 
 #
 # Test that we can't open connection to server if we are using

=== modified file 'scripts/mysql_secure_installation.pl.in'
--- a/scripts/mysql_secure_installation.pl.in	2011-11-21 17:13:14 +0000
+++ b/scripts/mysql_secure_installation.pl.in	2012-11-06 09:52:55 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # -*- cperl -*-
 #
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@ my $mysql;  # How to call the mysql clie
 my $rootpass = "";
 
 
-$SIG{QUIT} = $SIG{INT} = sub {
+$SIG{QUIT} = $SIG{INT} = $SIG{TERM} = $SIG{ABRT} = $SIG{HUP} = sub {
   print "\nAborting!\n\n";
   echo_on();
   cleanup();
@@ -242,7 +242,11 @@ sub reload_privilege_tables {
 }
 
 sub cleanup {
-  unlink($config,$command);
+  print "Cleaning up...\n";
+
+  foreach my $file ($config, $command) {
+    unlink $file or warn "Warning: Could not unlink $file: $!\n";
+  }
 }
 
 

=== modified file 'scripts/mysql_secure_installation.sh'
--- a/scripts/mysql_secure_installation.sh	2011-11-21 17:13:14 +0000
+++ b/scripts/mysql_secure_installation.sh	2012-11-06 09:52:55 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright (c) 2002, 2010, Oracle and/or its affiliates
+# Copyright (c) 2002, 2012, Oracle and/or its affiliates.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
 config=".my.cnf.$$"
 command=".mysql.$$"
 
-trap "interrupt" 2
+trap "interrupt" 1 2 3 6 15
 
 rootpass=""
 echo_n=
@@ -286,13 +286,16 @@ set_root_password() {
     if [ $? -eq 0 ]; then
         echo "Password updated successfully!"
         echo "Reloading privilege tables.."
-        reload_privilege_tables || exit 1
+        reload_privilege_tables
+        if [ $? -eq 1 ]; then
+                clean_and_exit
+        fi
         echo
         rootpass=$password1
         make_config
     else
         echo "Password update failed!"
-        exit 1
+        clean_and_exit
     fi
 
     return 0
@@ -304,7 +307,7 @@ remove_anonymous_users() {
         echo " ... Success!"
     else
         echo " ... Failed!"
-        exit 1
+        clean_and_exit
     fi
 
     return 0
@@ -364,6 +367,11 @@ cleanup() {
     rm -f $config $command
 }
 
+# Remove the files before exiting.
+clean_and_exit() {
+        cleanup
+        exit 1
+}
 
 # The actual script starts here
 

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2012-04-05 08:49:38 +0000
+++ b/sql/filesort.cc	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.  
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -296,8 +296,7 @@ ha_rows filesort(THD *thd, TABLE *table,
       Use also the space previously used by string pointers in sort_buffer
       for temporary key storage.
     */
-    param.keys=((param.keys*(param.rec_length+sizeof(char*))) /
-                param.rec_length-1);
+    param.keys= table_sort.sort_keys_size / param.rec_length;
     maxbuffer--;                                // Offset from 0
     if (merge_many_buff(&param,(uchar*) sort_keys,buffpek,&maxbuffer,
                         &tempfile))

=== modified file 'sql/gen_lex_hash.cc'
--- a/sql/gen_lex_hash.cc	2011-11-21 17:13:14 +0000
+++ b/sql/gen_lex_hash.cc	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -89,6 +89,8 @@ So, we can read full search-structure as
 #include "mysql_version.h"
 #include "lex.h"
 
+#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
+
 const char *default_dbug_option="d:t:o,/tmp/gen_lex_hash.trace";
 
 struct my_option my_long_options[] =
@@ -348,10 +350,7 @@ static void usage(int version)
          my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
   if (version)
     return;
-  puts("Copyright (C) 2001 MySQL AB, by VVA and Monty");
-  puts("Copyright (C) 2011 Oracle");
-  puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
-and you are welcome to modify and redistribute it under the GPL license\n");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
   puts("This program generates a perfect hashing function for the sql_lex.cc");
   printf("Usage: %s [OPTIONS]\n\n", my_progname);
   my_print_help(my_long_options);
@@ -453,25 +452,9 @@ int main(int argc,char **argv)
   /* Broken up to indicate that it's not advice to you, gentle reader. */
   printf("/*\n\n  Do " "not " "edit " "this " "file " "directly!\n\n*/\n");
 
-  printf("\
-/* Copyright (C) 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.\n\
-   Copyright (C) 2008-2011 Oracle\n\
-\n\
-   This program is free software; you can redistribute it and/or modify\n\
-   it under the terms of the GNU General Public License as published by\n\
-   the Free Software Foundation; version 2 of the License.\n\
-\n\
-   This program is distributed in the hope that it will be useful,\n\
-   but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\
-   GNU General Public License for more details.\n\
-\n\
-   You should have received a copy of the GNU General Public License\n\
-   along with this program; see the file COPYING. If not, write to the\n\
-   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston\n\
-   MA  02110-1301  USA. */\n\
-\n\
-");
+  puts("/*");
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
+  puts("*/");
 
   /* Broken up to indicate that it's not advice to you, gentle reader. */
   printf("/* Do " "not " "edit " "this " "file!  This is generated by "

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2012-10-31 21:49:51 +0000
+++ b/sql/ha_partition.cc	2012-11-06 09:52:55 +0000
@@ -324,9 +324,7 @@ ha_partition::~ha_partition()
     for (i= 0; i < m_tot_parts; i++)
       delete m_file[i];
   }
-
-  my_free(m_ordered_rec_buffer, MYF(MY_ALLOW_ZERO_PTR));
-  m_ordered_rec_buffer= NULL;
+  destroy_record_priority_queue();
 
   clear_handler_file();
 
@@ -2659,7 +2657,6 @@ int ha_partition::open(const char *name,
 {
   char *name_buffer_ptr;
   int error= HA_ERR_INITIALIZATION;
-  uint alloc_len;
   handler **file;
   char name_buff[FN_REFLEN];
   bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE);
@@ -2677,32 +2674,6 @@ int ha_partition::open(const char *name,
   m_start_key.length= 0;
   m_rec0= table->record[0];
   m_rec_length= table_share->reclength;
-  alloc_len= m_tot_parts * (m_rec_length + PARTITION_BYTES_IN_POS);
-  alloc_len+= table_share->max_key_length;
-  if (!m_ordered_rec_buffer)
-  {
-    if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME))))
-    {
-      DBUG_RETURN(error);
-    }
-    {
-      /*
-        We set-up one record per partition and each record has 2 bytes in
-        front where the partition id is written. This is used by ordered
-        index_read.
-        We also set-up a reference to the first record for temporary use in
-        setting up the scan.
-      */
-      char *ptr= (char*)m_ordered_rec_buffer;
-      uint i= 0;
-      do
-      {
-        int2store(ptr, i);
-        ptr+= m_rec_length + PARTITION_BYTES_IN_POS;
-      } while (++i < m_tot_parts);
-      m_start_key.key= (const uchar*)ptr;
-    }
-  }
 
   /* Initialize the bitmap we use to minimize ha_start_bulk_insert calls */
   if (bitmap_init(&m_bulk_insert_started, NULL, m_tot_parts + 1, FALSE))
@@ -2722,7 +2693,7 @@ int ha_partition::open(const char *name,
 
   if (m_is_clone_of)
   {
-    uint i;
+    uint i, alloc_len;
     DBUG_ASSERT(m_clone_mem_root);
     /* Allocate an array of handler pointers for the partitions handlers. */
     alloc_len= (m_tot_parts + 1) * sizeof(handler*);
@@ -2800,12 +2771,6 @@ int ha_partition::open(const char *name,
     being opened once.
   */
   clear_handler_file();
-  /*
-    Initialize priority queue, initialized to reading forward.
-  */
-  if ((error= init_queue(&m_queue, m_tot_parts, (uint) PARTITION_BYTES_IN_POS,
-                         0, key_rec_cmp, (void*)this)))
-    goto err_handler;
 
   /*
     Use table_share->ha_data to share auto_increment_value among all handlers
@@ -2928,7 +2893,7 @@ int ha_partition::close(void)
   DBUG_ENTER("ha_partition::close");
 
   DBUG_ASSERT(table->s == table_share);
-  delete_queue(&m_queue);
+  destroy_record_priority_queue();
   bitmap_free(&m_bulk_insert_started);
   if (!m_is_clone_of)
     bitmap_free(&(m_part_info->used_partitions));
@@ -4146,6 +4111,78 @@ int ha_partition::rnd_pos_by_record(ucha
     subset of the partitions are used, then only use those partitions.
 */
 
+
+/**
+  Setup the ordered record buffer and the priority queue.
+*/
+
+bool ha_partition::init_record_priority_queue()
+{
+  DBUG_ENTER("ha_partition::init_record_priority_queue");
+  DBUG_ASSERT(!m_ordered_rec_buffer);
+  /*
+    Initialize the ordered record buffer.
+  */
+  if (!m_ordered_rec_buffer)
+  {
+    uint alloc_len;
+    uint used_parts= bitmap_bits_set(&m_part_info->used_partitions);
+    /* Allocate record buffer for each used partition. */
+    alloc_len= used_parts * (m_rec_length + PARTITION_BYTES_IN_POS);
+    /* Allocate a key for temporary use when setting up the scan. */
+    alloc_len+= table_share->max_key_length;
+
+    if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME))))
+      DBUG_RETURN(true);
+
+    /*
+      We set-up one record per partition and each record has 2 bytes in
+      front where the partition id is written. This is used by ordered
+      index_read.
+      We also set-up a reference to the first record for temporary use in
+      setting up the scan.
+    */
+    char *ptr= (char*) m_ordered_rec_buffer;
+    uint16 i= 0;
+    do
+    {
+      if (bitmap_is_set(&m_part_info->used_partitions, i))
+      {
+        int2store(ptr, i);
+        ptr+= m_rec_length + PARTITION_BYTES_IN_POS;
+      }
+    } while (++i < m_tot_parts);
+    m_start_key.key= (const uchar*)ptr;
+    /* Initialize priority queue, initialized to reading forward. */
+    if (init_queue(&m_queue, used_parts, (uint) PARTITION_BYTES_IN_POS,
+                   0, key_rec_cmp, (void*)m_curr_key_info))
+    {
+      my_free(m_ordered_rec_buffer, MYF(0));
+      m_ordered_rec_buffer= NULL;
+      DBUG_RETURN(true);
+    }
+  }
+  DBUG_RETURN(false);
+}
+
+
+/**
+  Destroy the ordered record buffer and the priority queue.
+*/
+
+void ha_partition::destroy_record_priority_queue()
+{
+  DBUG_ENTER("ha_partition::destroy_record_priority_queue");
+  if (m_ordered_rec_buffer)
+  {
+    delete_queue(&m_queue);
+    my_free(m_ordered_rec_buffer, MYF(0));
+    m_ordered_rec_buffer= NULL;
+  }
+  DBUG_VOID_RETURN;
+}
+
+
 /*
   Initialize handler before start of index scan
 
@@ -4187,6 +4224,10 @@ int ha_partition::index_init(uint inx, b
   }
   else
     m_curr_key_info[1]= NULL;
+
+  if (init_record_priority_queue())
+    DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+
   /*
     Some handlers only read fields as specified by the bitmap for the
     read set. For partitioned handlers we always require that the
@@ -4261,11 +4302,11 @@ int ha_partition::index_end()
   do
   {
     int tmp;
-    /* TODO RONM: Change to index_end() when code is stable */
     if (bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
       if ((tmp= (*file)->ha_index_end()))
         error= tmp;
   } while (*(++file));
+  destroy_record_priority_queue();
   DBUG_RETURN(error);
 }
 
@@ -5005,6 +5046,7 @@ int ha_partition::handle_ordered_index_s
   uint i;
   uint j= 0;
   bool found= FALSE;
+  uchar *part_rec_buf_ptr= m_ordered_rec_buffer;
   DBUG_ENTER("ha_partition::handle_ordered_index_scan");
 
   m_top_entry= NO_CURRENT_PART_ID;
@@ -5015,7 +5057,7 @@ int ha_partition::handle_ordered_index_s
   {
     if (!(bitmap_is_set(&(m_part_info->used_partitions), i)))
       continue;
-    uchar *rec_buf_ptr= rec_buf(i);
+    uchar *rec_buf_ptr= part_rec_buf_ptr + PARTITION_BYTES_IN_POS;
     int error;
     handler *file= m_file[i];
 
@@ -5062,12 +5104,13 @@ int ha_partition::handle_ordered_index_s
       /*
         Initialize queue without order first, simply insert
       */
-      queue_element(&m_queue, j++)= (uchar*)queue_buf(i);
+      queue_element(&m_queue, j++)= part_rec_buf_ptr;
     }
     else if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
     {
       DBUG_RETURN(error);
     }
+    part_rec_buf_ptr+= m_rec_length + PARTITION_BYTES_IN_POS;
   }
   if (found)
   {
@@ -5130,18 +5173,19 @@ int ha_partition::handle_ordered_next(uc
 {
   int error;
   uint part_id= m_top_entry;
+  uchar *rec_buf= queue_top(&m_queue) + PARTITION_BYTES_IN_POS;
   handler *file= m_file[part_id];
   DBUG_ENTER("ha_partition::handle_ordered_next");
   
   if (m_index_scan_type == partition_read_range)
   {
     error= file->read_range_next();
-    memcpy(rec_buf(part_id), table->record[0], m_rec_length);
+    memcpy(rec_buf, table->record[0], m_rec_length);
   }
   else if (!is_next_same)
-    error= file->index_next(rec_buf(part_id));
+    error= file->index_next(rec_buf);
   else
-    error= file->index_next_same(rec_buf(part_id), m_start_key.key,
+    error= file->index_next_same(rec_buf, m_start_key.key,
                                  m_start_key.length);
   if (error)
   {
@@ -5184,10 +5228,11 @@ int ha_partition::handle_ordered_prev(uc
 {
   int error;
   uint part_id= m_top_entry;
+  uchar *rec_buf= queue_top(&m_queue) + PARTITION_BYTES_IN_POS;
   handler *file= m_file[part_id];
   DBUG_ENTER("ha_partition::handle_ordered_prev");
 
-  if ((error= file->index_prev(rec_buf(part_id))))
+  if ((error= file->index_prev(rec_buf)))
   {
     if (error == HA_ERR_END_OF_FILE)
     {

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2012-05-17 10:12:33 +0000
+++ b/sql/ha_partition.h	2012-11-06 09:52:55 +0000
@@ -519,21 +519,13 @@ class ha_partition :public handler
   virtual int read_range_next();
 
 private:
+  bool init_record_priority_queue();
+  void destroy_record_priority_queue();
   int common_index_read(uchar * buf, bool have_start_key);
   int common_first_last(uchar * buf);
   int partition_scan_set_up(uchar * buf, bool idx_read_flag);
   int handle_unordered_next(uchar * buf, bool next_same);
   int handle_unordered_scan_next_partition(uchar * buf);
-  uchar *queue_buf(uint part_id)
-    {
-      return (m_ordered_rec_buffer +
-              (part_id * (m_rec_length + PARTITION_BYTES_IN_POS)));
-    }
-  uchar *rec_buf(uint part_id)
-    {
-      return (queue_buf(part_id) +
-              PARTITION_BYTES_IN_POS);
-    }
   int handle_ordered_index_scan(uchar * buf, bool reverse_order);
   int handle_ordered_next(uchar * buf, bool next_same);
   int handle_ordered_prev(uchar * buf);

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2012-08-22 09:40:39 +0000
+++ b/sql/handler.cc	2012-11-06 09:52:55 +0000
@@ -4352,7 +4352,19 @@ int handler::read_range_first(const key_
                 ? HA_ERR_END_OF_FILE
                 : result);
 
-  DBUG_RETURN (compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
+  if (compare_key(end_range) <= 0)
+  {
+    DBUG_RETURN(0);
+  }
+  else
+  {
+    /*
+      The last read row does not fall in the range. So request
+      storage engine to release row lock if possible.
+    */
+    unlock_row();
+    DBUG_RETURN(HA_ERR_END_OF_FILE);
+  }
 }
 
 
@@ -4384,7 +4396,20 @@ int handler::read_range_next()
   result= index_next(table->record[0]);
   if (result)
     DBUG_RETURN(result);
-  DBUG_RETURN(compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
+
+  if (compare_key(end_range) <= 0)
+  {
+    DBUG_RETURN(0);
+  }
+  else
+  {
+    /*
+      The last read row does not fall in the range. So request
+      storage engine to release row lock if possible.
+    */
+    unlock_row();
+    DBUG_RETURN(HA_ERR_END_OF_FILE);
+  }
 }
 
 

=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc	2012-04-05 08:49:38 +0000
+++ b/sql/item_strfunc.cc	2012-11-06 09:52:55 +0000
@@ -3049,23 +3049,21 @@ String *Item_load_file::val_str(String *
 String* Item_func_export_set::val_str(String* str)
 {
   DBUG_ASSERT(fixed == 1);
-  ulonglong the_set = (ulonglong) args[0]->val_int();
-  String yes_buf, *yes;
-  yes = args[1]->val_str(&yes_buf);
-  String no_buf, *no;
-  no = args[2]->val_str(&no_buf);
-  String *sep = NULL, sep_buf ;
+  String yes_buf, no_buf, sep_buf;
+  const ulonglong the_set = (ulonglong) args[0]->val_int();
+  const String *yes= args[1]->val_str(&yes_buf);
+  const String *no= args[2]->val_str(&no_buf);
+  const String *sep= NULL;
 
   uint num_set_values = 64;
-  ulonglong mask = 0x1;
   str->length(0);
   str->set_charset(collation.collation);
 
   /* Check if some argument is a NULL value */
   if (args[0]->null_value || args[1]->null_value || args[2]->null_value)
   {
-    null_value=1;
-    return 0;
+    null_value= true;
+    return NULL;
   }
   /*
     Arg count can only be 3, 4 or 5 here. This is guaranteed from the
@@ -3078,37 +3076,56 @@ String* Item_func_export_set::val_str(St
       num_set_values=64;
     if (args[4]->null_value)
     {
-      null_value=1;
-      return 0;
+      null_value= true;
+      return NULL;
     }
     /* Fall through */
   case 4:
     if (!(sep = args[3]->val_str(&sep_buf)))    // Only true if NULL
     {
-      null_value=1;
-      return 0;
+      null_value= true;
+      return NULL;
     }
     break;
   case 3:
     {
       /* errors is not checked - assume "," can always be converted */
       uint errors;
-      sep_buf.copy(STRING_WITH_LEN(","), &my_charset_bin, collation.collation, &errors);
+      sep_buf.copy(STRING_WITH_LEN(","), &my_charset_bin,
+                   collation.collation, &errors);
       sep = &sep_buf;
     }
     break;
   default:
     DBUG_ASSERT(0); // cannot happen
   }
-  null_value=0;
+  null_value= false;
 
-  for (uint i = 0; i < num_set_values; i++, mask = (mask << 1))
+  const ulong max_allowed_packet= current_thd->variables.max_allowed_packet;
+  const uint num_separators= num_set_values > 0 ? num_set_values - 1 : 0;
+  const ulonglong max_total_length=
+    num_set_values * max(yes->length(), no->length()) +
+    num_separators * sep->length();
+
+  if (unlikely(max_total_length > max_allowed_packet))
+  {
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
+                        ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
+                        func_name(), max_allowed_packet);
+    null_value= true;
+    return NULL;
+  }
+
+  uint ix;
+  ulonglong mask;
+  for (ix= 0, mask=0x1; ix < num_set_values; ++ix, mask = (mask << 1))
   {
     if (the_set & mask)
       str->append(*yes);
     else
       str->append(*no);
-    if (i != num_set_values - 1)
+    if (ix != num_separators)
       str->append(*sep);
   }
   return str;

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2012-05-17 10:12:33 +0000
+++ b/sql/item_subselect.cc	2012-11-06 09:52:55 +0000
@@ -1160,7 +1160,7 @@ Item_in_subselect::single_value_transfor
   }
   else
   {
-    Item *item= (Item*) select_lex->item_list.head();
+    Item *item= (Item*) select_lex->item_list.head()->real_item();
 
     if (select_lex->table_list.elements)
     {

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2012-08-24 08:34:55 +0000
+++ b/sql/log_event.h	2012-11-06 09:52:55 +0000
@@ -2490,7 +2490,7 @@ class User_var_log_event: public Log_eve
   User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
                      char *val_arg, ulong val_len_arg, Item_result type_arg,
                      uint charset_number_arg)
-    :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
+    :Log_event(thd_arg,0,0), name(name_arg), name_len(name_len_arg), val(val_arg),
     val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg),
     deferred(false)
     { is_null= !val; }

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2012-09-26 13:30:08 +0000
+++ b/sql/mysqld.cc	2012-11-06 09:52:55 +0000
@@ -269,6 +269,8 @@ extern "C" sig_handler handle_fatal_sign
 
 /* Constants */
 
+#include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE
+
 const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
 /*
   WARNING: When adding new SQL modes don't forget to update the
@@ -7920,14 +7922,8 @@ static void usage(void)
   if (!default_collation_name)
     default_collation_name= (char*) default_charset_info->name;
   print_version();
-  puts("\
-Copyright (C) 2000-2008 MySQL AB, by Monty and others.\n\
-Copyright (C) 2000, 2011 Oracle.\n\
-Copyright (C) 2009-2011 Monty Program Ab.\n\
-This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
-and you are welcome to modify and redistribute it under the GPL license\n\n\
-Starts the MariaDB database server.\n");
-
+  puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000"));
+  puts("Starts the MariaDB database server.\n");
   printf("Usage: %s [OPTIONS]\n", my_progname);
   if (!opt_verbose)
     puts("\nFor more help options (several pages), use mysqld --verbose --help.");

=== modified file 'sql/share/charsets/Index.xml'
--- a/sql/share/charsets/Index.xml	2006-12-23 19:20:40 +0000
+++ b/sql/share/charsets/Index.xml	2012-07-24 05:27:00 +0000
@@ -3,7 +3,7 @@
 <charsets max-id="99">
 
 <copyright>
- Copyright (C) 2003 MySQL AB
+  Copyright (c) 2003, 2012,  Oracle and/or its affiliates. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by

=== modified file 'sql/spatial.cc'
--- a/sql/spatial.cc	2012-05-17 10:12:33 +0000
+++ b/sql/spatial.cc	2012-11-06 09:52:55 +0000
@@ -525,12 +525,13 @@ uint Gis_line_string::init_from_wkb(cons
   const char *wkb_end;
   Gis_point p;
 
-  if (len < 4)
+  if (len < 4 ||
+      (n_points= wkb_get_uint(wkb, bo)) < 1 ||
+      n_points > max_n_points)
     return 0;
-  n_points= wkb_get_uint(wkb, bo);
   proper_length= 4 + n_points * POINT_DATA_SIZE;
 
-  if (!n_points || len < proper_length || res->reserve(proper_length))
+  if (len < proper_length || res->reserve(proper_length))
     return 0;
 
   res->q_append(n_points);
@@ -1072,9 +1073,9 @@ uint Gis_multi_point::init_from_wkb(cons
   Gis_point p;
   const char *wkb_end;
 
-  if (len < 4)
+  if (len < 4 ||
+      (n_points= wkb_get_uint(wkb, bo)) > max_n_points)
     return 0;
-  n_points= wkb_get_uint(wkb, bo);
   proper_size= 4 + n_points * (WKB_HEADER_SIZE + POINT_DATA_SIZE);
  
   if (len < proper_size || res->reserve(proper_size))

=== modified file 'sql/spatial.h'
--- a/sql/spatial.h	2011-11-21 17:13:14 +0000
+++ b/sql/spatial.h	2012-11-06 09:52:55 +0000
@@ -379,6 +379,10 @@ class Gis_point: public Geometry
 
 class Gis_line_string: public Geometry
 {
+  // Maximum number of points in LineString that can fit into String
+  static const uint32 max_n_points=
+    (uint32) (UINT_MAX32 - WKB_HEADER_SIZE - 4 /* n_points */) /
+    POINT_DATA_SIZE;
 public:
   Gis_line_string() {}                        /* Remove gcc warning */
   virtual ~Gis_line_string() {}               /* Remove gcc warning */
@@ -435,6 +439,10 @@ class Gis_polygon: public Geometry
 
 class Gis_multi_point: public Geometry
 {
+  // Maximum number of points in MultiPoint that can fit into String
+  static const uint32 max_n_points=
+    (uint32) (UINT_MAX32 - WKB_HEADER_SIZE - 4 /* n_points */) /
+    (WKB_HEADER_SIZE + POINT_DATA_SIZE);
 public:
   Gis_multi_point() {}                        /* Remove gcc warning */
   virtual ~Gis_multi_point() {}               /* Remove gcc warning */

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2012-08-22 09:40:39 +0000
+++ b/sql/sql_prepare.cc	2012-11-06 09:52:55 +0000
@@ -786,6 +786,14 @@ static bool insert_params_with_log(Prepa
         param->set_param_func(param, &read_pos, (uint) (data_end - read_pos));
         if (param->state == Item_param::NO_VALUE)
           DBUG_RETURN(1);
+
+        if (param->limit_clause_param && param->item_type != Item::INT_ITEM)
+        {
+          param->set_int(param->val_int(), MY_INT64_NUM_DECIMAL_DIGITS);
+          param->item_type= Item::INT_ITEM;
+          if (!param->unsigned_flag && param->value.integer < 0)
+            DBUG_RETURN(1);
+        }
       }
     }
     /*

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-08-22 09:40:39 +0000
+++ b/sql/sql_select.cc	2012-11-06 09:52:55 +0000
@@ -538,8 +538,6 @@ JOIN::prepare(Item ***rref_pointer_array
   
   if (having)
   {
-    Query_arena backup, *arena;
-    arena= thd->activate_stmt_arena_if_needed(&backup);
     nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
     thd->where="having clause";
     thd->lex->allow_sum_func|= 1 << select_lex_arg->nest_level;
@@ -549,8 +547,6 @@ JOIN::prepare(Item ***rref_pointer_array
                           having->check_cols(1)));
     select_lex->having_fix_field= 0;
     select_lex->having= having;
-    if (arena)
-      thd->restore_active_arena(arena, &backup);
 
     if (having_fix_rc || thd->is_error())
       DBUG_RETURN(-1);                          /* purecov: inspected */
@@ -1467,12 +1463,19 @@ JOIN::optimize()
         DBUG_RETURN(1);
       }
     }
-    
+    /*
+      Calculate a possible 'limit' of table rows for 'GROUP BY': 'need_tmp'
+      implies that there will be more postprocessing so the specified
+      'limit' should not be enforced yet in the call to
+      'test_if_skip_sort_order'.
+    */
+    const ha_rows limit = need_tmp ? HA_POS_ERROR : unit->select_limit_cnt;
+
     if (!(select_options & SELECT_BIG_RESULT) &&
         ((group_list &&
           (!simple_group ||
            !test_if_skip_sort_order(&join_tab[const_tables], group_list,
-                                    unit->select_limit_cnt, 0, 
+                                    limit, 0,
                                     &join_tab[const_tables].table->
                                     keys_in_use_for_group_by))) ||
          select_distinct) &&

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2012-08-24 08:34:55 +0000
+++ b/sql/sql_show.cc	2012-11-06 09:52:55 +0000
@@ -3202,8 +3202,9 @@ fill_schema_table_by_open(THD *thd, bool
   /* Restore original LEX value, statement's arena and THD arena values. */
   lex_end(thd->lex);
 
-  if (i_s_arena.free_list)
-    i_s_arena.free_items();
+  // Free items, before restoring backup_arena below.
+  DBUG_ASSERT(i_s_arena.free_list == NULL);
+  thd->free_items();
 
   /*
     For safety reset list of open temporary tables before closing

=== modified file 'sql/sql_string.h'
--- a/sql/sql_string.h	2012-08-24 08:06:16 +0000
+++ b/sql/sql_string.h	2012-11-06 09:52:55 +0000
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -230,8 +230,12 @@ class String
   }
   bool real_alloc(uint32 arg_length);                   // Empties old string
   bool realloc(uint32 arg_length);
-  inline void shrink(uint32 arg_length)         // Shrink buffer
+
+  // Shrink the buffer, but only if it is allocated on the heap.
+  inline void shrink(uint32 arg_length)
   {
+    if (!is_alloced())
+      return;
     if (arg_length < Alloced_length)
     {
       char *new_ptr;
@@ -247,7 +251,7 @@ class String
       }
     }
   }
-  bool is_alloced() { return alloced; }
+  bool is_alloced() const { return alloced; }
   inline String& operator = (const String &s)
   {
     if (&s != this)

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2012-04-05 08:49:38 +0000
+++ b/storage/federated/ha_federated.cc	2012-11-06 09:52:55 +0000
@@ -1364,7 +1364,7 @@ bool ha_federated::create_where_from_key
           break;
         }
         DBUG_PRINT("info", ("federated HA_READ_AFTER_KEY %d", i));
-        if (store_length >= length) /* end key */
+        if ((store_length >= length) || (i > 0)) /* for all parts of end key*/
         {
           if (emit_key_part_name(&tmp, key_part))
             goto err;

=== modified file 'storage/innobase/btr/btr0pcur.c'
--- a/storage/innobase/btr/btr0pcur.c	2012-03-08 15:10:10 +0000
+++ b/storage/innobase/btr/btr0pcur.c	2012-08-09 06:55:29 +0000
@@ -312,45 +312,40 @@ btr_pcur_restore_position(
         /* Restore the old search mode */
         cursor->search_mode = old_mode;
 
-        if (btr_pcur_is_on_user_rec(cursor, mtr)) {
-                switch (cursor->rel_pos) {
-                case BTR_PCUR_ON:
-                        if (!cmp_dtuple_rec(
-                                    tuple, btr_pcur_get_rec(cursor),
-                                    rec_get_offsets(btr_pcur_get_rec(cursor),
-                                                    index, NULL,
-                                                    ULINT_UNDEFINED, &heap))) {
-
-                                /* We have to store the NEW value for
-                                the modify clock, since the cursor can
-                                now be on a different page! But we can
-                                retain the value of old_rec */
-
-                                cursor->block_when_stored =
-                                        buf_block_align(
-                                                btr_pcur_get_page(cursor));
-                                cursor->modify_clock =
-                                        buf_block_get_modify_clock(
-                                                cursor->block_when_stored);
-                                cursor->old_stored = BTR_PCUR_OLD_STORED;
-
-                                mem_heap_free(heap);
-
-                                return(TRUE);
-                        }
-
-                        break;
-                case BTR_PCUR_BEFORE:
-                        page_cur_move_to_next(btr_pcur_get_page_cur(cursor));
-                        break;
-                case BTR_PCUR_AFTER:
-                        page_cur_move_to_prev(btr_pcur_get_page_cur(cursor));
-                        break;
+        switch (cursor->rel_pos) {
+        case BTR_PCUR_ON:
+                if (btr_pcur_is_on_user_rec(cursor, mtr)
+                    && !cmp_dtuple_rec(
+                            tuple, btr_pcur_get_rec(cursor),
+                            rec_get_offsets(btr_pcur_get_rec(cursor),
+                                            index, NULL,
+                                            ULINT_UNDEFINED, &heap))) {
+
+                        /* We have to store the NEW value for
+                        the modify clock, since the cursor can
+                        now be on a different page! But we can
+                        retain the value of old_rec */
+
+                        cursor->block_when_stored =
+                                buf_block_align(
+                                        btr_pcur_get_page(cursor));
+                        cursor->modify_clock =
+                                buf_block_get_modify_clock(
+                                        cursor->block_when_stored);
+                        cursor->old_stored = BTR_PCUR_OLD_STORED;
+
+                        mem_heap_free(heap);
+
+                        return(TRUE);
+                }
 #ifdef UNIV_DEBUG
-                default:
-                        ut_error;
+                /* fall through */
+        case BTR_PCUR_BEFORE:
+        case BTR_PCUR_AFTER:
+                break;
+        default:
+                ut_error;
 #endif /* UNIV_DEBUG */
-                }
         }
 
         mem_heap_free(heap);

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2012-06-29 11:25:57 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2012-08-28 12:51:01 +0000
@@ -6380,7 +6380,6 @@ ha_innobase::records_in_range(
         void*           heap2;
 
         DBUG_ENTER("records_in_range");
-        DBUG_ASSERT(min_key || max_key);
 
         ut_a(prebuilt->trx == thd_to_trx(ha_thd()));
 

=== modified file 'storage/innodb_plugin/ChangeLog'
--- a/storage/innodb_plugin/ChangeLog	2012-03-21 12:53:09 +0000
+++ b/storage/innodb_plugin/ChangeLog	2012-08-30 18:53:41 +0000
@@ -1,3 +1,32 @@
+2012-08-29      The InnoDB Team
+
+        * btr/btr0btr.c, page/page0cur.c, page/page0page.c:
+        Fix Bug#14554000 CRASH IN PAGE_REC_GET_NTH_CONST(NTH=0)
+        DURING COMPRESSED PAGE SPLIT
+
+2012-08-16      The InnoDB Team
+
+        * btr/btr0cur.c:
+        Fix Bug#12595091 POSSIBLY INVALID ASSERTION IN
+        BTR_CUR_PESSIMISTIC_UPDATE()
+
+2012-08-16      The InnoDB Team
+
+        * btr/btr0btr.c, btr/btr0cur.c:
+        Fix Bug#12845774 OPTIMISTIC INSERT/UPDATE USES WRONG HEURISTICS FOR
+        COMPRESSED PAGE SIZE
+
+2012-08-16      The InnoDB Team
+
+        * btr/btr0cur.c, page/page0page.c:
+        Fix Bug#13523839 ASSERTION FAILURES ON COMPRESSED INNODB TABLES
+
+2012-08-07      The InnoDB Team
+
+        * btr/btr0pcur.c, row/row0merge.c:
+        Fix Bug#14399148 INNODB TABLES UNDER LOAD PRODUCE DUPLICATE COPIES
+        OF ROWS IN QUERIES
+
 2012-03-15      The InnoDB Team
 
         * fil/fil0fil.c, ibuf/ibuf0ibuf.c, include/fil0fil.h,

=== modified file 'storage/innodb_plugin/btr/btr0btr.c'
--- a/storage/innodb_plugin/btr/btr0btr.c	2012-02-28 12:00:00 +0000
+++ b/storage/innodb_plugin/btr/btr0btr.c	2012-08-30 18:53:41 +0000
@@ -1822,6 +1822,7 @@ btr_root_raise_and_insert(
         root = btr_cur_get_page(cursor);
         root_block = btr_cur_get_block(cursor);
         root_page_zip = buf_block_get_page_zip(root_block);
+        ut_ad(page_get_n_recs(root) > 0);
 #ifdef UNIV_ZIP_DEBUG
         ut_a(!root_page_zip || page_zip_validate(root_page_zip, root));
 #endif /* UNIV_ZIP_DEBUG */
@@ -2302,12 +2303,20 @@ btr_insert_on_non_leaf_level_func(
                                     BTR_CONT_MODIFY_TREE,
                                     &cursor, 0, file, line, mtr);
 
-        err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
-                                         | BTR_KEEP_SYS_FLAG
-                                         | BTR_NO_UNDO_LOG_FLAG,
-                                         &cursor, tuple, &rec,
-                                         &dummy_big_rec, 0, NULL, mtr);
-        ut_a(err == DB_SUCCESS);
+        ut_ad(cursor.flag == BTR_CUR_BINARY);
+
+        err = btr_cur_optimistic_insert(
+                BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG
+                | BTR_NO_UNDO_LOG_FLAG, &cursor, tuple, &rec,
+                &dummy_big_rec, 0, NULL, mtr);
+
+        if (err == DB_FAIL) {
+                err = btr_cur_pessimistic_insert(
+                        BTR_NO_LOCKING_FLAG | BTR_KEEP_SYS_FLAG
+                        | BTR_NO_UNDO_LOG_FLAG,
+                        &cursor, tuple, &rec, &dummy_big_rec, 0, NULL, mtr);
+                ut_a(err == DB_SUCCESS);
+        }
 }
 
 /**************************************************************//**
@@ -3232,6 +3241,7 @@ btr_compress(
 
         if (adjust) {
                 nth_rec = page_rec_get_n_recs_before(btr_cur_get_rec(cursor));
+                ut_ad(nth_rec > 0);
         }
 
         /* Decide the page to which we try to merge and which will inherit
@@ -3467,6 +3477,7 @@ btr_compress(
         mem_heap_free(heap);
 
         if (adjust) {
+                ut_ad(nth_rec > 0);
                 btr_cur_position(
                         index,
                         page_rec_get_nth(merge_block->frame, nth_rec),
@@ -3979,8 +3990,22 @@ btr_index_page_validate(
 {
         page_cur_t      cur;
         ibool           ret     = TRUE;
+#ifndef DBUG_OFF
+        ulint           nth     = 1;
+#endif /* !DBUG_OFF */
 
         page_cur_set_before_first(block, &cur);
+
+        /* Directory slot 0 should only contain the infimum record. */
+        DBUG_EXECUTE_IF("check_table_rec_next",
+                        ut_a(page_rec_get_nth_const(
+                                     page_cur_get_page(&cur), 0)
+                             == cur.rec);
+                        ut_a(page_dir_slot_get_n_owned(
+                                     page_dir_get_nth_slot(
+                                             page_cur_get_page(&cur), 0))
+                             == 1););
+
         page_cur_move_to_next(&cur);
 
         for (;;) {
@@ -3994,6 +4019,16 @@ btr_index_page_validate(
                         return(FALSE);
                 }
 
+                /* Verify that page_rec_get_nth_const() is correctly
+                retrieving each record. */
+                DBUG_EXECUTE_IF("check_table_rec_next",
+                                ut_a(cur.rec == page_rec_get_nth_const(
+                                             page_cur_get_page(&cur),
+                                             page_rec_get_n_recs_before(
+                                                     cur.rec)));
+                                ut_a(nth++ == page_rec_get_n_recs_before(
+                                             cur.rec)););
+
                 page_cur_move_to_next(&cur);
         }
 

=== modified file 'storage/innodb_plugin/btr/btr0cur.c'
--- a/storage/innodb_plugin/btr/btr0cur.c	2012-05-10 04:48:31 +0000
+++ b/storage/innodb_plugin/btr/btr0cur.c	2012-08-16 14:45:39 +0000
@@ -1220,7 +1220,12 @@ btr_cur_optimistic_insert(
 
                 if (UNIV_UNLIKELY(reorg)) {
                         ut_a(zip_size);
-                        ut_a(*rec);
+                        /* It's possible for rec to be NULL if the
+                        page is compressed.  This is because a
+                        reorganized page may become incompressible. */
+                        if (!*rec) {
+                                goto fail;
+                        }
                 }
         }
 
@@ -1356,20 +1361,9 @@ btr_cur_pessimistic_insert(
         ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(cursor),
                                 MTR_MEMO_PAGE_X_FIX));
 
-        /* Try first an optimistic insert; reset the cursor flag: we do not
-        assume anything of how it was positioned */
-
         cursor->flag = BTR_CUR_BINARY;
 
-        err = btr_cur_optimistic_insert(flags, cursor, entry, rec,
-                                        big_rec, n_ext, thr, mtr);
-        if (err != DB_FAIL) {
-
-                return(err);
-        }
-
-        /* Retry with a pessimistic insert. Check locks and write to undo log,
-        if specified */
+        /* Check locks and write to undo log, if specified */
 
         err = btr_cur_ins_lock_and_undo(flags, cursor, entry,
                                         thr, mtr, &dummy_inh);
@@ -1973,8 +1967,12 @@ btr_cur_optimistic_update(
                 goto err_exit;
         }
 
-        max_size = old_rec_size
-                + page_get_max_insert_size_after_reorganize(page, 1);
+        /* We do not attempt to reorganize if the page is compressed.
+        This is because the page may fail to compress after reorganization. */
+        max_size = page_zip
+                ? page_get_max_insert_size(page, 1)
+                : (old_rec_size
+                   + page_get_max_insert_size_after_reorganize(page, 1));
 
         if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
                && (max_size >= new_rec_size))
@@ -2328,7 +2326,12 @@ btr_cur_pessimistic_update(
                 err = DB_SUCCESS;
                 goto return_after_reservations;
         } else {
-                ut_a(optim_err != DB_UNDERFLOW);
+                /* If the page is compressed and it initially
+                compresses very well, and there is a subsequent insert
+                of a badly-compressing record, it is possible for
+                btr_cur_optimistic_update() to return DB_UNDERFLOW and
+                btr_cur_insert_if_possible() to return FALSE. */
+                ut_a(page_zip || optim_err != DB_UNDERFLOW);
 
                 /* Out of space: reset the free bits. */
                 if (!dict_index_is_clust(index)
@@ -2356,8 +2359,10 @@ btr_cur_pessimistic_update(
         record on its page? */
         was_first = page_cur_is_before_first(page_cursor);
 
-        /* The first parameter means that no lock checking and undo logging
-        is made in the insert */
+        /* Lock checks and undo logging were already performed by
+        btr_cur_upd_lock_and_undo(). We do not try
+        btr_cur_optimistic_insert() because
+        btr_cur_insert_if_possible() already failed above. */
 
         err = btr_cur_pessimistic_insert(BTR_NO_UNDO_LOG_FLAG
                                          | BTR_NO_LOCKING_FLAG

=== modified file 'storage/innodb_plugin/btr/btr0pcur.c'
--- a/storage/innodb_plugin/btr/btr0pcur.c	2012-03-08 15:10:10 +0000
+++ b/storage/innodb_plugin/btr/btr0pcur.c	2012-08-09 06:55:29 +0000
@@ -336,44 +336,39 @@ btr_pcur_restore_position_func(
         /* Restore the old search mode */
         cursor->search_mode = old_mode;
 
-        if (btr_pcur_is_on_user_rec(cursor)) {
-                switch (cursor->rel_pos) {
-                case BTR_PCUR_ON:
-                        if (!cmp_dtuple_rec(
-                                    tuple, btr_pcur_get_rec(cursor),
-                                    rec_get_offsets(btr_pcur_get_rec(cursor),
-                                                    index, NULL,
-                                                    ULINT_UNDEFINED, &heap))) {
-
-                                /* We have to store the NEW value for
-                                the modify clock, since the cursor can
-                                now be on a different page! But we can
-                                retain the value of old_rec */
-
-                                cursor->block_when_stored =
-                                        btr_pcur_get_block(cursor);
-                                cursor->modify_clock =
-                                        buf_block_get_modify_clock(
-                                                cursor->block_when_stored);
-                                cursor->old_stored = BTR_PCUR_OLD_STORED;
-
-                                mem_heap_free(heap);
-
-                                return(TRUE);
-                        }
-
-                        break;
-                case BTR_PCUR_BEFORE:
-                        page_cur_move_to_next(btr_pcur_get_page_cur(cursor));
-                        break;
-                case BTR_PCUR_AFTER:
-                        page_cur_move_to_prev(btr_pcur_get_page_cur(cursor));
-                        break;
+        switch (cursor->rel_pos) {
+        case BTR_PCUR_ON:
+                if (btr_pcur_is_on_user_rec(cursor)
+                    && !cmp_dtuple_rec(
+                            tuple, btr_pcur_get_rec(cursor),
+                            rec_get_offsets(btr_pcur_get_rec(cursor),
+                                            index, NULL,
+                                            ULINT_UNDEFINED, &heap))) {
+
+                        /* We have to store the NEW value for
+                        the modify clock, since the cursor can
+                        now be on a different page! But we can
+                        retain the value of old_rec */
+
+                        cursor->block_when_stored =
+                                btr_pcur_get_block(cursor);
+                        cursor->modify_clock =
+                                buf_block_get_modify_clock(
+                                        cursor->block_when_stored);
+                        cursor->old_stored = BTR_PCUR_OLD_STORED;
+
+                        mem_heap_free(heap);
+
+                        return(TRUE);
+                }
 #ifdef UNIV_DEBUG
-                default:
-                        ut_error;
+                /* fall through */
+        case BTR_PCUR_BEFORE:
+        case BTR_PCUR_AFTER:
+                break;
+        default:
+                ut_error;
 #endif /* UNIV_DEBUG */
-                }
         }
 
         mem_heap_free(heap);

=== modified file 'storage/innodb_plugin/buf/buf0buf.c'
--- a/storage/innodb_plugin/buf/buf0buf.c	2012-01-16 07:55:12 +0000
+++ b/storage/innodb_plugin/buf/buf0buf.c	2012-07-25 08:21:39 +0000
@@ -269,14 +269,6 @@ read-ahead or flush occurs */
 UNIV_INTERN ibool               buf_debug_prints = FALSE;
 #endif /* UNIV_DEBUG */
 
-/** A chunk of buffers.  The buffer pool is allocated in chunks. */
-struct buf_chunk_struct{
-        ulint           mem_size;       /*!< allocated size of the chunk */
-        ulint           size;           /*!< size of frames[] and blocks[] */
-        void*           mem;            /*!< pointer to the memory area which
-                                        was allocated for the frames */
-        buf_block_t*    blocks;         /*!< array of buffer control blocks */
-};
 #endif /* !UNIV_HOTBACKUP */
 
 /********************************************************************//**
@@ -3623,6 +3615,133 @@ buf_get_free_list_len(void)
 
         return(len);
 }
+
+/*******************************************************************//**
+Collect buffer pool stats information for a buffer pool. Also
+record aggregated stats if there are more than one buffer pool
+in the server */
+UNIV_INTERN
+void
+buf_stats_get_pool_info(
+/*====================*/
+        buf_pool_info_t*        pool_info)      /*!< in/out: buffer pool info
+                                                to fill */
+{
+        time_t                  current_time;
+        double                  time_elapsed;
+
+        buf_pool_mutex_enter();
+
+        pool_info->pool_size = buf_pool->curr_size;
+
+        pool_info->lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
+
+        pool_info->old_lru_len = buf_pool->LRU_old_len;
+
+        pool_info->free_list_len = UT_LIST_GET_LEN(buf_pool->free);
+
+        pool_info->flush_list_len = UT_LIST_GET_LEN(buf_pool->flush_list);
+
+        pool_info->n_pend_unzip = UT_LIST_GET_LEN(buf_pool->unzip_LRU);
+
+        pool_info->n_pend_reads = buf_pool->n_pend_reads;
+
+        pool_info->n_pending_flush_lru =
+                 (buf_pool->n_flush[BUF_FLUSH_LRU]
+                  + buf_pool->init_flush[BUF_FLUSH_LRU]);
+
+        pool_info->n_pending_flush_list =
+                 (buf_pool->n_flush[BUF_FLUSH_LIST]
+                  + buf_pool->init_flush[BUF_FLUSH_LIST]);
+
+        pool_info->n_pending_flush_single_page =
+                 (buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]
+                  + buf_pool->init_flush[BUF_FLUSH_SINGLE_PAGE]);
+
+        current_time = time(NULL);
+        time_elapsed = 0.001 + difftime(current_time,
+                                        buf_pool->last_printout_time);
+
+        pool_info->n_pages_made_young = buf_pool->stat.n_pages_made_young;
+
+        pool_info->n_pages_not_made_young =
+                buf_pool->stat.n_pages_not_made_young;
+
+        pool_info->n_pages_read = buf_pool->stat.n_pages_read;
+
+        pool_info->n_pages_created = buf_pool->stat.n_pages_created;
+
+        pool_info->n_pages_written = buf_pool->stat.n_pages_written;
+
+        pool_info->n_page_gets = buf_pool->stat.n_page_gets;
+
+        pool_info->n_ra_pages_read_rnd = buf_pool->stat.n_ra_pages_read_rnd;
+        pool_info->n_ra_pages_read = buf_pool->stat.n_ra_pages_read;
+
+        pool_info->n_ra_pages_evicted = buf_pool->stat.n_ra_pages_evicted;
+
+        pool_info->page_made_young_rate =
+                 (buf_pool->stat.n_pages_made_young
+                  - buf_pool->old_stat.n_pages_made_young) / time_elapsed;
+
+        pool_info->page_not_made_young_rate =
+                 (buf_pool->stat.n_pages_not_made_young
+                  - buf_pool->old_stat.n_pages_not_made_young) / time_elapsed;
+
+        pool_info->pages_read_rate =
+                (buf_pool->stat.n_pages_read
+                  - buf_pool->old_stat.n_pages_read) / time_elapsed;
+
+        pool_info->pages_created_rate =
+                (buf_pool->stat.n_pages_created
+                 - buf_pool->old_stat.n_pages_created) / time_elapsed;
+
+        pool_info->pages_written_rate =
+                (buf_pool->stat.n_pages_written
+                 - buf_pool->old_stat.n_pages_written) / time_elapsed;
+
+        pool_info->n_page_get_delta = buf_pool->stat.n_page_gets
+                                      - buf_pool->old_stat.n_page_gets;
+
+        if (pool_info->n_page_get_delta) {
+                pool_info->page_read_delta = buf_pool->stat.n_pages_read
+                                             - buf_pool->old_stat.n_pages_read;
+
+                pool_info->young_making_delta =
+                        buf_pool->stat.n_pages_made_young
+                        - buf_pool->old_stat.n_pages_made_young;
+
+                pool_info->not_young_making_delta =
+                        buf_pool->stat.n_pages_not_made_young
+                        - buf_pool->old_stat.n_pages_not_made_young;
+        }
+        pool_info->pages_readahead_rnd_rate =
+                 (buf_pool->stat.n_ra_pages_read_rnd
+                  - buf_pool->old_stat.n_ra_pages_read_rnd) / time_elapsed;
+
+
+        pool_info->pages_readahead_rate =
+                 (buf_pool->stat.n_ra_pages_read
+                  - buf_pool->old_stat.n_ra_pages_read) / time_elapsed;
+
+        pool_info->pages_evicted_rate =
+                (buf_pool->stat.n_ra_pages_evicted
+                 - buf_pool->old_stat.n_ra_pages_evicted) / time_elapsed;
+
+        pool_info->unzip_lru_len = UT_LIST_GET_LEN(buf_pool->unzip_LRU);
+
+        pool_info->io_sum = buf_LRU_stat_sum.io;
+
+        pool_info->io_cur = buf_LRU_stat_cur.io;
+
+        pool_info->unzip_sum = buf_LRU_stat_sum.unzip;
+
+        pool_info->unzip_cur = buf_LRU_stat_cur.unzip;
+
+        buf_refresh_io_stats();
+        buf_pool_mutex_exit();
+}
+
 #else /* !UNIV_HOTBACKUP */
 /********************************************************************//**
 Inits a page to the buffer buf_pool, for use in ibbackup --restore. */

=== modified file 'storage/innodb_plugin/handler/ha_innodb.cc'
--- a/storage/innodb_plugin/handler/ha_innodb.cc	2012-08-22 09:40:39 +0000
+++ b/storage/innodb_plugin/handler/ha_innodb.cc	2012-11-06 09:52:55 +0000
@@ -877,11 +877,23 @@ convert_error_code_to_mysql(
         case DB_TABLE_NOT_FOUND:
                 return(HA_ERR_NO_SUCH_TABLE);
 
-        case DB_TOO_BIG_RECORD:
-                my_error(ER_TOO_BIG_ROWSIZE, MYF(0),
-                         page_get_free_space_of_empty(flags
-                                                      & DICT_TF_COMPACT) / 2);
+        case DB_TOO_BIG_RECORD: {
+                /* If prefix is true then a 768-byte prefix is stored
+                locally for BLOB fields. Refer to dict_table_get_format() */
+                bool prefix = ((flags & DICT_TF_FORMAT_MASK)
+                               >> DICT_TF_FORMAT_SHIFT) < UNIV_FORMAT_B;
+                my_printf_error(ER_TOO_BIG_ROWSIZE,
+                        "Row size too large (> %lu). Changing some columns "
+                        "to TEXT or BLOB %smay help. In current row "
+                        "format, BLOB prefix of %d bytes is stored inline.",
+                        MYF(0),
+                        page_get_free_space_of_empty(flags &
+                                DICT_TF_COMPACT) / 2,
+                        prefix ? "or using ROW_FORMAT=DYNAMIC "
+                        "or ROW_FORMAT=COMPRESSED ": "",
+                        prefix ? DICT_MAX_INDEX_COL_LEN : 0);
                 return(HA_ERR_TO_BIG_ROW);
+        }
 
         case DB_NO_SAVEPOINT:
                 return(HA_ERR_NO_SAVEPOINT);
@@ -7439,7 +7451,6 @@ ha_innobase::records_in_range(
         mem_heap_t*     heap;
 
         DBUG_ENTER("records_in_range");
-        DBUG_ASSERT(min_key || max_key);
 
         ut_a(prebuilt->trx == thd_to_trx(ha_thd()));
 
@@ -11342,7 +11353,10 @@ i_s_innodb_lock_waits,
 i_s_innodb_cmp,
 i_s_innodb_cmp_reset,
 i_s_innodb_cmpmem,
-i_s_innodb_cmpmem_reset
+i_s_innodb_cmpmem_reset,
+i_s_innodb_buffer_page,
+i_s_innodb_buffer_page_lru,
+i_s_innodb_buffer_stats
 mysql_declare_plugin_end;
 
 /** @brief Initialize the default value of innodb_commit_concurrency.

=== modified file 'storage/innodb_plugin/handler/i_s.cc'
--- a/storage/innodb_plugin/handler/i_s.cc	2011-01-10 13:08:33 +0000
+++ b/storage/innodb_plugin/handler/i_s.cc	2012-07-25 08:21:39 +0000
@@ -41,10 +41,90 @@ extern "C" {
 #include "buf0buf.h" /* for buf_pool and PAGE_ZIP_MIN_SIZE */
 #include "ha_prototypes.h" /* for innobase_convert_name() */
 #include "srv0start.h" /* for srv_was_started */
+#include "btr0btr.h"
+#include "log0log.h"
 }
 
 static const char plugin_author[] = "Innobase Oy";
 
+/** structure associates a name string with a file page type and/or buffer
+page state. */
+struct buffer_page_desc_str_struct{
+        const char*     type_str;       /*!< String explain the page
+                                        type/state */
+        ulint           type_value;     /*!< Page type or page state */
+};
+
+typedef struct buffer_page_desc_str_struct      buf_page_desc_str_t;
+
+/** Any states greater than FIL_PAGE_TYPE_LAST would be treated as unknown. */
+#define I_S_PAGE_TYPE_UNKNOWN           (FIL_PAGE_TYPE_LAST + 1)
+
+/** We also define I_S_PAGE_TYPE_INDEX as the Index Page's position
+in i_s_page_type[] array */
+#define I_S_PAGE_TYPE_INDEX             1
+
+/** Name string for File Page Types */
+static buf_page_desc_str_t      i_s_page_type[] = {
+        {"ALLOCATED", FIL_PAGE_TYPE_ALLOCATED},
+        {"INDEX", FIL_PAGE_INDEX},
+        {"UNDO_LOG", FIL_PAGE_UNDO_LOG},
+        {"INODE", FIL_PAGE_INODE},
+        {"IBUF_FREE_LIST", FIL_PAGE_IBUF_FREE_LIST},
+        {"IBUF_BITMAP", FIL_PAGE_IBUF_BITMAP},
+        {"SYSTEM", FIL_PAGE_TYPE_SYS},
+        {"TRX_SYSTEM", FIL_PAGE_TYPE_TRX_SYS},
+        {"FILE_SPACE_HEADER", FIL_PAGE_TYPE_FSP_HDR},
+        {"EXTENT_DESCRIPTOR", FIL_PAGE_TYPE_XDES},
+        {"BLOB", FIL_PAGE_TYPE_BLOB},
+        {"COMPRESSED_BLOB", FIL_PAGE_TYPE_ZBLOB},
+        {"COMPRESSED_BLOB2", FIL_PAGE_TYPE_ZBLOB2},
+        {"UNKNOWN", I_S_PAGE_TYPE_UNKNOWN}
+};
+
+/* Check if we can hold all page type in a 4 bit value */
+#if I_S_PAGE_TYPE_UNKNOWN > 1<<4
+# error "i_s_page_type[] is too large"
+#endif
+
+/** This structure defines information we will fetch from pages
+currently cached in the buffer pool. It will be used to populate
+table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE */
+struct buffer_page_info_struct{
+        ulint           block_id;       /*!< Buffer Pool block ID */
+        unsigned        space_id:32;    /*!< Tablespace ID */
+        unsigned        page_num:32;    /*!< Page number/offset */
+        unsigned        access_time:32; /*!< Time of first access */
+        unsigned        flush_type:2;   /*!< Flush type */
+        unsigned        io_fix:2;       /*!< type of pending I/O operation */
+        unsigned        fix_count:19;   /*!< Count of how manyfold this block
+                                        is bufferfixed */
+        unsigned        hashed:1;       /*!< Whether hash index has been
+                                        built on this page */
+        unsigned        is_old:1;       /*!< TRUE if the block is in the old
+                                        blocks in buf_pool->LRU_old */
+        unsigned        freed_page_clock:31; /*!< the value of
+                                        buf_pool->freed_page_clock */
+        unsigned        zip_ssize:PAGE_ZIP_SSIZE_BITS;
+                                        /*!< Compressed page size */
+        unsigned        page_state:BUF_PAGE_STATE_BITS; /*!< Page state */
+        unsigned        page_type:4;    /*!< Page type */
+        unsigned        num_recs:UNIV_PAGE_SIZE_SHIFT-2;
+                                        /*!< Number of records on Page */
+        unsigned        data_size:UNIV_PAGE_SIZE_SHIFT;
+                                        /*!< Sum of the sizes of the records */
+        lsn_t           newest_mod;     /*!< Log sequence number of
+                                        the youngest modification */
+        lsn_t           oldest_mod;     /*!< Log sequence number of
+                                        the oldest modification */
+        dulint          index_id;       /*!< Index ID if a index page */
+};
+
+typedef struct buffer_page_info_struct  buf_page_info_t;
+
+/** maximum number of buffer page info we would cache. */
+#define MAX_BUF_INFO_CACHED             10000
+
 #define OK(expr)                \
         if ((expr) != 0) {      \
                 DBUG_RETURN(1); \
@@ -1576,3 +1656,1675 @@ i_s_common_deinit(
 
         DBUG_RETURN(0);
 }
+
+
+/* Fields of the dynamic table INNODB_BUFFER_POOL_STATS. */
+static ST_FIELD_INFO    i_s_innodb_buffer_stats_fields_info[] =
+{
+#define IDX_BUF_STATS_POOL_SIZE         0
+        {STRUCT_FLD(field_name,         "POOL_SIZE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_FREE_BUFFERS      1
+        {STRUCT_FLD(field_name,         "FREE_BUFFERS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_LRU_LEN           2
+        {STRUCT_FLD(field_name,         "DATABASE_PAGES"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_OLD_LRU_LEN       3
+        {STRUCT_FLD(field_name,         "OLD_DATABASE_PAGES"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_FLUSH_LIST_LEN    4
+        {STRUCT_FLD(field_name,         "MODIFIED_DATABASE_PAGES"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PENDING_ZIP       5
+        {STRUCT_FLD(field_name,         "PENDING_DECOMPRESS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PENDING_READ      6
+        {STRUCT_FLD(field_name,         "PENDING_READS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_FLUSH_LRU         7
+        {STRUCT_FLD(field_name,         "PENDING_FLUSH_LRU"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_FLUSH_LIST        8
+        {STRUCT_FLD(field_name,         "PENDING_FLUSH_LIST"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_YOUNG        9
+        {STRUCT_FLD(field_name,         "PAGES_MADE_YOUNG"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_NOT_YOUNG    10
+        {STRUCT_FLD(field_name,         "PAGES_NOT_MADE_YOUNG"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_YOUNG_RATE   11
+        {STRUCT_FLD(field_name,         "PAGES_MADE_YOUNG_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_NOT_YOUNG_RATE 12
+        {STRUCT_FLD(field_name,         "PAGES_MADE_NOT_YOUNG_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_READ         13
+        {STRUCT_FLD(field_name,         "NUMBER_PAGES_READ"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_CREATED      14
+        {STRUCT_FLD(field_name,         "NUMBER_PAGES_CREATED"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_WRITTEN      15
+        {STRUCT_FLD(field_name,         "NUMBER_PAGES_WRITTEN"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_READ_RATE    16
+        {STRUCT_FLD(field_name,         "PAGES_READ_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_CREATE_RATE  17
+        {STRUCT_FLD(field_name,         "PAGES_CREATE_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_PAGE_WRITTEN_RATE 18
+        {STRUCT_FLD(field_name,         "PAGES_WRITTEN_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_GET               19
+        {STRUCT_FLD(field_name,         "NUMBER_PAGES_GET"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_HIT_RATE          20
+        {STRUCT_FLD(field_name,         "HIT_RATE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_MADE_YOUNG_PCT    21
+        {STRUCT_FLD(field_name,         "YOUNG_MAKE_PER_THOUSAND_GETS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_NOT_MADE_YOUNG_PCT 22
+        {STRUCT_FLD(field_name,         "NOT_YOUNG_MAKE_PER_THOUSAND_GETS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_READ_AHREAD       23
+        {STRUCT_FLD(field_name,         "NUMBER_PAGES_READ_AHEAD"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_READ_AHEAD_EVICTED 24
+        {STRUCT_FLD(field_name,         "NUMBER_READ_AHEAD_EVICTED"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_READ_AHEAD_RATE   25
+        {STRUCT_FLD(field_name,         "READ_AHEAD_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_READ_AHEAD_EVICT_RATE 26
+        {STRUCT_FLD(field_name,         "READ_AHEAD_EVICTED_RATE"),
+         STRUCT_FLD(field_length,       MAX_FLOAT_STR_LENGTH),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_FLOAT),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        0),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_LRU_IO_SUM        27
+        {STRUCT_FLD(field_name,         "LRU_IO_TOTAL"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_LRU_IO_CUR        28
+        {STRUCT_FLD(field_name,         "LRU_IO_CURRENT"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_UNZIP_SUM         29
+        {STRUCT_FLD(field_name,         "UNCOMPRESS_TOTAL"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_STATS_UNZIP_CUR         30
+        {STRUCT_FLD(field_name,         "UNCOMPRESS_CURRENT"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+        END_OF_ST_FIELD_INFO
+};
+
+/*******************************************************************//**
+Fill Information Schema table INNODB_BUFFER_POOL_STATS for a particular
+buffer pool
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_stats_fill(
+/*==================*/
+        THD*                    thd,            /*!< in: thread */
+        TABLE_LIST*             tables,         /*!< in/out: tables to fill */
+        const buf_pool_info_t*  info)           /*!< in: buffer pool
+                                                information */
+{
+        TABLE*                  table;
+        Field**                 fields;
+
+        DBUG_ENTER("i_s_innodb_stats_fill");
+
+        table = tables->table;
+
+        fields = table->field;
+
+        OK(fields[IDX_BUF_STATS_POOL_SIZE]->store(info->pool_size));
+
+        OK(fields[IDX_BUF_STATS_LRU_LEN]->store(info->lru_len));
+
+        OK(fields[IDX_BUF_STATS_OLD_LRU_LEN]->store(info->old_lru_len));
+
+        OK(fields[IDX_BUF_STATS_FREE_BUFFERS]->store(info->free_list_len));
+
+        OK(fields[IDX_BUF_STATS_FLUSH_LIST_LEN]->store(
+                info->flush_list_len));
+
+        OK(fields[IDX_BUF_STATS_PENDING_ZIP]->store(info->n_pend_unzip));
+
+        OK(fields[IDX_BUF_STATS_PENDING_READ]->store(info->n_pend_reads));
+
+        OK(fields[IDX_BUF_STATS_FLUSH_LRU]->store(info->n_pending_flush_lru));
+
+        OK(fields[IDX_BUF_STATS_FLUSH_LIST]->store(info->n_pending_flush_list));
+
+        OK(fields[IDX_BUF_STATS_PAGE_YOUNG]->store(info->n_pages_made_young));
+
+        OK(fields[IDX_BUF_STATS_PAGE_NOT_YOUNG]->store(
+                info->n_pages_not_made_young));
+
+        OK(fields[IDX_BUF_STATS_PAGE_YOUNG_RATE]->store(
+                info->page_made_young_rate));
+
+        OK(fields[IDX_BUF_STATS_PAGE_NOT_YOUNG_RATE]->store(
+                info->page_not_made_young_rate));
+
+        OK(fields[IDX_BUF_STATS_PAGE_READ]->store(info->n_pages_read));
+
+        OK(fields[IDX_BUF_STATS_PAGE_CREATED]->store(info->n_pages_created));
+
+        OK(fields[IDX_BUF_STATS_PAGE_WRITTEN]->store(info->n_pages_written));
+
+        OK(fields[IDX_BUF_STATS_GET]->store(info->n_page_gets));
+
+        OK(fields[IDX_BUF_STATS_PAGE_READ_RATE]->store(info->pages_read_rate));
+
+        OK(fields[IDX_BUF_STATS_PAGE_CREATE_RATE]->store(info->pages_created_rate));
+
+        OK(fields[IDX_BUF_STATS_PAGE_WRITTEN_RATE]->store(info->pages_written_rate));
+
+        if (info->n_page_get_delta) {
+                OK(fields[IDX_BUF_STATS_HIT_RATE]->store(
+                        1000 - (1000 * info->page_read_delta
+                                / info->n_page_get_delta)));
+
+                OK(fields[IDX_BUF_STATS_MADE_YOUNG_PCT]->store(
+                        1000 * info->young_making_delta
+                        / info->n_page_get_delta));
+
+                OK(fields[IDX_BUF_STATS_NOT_MADE_YOUNG_PCT]->store(
+                        1000 * info->not_young_making_delta
+                        / info->n_page_get_delta));
+        } else {
+                OK(fields[IDX_BUF_STATS_HIT_RATE]->store(0));
+                OK(fields[IDX_BUF_STATS_MADE_YOUNG_PCT]->store(0));
+                OK(fields[IDX_BUF_STATS_NOT_MADE_YOUNG_PCT]->store(0));
+        }
+
+        OK(fields[IDX_BUF_STATS_READ_AHREAD]->store(info->n_ra_pages_read));
+
+        OK(fields[IDX_BUF_STATS_READ_AHEAD_EVICTED]->store(
+                info->n_ra_pages_evicted));
+
+        OK(fields[IDX_BUF_STATS_READ_AHEAD_RATE]->store(
+                info->pages_readahead_rate));
+
+        OK(fields[IDX_BUF_STATS_READ_AHEAD_EVICT_RATE]->store(
+                info->pages_evicted_rate));
+
+        OK(fields[IDX_BUF_STATS_LRU_IO_SUM]->store(info->io_sum));
+
+        OK(fields[IDX_BUF_STATS_LRU_IO_CUR]->store(info->io_cur));
+
+        OK(fields[IDX_BUF_STATS_UNZIP_SUM]->store(info->unzip_sum));
+
+        OK(fields[IDX_BUF_STATS_UNZIP_CUR]->store( info->unzip_cur));
+
+        DBUG_RETURN(schema_table_store_record(thd, table));
+}
+
+/*******************************************************************//**
+This is the function that loops through each buffer pool and fetch buffer
+pool stats to information schema  table: I_S_INNODB_BUFFER_POOL_STATS
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buffer_stats_fill_table(
+/*===============================*/
+        THD*            thd,            /*!< in: thread */
+        TABLE_LIST*     tables,         /*!< in/out: tables to fill */
+        Item*           )               /*!< in: condition (ignored) */
+{
+        int                     status  = 0;
+        buf_pool_info_t*        pool_info;
+
+        DBUG_ENTER("i_s_innodb_buffer_fill_general");
+
+        /* Only allow the PROCESS privilege holder to access the stats */
+        if (check_global_access(thd, PROCESS_ACL)) {
+                DBUG_RETURN(0);
+        }
+
+        pool_info = (buf_pool_info_t*) mem_zalloc(sizeof *pool_info);
+
+        /* Fetch individual buffer pool info */
+        buf_stats_get_pool_info(pool_info);
+        status = i_s_innodb_stats_fill(thd, tables, pool_info);
+
+        mem_free(pool_info);
+
+        DBUG_RETURN(status);
+}
+
+/*******************************************************************//**
+Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS.
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buffer_pool_stats_init(
+/*==============================*/
+        void*   p)      /*!< in/out: table schema object */
+{
+        ST_SCHEMA_TABLE*        schema;
+
+        DBUG_ENTER("i_s_innodb_buffer_pool_stats_init");
+
+        schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p);
+
+        schema->fields_info = i_s_innodb_buffer_stats_fields_info;
+        schema->fill_table = i_s_innodb_buffer_stats_fill_table;
+
+        DBUG_RETURN(0);
+}
+
+UNIV_INTERN struct st_mysql_plugin      i_s_innodb_buffer_stats =
+{
+        /* the plugin type (a MYSQL_XXX_PLUGIN value) */
+        /* int */
+        STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
+
+        /* pointer to type-specific plugin descriptor */
+        /* void* */
+        STRUCT_FLD(info, &i_s_info),
+
+        /* plugin name */
+        /* const char* */
+        STRUCT_FLD(name, "INNODB_BUFFER_POOL_STATS"),
+
+        /* plugin author (for SHOW PLUGINS) */
+        /* const char* */
+        STRUCT_FLD(author, plugin_author),
+
+        /* general descriptive text (for SHOW PLUGINS) */
+        /* const char* */
+        STRUCT_FLD(descr, "InnoDB Buffer Pool Statistics Information "),
+
+        /* the plugin license (PLUGIN_LICENSE_XXX) */
+        /* int */
+        STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
+
+        /* the function to invoke when plugin is loaded */
+        /* int (*)(void*); */
+        STRUCT_FLD(init, i_s_innodb_buffer_pool_stats_init),
+
+        /* the function to invoke when plugin is unloaded */
+        /* int (*)(void*); */
+        STRUCT_FLD(deinit, i_s_common_deinit),
+
+        /* plugin version (for SHOW PLUGINS) */
+        /* unsigned int */
+        STRUCT_FLD(version, INNODB_VERSION_SHORT),
+
+        /* struct st_mysql_show_var* */
+        STRUCT_FLD(status_vars, NULL),
+
+        /* struct st_mysql_sys_var** */
+        STRUCT_FLD(system_vars, NULL),
+
+        /* reserved for dependency checking */
+        /* void* */
+        STRUCT_FLD(__reserved1, NULL),
+};
+
+/* Fields of the dynamic table INNODB_BUFFER_POOL_PAGE. */
+static ST_FIELD_INFO    i_s_innodb_buffer_page_fields_info[] =
+{
+#define IDX_BUFFER_BLOCK_ID             0
+        {STRUCT_FLD(field_name,         "BLOCK_ID"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_SPACE           1
+        {STRUCT_FLD(field_name,         "SPACE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_NUM             2
+        {STRUCT_FLD(field_name,         "PAGE_NUMBER"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_TYPE            3
+        {STRUCT_FLD(field_name,         "PAGE_TYPE"),
+         STRUCT_FLD(field_length,       64),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_FLUSH_TYPE      4
+        {STRUCT_FLD(field_name,         "FLUSH_TYPE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_FIX_COUNT       5
+        {STRUCT_FLD(field_name,         "FIX_COUNT"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_HASHED          6
+        {STRUCT_FLD(field_name,         "IS_HASHED"),
+         STRUCT_FLD(field_length,       3),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_NEWEST_MOD      7
+        {STRUCT_FLD(field_name,         "NEWEST_MODIFICATION"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_OLDEST_MOD      8
+        {STRUCT_FLD(field_name,         "OLDEST_MODIFICATION"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_ACCESS_TIME      9
+        {STRUCT_FLD(field_name,         "ACCESS_TIME"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_TABLE_NAME      10
+        {STRUCT_FLD(field_name,         "TABLE_NAME"),
+         STRUCT_FLD(field_length,       1024),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_INDEX_NAME      11
+        {STRUCT_FLD(field_name,         "INDEX_NAME"),
+         STRUCT_FLD(field_length,       1024),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_NUM_RECS        12
+        {STRUCT_FLD(field_name,         "NUMBER_RECORDS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_DATA_SIZE       13
+        {STRUCT_FLD(field_name,         "DATA_SIZE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_ZIP_SIZE        14
+        {STRUCT_FLD(field_name,         "COMPRESSED_SIZE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_STATE           15
+        {STRUCT_FLD(field_name,         "PAGE_STATE"),
+         STRUCT_FLD(field_length,       64),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_IO_FIX          16
+        {STRUCT_FLD(field_name,         "IO_FIX"),
+         STRUCT_FLD(field_length,       64),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_IS_OLD          17
+        {STRUCT_FLD(field_name,         "IS_OLD"),
+         STRUCT_FLD(field_length,       3),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUFFER_PAGE_FREE_CLOCK      18
+        {STRUCT_FLD(field_name,         "FREE_PAGE_CLOCK"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+        END_OF_ST_FIELD_INFO
+};
+
+/*******************************************************************//**
+Fill Information Schema table INNODB_BUFFER_PAGE with information
+cached in the buf_page_info_t array
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buffer_page_fill(
+/*========================*/
+        THD*                    thd,            /*!< in: thread */
+        TABLE_LIST*             tables,         /*!< in/out: tables to fill */
+        const buf_page_info_t*  info_array,     /*!< in: array cached page
+                                                info */
+        ulint                   num_page,       /*!< in: number of page info
+                                                 cached */
+        mem_heap_t*             heap)           /*!< in: temp heap memory */
+{
+        TABLE*                  table;
+        Field**                 fields;
+
+        DBUG_ENTER("i_s_innodb_buffer_page_fill");
+
+        table = tables->table;
+
+        fields = table->field;
+
+        /* Iterate through the cached array and fill the I_S table rows */
+        for (ulint i = 0; i < num_page; i++) {
+                const buf_page_info_t*  page_info;
+                const char*             table_name;
+                const char*             index_name;
+                const char*             state_str;
+                enum buf_page_state     state;
+
+                page_info = info_array + i;
+
+                table_name = NULL;
+                index_name = NULL;
+                state_str = NULL;
+
+                OK(fields[IDX_BUFFER_BLOCK_ID]->store(page_info->block_id));
+
+                OK(fields[IDX_BUFFER_PAGE_SPACE]->store(page_info->space_id));
+
+                OK(fields[IDX_BUFFER_PAGE_NUM]->store(page_info->page_num));
+
+                OK(field_store_string(
+                        fields[IDX_BUFFER_PAGE_TYPE],
+                        i_s_page_type[page_info->page_type].type_str));
+
+                OK(fields[IDX_BUFFER_PAGE_FLUSH_TYPE]->store(
+                        page_info->flush_type));
+
+                OK(fields[IDX_BUFFER_PAGE_FIX_COUNT]->store(
+                        page_info->fix_count));
+
+                if (page_info->hashed) {
+                        OK(field_store_string(
+                                fields[IDX_BUFFER_PAGE_HASHED], "YES"));
+                } else {
+                        OK(field_store_string(
+                                fields[IDX_BUFFER_PAGE_HASHED], "NO"));
+                }
+
+                OK(fields[IDX_BUFFER_PAGE_NEWEST_MOD]->store(
+                        (longlong) page_info->newest_mod, true));
+
+                OK(fields[IDX_BUFFER_PAGE_OLDEST_MOD]->store(
+                        (longlong) page_info->oldest_mod, true));
+
+                OK(fields[IDX_BUFFER_PAGE_ACCESS_TIME]->store(
+                        page_info->access_time));
+
+                /* If this is an index page, fetch the index name
+                and table name */
+                if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
+                        const dict_index_t*     index;
+
+                        mutex_enter(&dict_sys->mutex);
+                        index = dict_index_get_if_in_cache_low(
+                                page_info->index_id);
+
+                        /* Copy the index/table name under mutex. We
+                        do not want to hold the InnoDB mutex while
+                        filling the IS table */
+                        if (index) {
+                                const char*     name_ptr = index->name;
+
+                                if (name_ptr[0] == TEMP_INDEX_PREFIX) {
+                                        name_ptr++;
+                                }
+
+                                index_name = mem_heap_strdup(heap, name_ptr);
+
+                                table_name = mem_heap_strdup(heap,
+                                                             index->table_name);
+
+                        }
+
+                        mutex_exit(&dict_sys->mutex);
+                }
+
+                OK(field_store_string(
+                        fields[IDX_BUFFER_PAGE_TABLE_NAME], table_name));
+
+                OK(field_store_string(
+                        fields[IDX_BUFFER_PAGE_INDEX_NAME], index_name));
+
+                OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store(
+                        page_info->num_recs));
+
+                OK(fields[IDX_BUFFER_PAGE_DATA_SIZE]->store(
+                        page_info->data_size));
+
+                OK(fields[IDX_BUFFER_PAGE_ZIP_SIZE]->store(
+                        page_info->zip_ssize
+                        ? (PAGE_ZIP_MIN_SIZE >> 1) << page_info->zip_ssize
+                        : 0));
+
+#if BUF_PAGE_STATE_BITS > 3
+# error "BUF_PAGE_STATE_BITS > 3, please ensure that all 1<<BUF_PAGE_STATE_BITS values are checked for"
+#endif
+                state = static_cast<enum buf_page_state>(page_info->page_state);
+
+                switch (state) {
+                /* First three states are for compression pages and
+                are not states we would get as we scan pages through
+                buffer blocks */
+                case BUF_BLOCK_ZIP_FREE:
+                case BUF_BLOCK_ZIP_PAGE:
+                case BUF_BLOCK_ZIP_DIRTY:
+                        state_str = NULL;
+                        break;
+                case BUF_BLOCK_NOT_USED:
+                        state_str = "NOT_USED";
+                        break;
+                case BUF_BLOCK_READY_FOR_USE:
+                        state_str = "READY_FOR_USE";
+                        break;
+                case BUF_BLOCK_FILE_PAGE:
+                        state_str = "FILE_PAGE";
+                        break;
+                case BUF_BLOCK_MEMORY:
+                        state_str = "MEMORY";
+                        break;
+                case BUF_BLOCK_REMOVE_HASH:
+                        state_str = "REMOVE_HASH";
+                        break;
+                };
+
+                OK(field_store_string(fields[IDX_BUFFER_PAGE_STATE],
+                                      state_str));
+
+                switch (page_info->io_fix) {
+                case BUF_IO_NONE:
+                        OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX],
+                                              "IO_NONE"));
+                        break;
+                case BUF_IO_READ:
+                        OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX],
+                                              "IO_READ"));
+                        break;
+                case BUF_IO_WRITE:
+                        OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX],
+                                              "IO_WRITE"));
+                        break;
+                }
+
+                OK(field_store_string(fields[IDX_BUFFER_PAGE_IS_OLD],
+                                      (page_info->is_old) ? "YES" : "NO"));
+
+                OK(fields[IDX_BUFFER_PAGE_FREE_CLOCK]->store(
+                        page_info->freed_page_clock));
+
+                if (schema_table_store_record(thd, table)) {
+                        DBUG_RETURN(1);
+                }
+        }
+
+        DBUG_RETURN(0);
+}
+
+/*******************************************************************//**
+Set appropriate page type to a buf_page_info_t structure */
+static
+void
+i_s_innodb_set_page_type(
+/*=====================*/
+        buf_page_info_t*page_info,      /*!< in/out: structure to fill with
+                                        scanned info */
+        ulint           page_type,      /*!< in: page type */
+        const byte*     frame)          /*!< in: buffer frame */
+{
+        if (page_type == FIL_PAGE_INDEX) {
+                const page_t*   page = (const page_t*) frame;
+
+                /* FIL_PAGE_INDEX is a bit special, its value
+                is defined as 17855, so we cannot use FIL_PAGE_INDEX
+                to index into i_s_page_type[] array, its array index
+                in the i_s_page_type[] array is I_S_PAGE_TYPE_INDEX
+                (1) */
+                page_info->page_type = I_S_PAGE_TYPE_INDEX;
+
+                page_info->index_id = btr_page_get_index_id(page);
+
+                page_info->data_size = (ulint)(page_header_get_field(
+                        page, PAGE_HEAP_TOP) - (page_is_comp(page)
+                                                ? PAGE_NEW_SUPREMUM_END
+                                                : PAGE_OLD_SUPREMUM_END)
+                        - page_header_get_field(page, PAGE_GARBAGE));
+
+                page_info->num_recs = page_get_n_recs(page);
+        } else if (page_type >= I_S_PAGE_TYPE_UNKNOWN) {
+                /* Encountered an unknown page type */
+                page_info->page_type = I_S_PAGE_TYPE_UNKNOWN;
+        } else {
+                /* Make sure we get the right index into the
+                i_s_page_type[] array */
+                ut_a(page_type == i_s_page_type[page_type].type_value);
+
+                page_info->page_type = page_type;
+        }
+
+        if (page_info->page_type == FIL_PAGE_TYPE_ZBLOB
+            || page_info->page_type == FIL_PAGE_TYPE_ZBLOB2) {
+                page_info->page_num = mach_read_from_4(
+                        frame + FIL_PAGE_OFFSET);
+                page_info->space_id = mach_read_from_4(
+                        frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
+        }
+}
+
+/*******************************************************************//**
+Scans pages in the buffer cache, and collect their general information
+into the buf_page_info_t array which is zero-filled. So any fields
+that are not initialized in the function will default to 0 */
+static
+void
+i_s_innodb_buffer_page_get_info(
+/*============================*/
+        const buf_page_t*bpage,         /*!< in: buffer pool page to scan */
+        ulint           pos,            /*!< in: buffer block position in
+                                        buffer pool or in the LRU list */
+        buf_page_info_t*page_info)      /*!< in: zero filled info structure;
+                                        out: structure filled with scanned
+                                        info */
+{
+        page_info->block_id = pos;
+
+        page_info->page_state = buf_page_get_state(bpage);
+
+        /* Only fetch information for buffers that map to a tablespace,
+        that is, buffer page with state BUF_BLOCK_ZIP_PAGE,
+        BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_FILE_PAGE */
+        if (buf_page_in_file(bpage)) {
+                const byte*     frame;
+                ulint           page_type;
+
+                page_info->space_id = buf_page_get_space(bpage);
+
+                page_info->page_num = buf_page_get_page_no(bpage);
+
+                page_info->flush_type = bpage->flush_type;
+
+                page_info->fix_count = bpage->buf_fix_count;
+
+                page_info->newest_mod = bpage->newest_modification;
+
+                page_info->oldest_mod = bpage->oldest_modification;
+
+                page_info->access_time = bpage->access_time;
+
+                page_info->zip_ssize = bpage->zip.ssize;
+
+                page_info->io_fix = bpage->io_fix;
+
+                page_info->is_old = bpage->old;
+
+                page_info->freed_page_clock = bpage->freed_page_clock;
+
+                if (page_info->page_state == BUF_BLOCK_FILE_PAGE) {
+                        const buf_block_t*block;
+
+                        block = reinterpret_cast<const buf_block_t*>(bpage);
+                        frame = block->frame;
+                        page_info->hashed = (block->index != NULL);
+                } else {
+                        ut_ad(page_info->zip_ssize);
+                        frame = bpage->zip.data;
+                }
+
+                page_type = fil_page_get_type(frame);
+
+                i_s_innodb_set_page_type(page_info, page_type, frame);
+        } else {
+                page_info->page_type = I_S_PAGE_TYPE_UNKNOWN;
+        }
+}
+
+/*******************************************************************//**
+This is the function that goes through each block of the buffer pool
+and fetch information to information schema tables: INNODB_BUFFER_PAGE.
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_fill_buffer_pool(
+/*========================*/
+        THD*                    thd,            /*!< in: thread */
+        TABLE_LIST*             tables)         /*!< in/out: tables to fill */
+{
+        int                     status  = 0;
+        mem_heap_t*             heap;
+
+        DBUG_ENTER("i_s_innodb_fill_buffer_pool");
+
+        heap = mem_heap_create(10000);
+
+        /* Go through each chunk of buffer pool. Currently, we only
+        have one single chunk for each buffer pool */
+        for (ulint n = 0; n < buf_pool->n_chunks; n++) {
+                const buf_block_t*      block;
+                ulint                   n_blocks;
+                buf_page_info_t*        info_buffer;
+                ulint                   num_page;
+                ulint                   mem_size;
+                ulint                   chunk_size;
+                ulint                   num_to_process = 0;
+                ulint                   block_id = 0;
+
+                /* Get buffer block of the nth chunk */
+                block = buf_get_nth_chunk_block(buf_pool, n, &chunk_size);
+                num_page = 0;
+
+                while (chunk_size > 0) {
+                        /* we cache maximum MAX_BUF_INFO_CACHED number of
+                        buffer page info */
+                        num_to_process = ut_min(chunk_size,
+                                                MAX_BUF_INFO_CACHED);
+
+                        mem_size = num_to_process * sizeof(buf_page_info_t);
+
+                        /* For each chunk, we'll pre-allocate information
+                        structures to cache the page information read from
+                        the buffer pool. Doing so before obtain any mutex */
+                        info_buffer = (buf_page_info_t*) mem_heap_zalloc(
+                                heap, mem_size);
+
+                        /* Obtain appropriate mutexes. Since this is diagnostic
+                        buffer pool info printout, we are not required to
+                        preserve the overall consistency, so we can
+                        release mutex periodically */
+                        buf_pool_mutex_enter();
+
+                        /* GO through each block in the chunk */
+                        for (n_blocks = num_to_process; n_blocks--; block++) {
+                                i_s_innodb_buffer_page_get_info(
+                                        &block->page, block_id,
+                                        info_buffer + num_page);
+                                block_id++;
+                                num_page++;
+                        }
+
+                        buf_pool_mutex_exit();
+
+                        /* Fill in information schema table with information
+                        just collected from the buffer chunk scan */
+                        status = i_s_innodb_buffer_page_fill(
+                                thd, tables, info_buffer,
+                                num_page, heap);
+
+                        /* If something goes wrong, break and return */
+                        if (status) {
+                                break;
+                        }
+
+                        mem_heap_empty(heap);
+                        chunk_size -= num_to_process;
+                        num_page = 0;
+                }
+        }
+
+        mem_heap_free(heap);
+
+        DBUG_RETURN(status);
+}
+
+/*******************************************************************//**
+Fill page information for pages in InnoDB buffer pool to the
+dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buffer_page_fill_table(
+/*==============================*/
+        THD*            thd,            /*!< in: thread */
+        TABLE_LIST*     tables,         /*!< in/out: tables to fill */
+        Item*           )               /*!< in: condition (ignored) */
+{
+        int     status  = 0;
+
+        DBUG_ENTER("i_s_innodb_buffer_page_fill_table");
+
+        /* deny access to user without PROCESS privilege */
+        if (check_global_access(thd, PROCESS_ACL)) {
+                DBUG_RETURN(0);
+        }
+
+        /* Fetch information from pages in this buffer pool,
+        and fill the corresponding I_S table */
+        status = i_s_innodb_fill_buffer_pool(thd, tables);
+
+        DBUG_RETURN(status);
+}
+
+/*******************************************************************//**
+Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE.
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buffer_page_init(
+/*========================*/
+        void*   p)      /*!< in/out: table schema object */
+{
+        ST_SCHEMA_TABLE*        schema;
+
+        DBUG_ENTER("i_s_innodb_buffer_page_init");
+
+        schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p);
+
+        schema->fields_info = i_s_innodb_buffer_page_fields_info;
+        schema->fill_table = i_s_innodb_buffer_page_fill_table;
+
+        DBUG_RETURN(0);
+}
+
+UNIV_INTERN struct st_mysql_plugin      i_s_innodb_buffer_page =
+{
+        /* the plugin type (a MYSQL_XXX_PLUGIN value) */
+        /* int */
+        STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
+
+        /* pointer to type-specific plugin descriptor */
+        /* void* */
+        STRUCT_FLD(info, &i_s_info),
+
+        /* plugin name */
+        /* const char* */
+        STRUCT_FLD(name, "INNODB_BUFFER_PAGE"),
+
+        /* plugin author (for SHOW PLUGINS) */
+        /* const char* */
+        STRUCT_FLD(author, plugin_author),
+
+        /* general descriptive text (for SHOW PLUGINS) */
+        /* const char* */
+        STRUCT_FLD(descr, "InnoDB Buffer Page Information"),
+
+        /* the plugin license (PLUGIN_LICENSE_XXX) */
+        /* int */
+        STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
+
+        /* the function to invoke when plugin is loaded */
+        /* int (*)(void*); */
+        STRUCT_FLD(init, i_s_innodb_buffer_page_init),
+
+        /* the function to invoke when plugin is unloaded */
+        /* int (*)(void*); */
+        STRUCT_FLD(deinit, i_s_common_deinit),
+
+        /* plugin version (for SHOW PLUGINS) */
+        /* unsigned int */
+        STRUCT_FLD(version, INNODB_VERSION_SHORT),
+
+        /* struct st_mysql_show_var* */
+        STRUCT_FLD(status_vars, NULL),
+
+        /* struct st_mysql_sys_var** */
+        STRUCT_FLD(system_vars, NULL),
+
+        /* reserved for dependency checking */
+        /* void* */
+        STRUCT_FLD(__reserved1, NULL),
+};
+
+static ST_FIELD_INFO    i_s_innodb_buf_page_lru_fields_info[] =
+{
+#define IDX_BUF_LRU_POS                 0
+        {STRUCT_FLD(field_name,         "LRU_POSITION"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_SPACE          1
+        {STRUCT_FLD(field_name,         "SPACE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_NUM            2
+        {STRUCT_FLD(field_name,         "PAGE_NUMBER"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_TYPE           3
+        {STRUCT_FLD(field_name,         "PAGE_TYPE"),
+         STRUCT_FLD(field_length,       64),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_FLUSH_TYPE     4
+        {STRUCT_FLD(field_name,         "FLUSH_TYPE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_FIX_COUNT      5
+        {STRUCT_FLD(field_name,         "FIX_COUNT"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_HASHED         6
+        {STRUCT_FLD(field_name,         "IS_HASHED"),
+         STRUCT_FLD(field_length,       3),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_NEWEST_MOD     7
+        {STRUCT_FLD(field_name,         "NEWEST_MODIFICATION"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_OLDEST_MOD     8
+        {STRUCT_FLD(field_name,         "OLDEST_MODIFICATION"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_ACCESS_TIME    9
+        {STRUCT_FLD(field_name,         "ACCESS_TIME"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_TABLE_NAME     10
+        {STRUCT_FLD(field_name,         "TABLE_NAME"),
+         STRUCT_FLD(field_length,       1024),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_INDEX_NAME     11
+        {STRUCT_FLD(field_name,         "INDEX_NAME"),
+         STRUCT_FLD(field_length,       1024),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_NUM_RECS       12
+        {STRUCT_FLD(field_name,         "NUMBER_RECORDS"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_DATA_SIZE      13
+        {STRUCT_FLD(field_name,         "DATA_SIZE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_ZIP_SIZE       14
+        {STRUCT_FLD(field_name,         "COMPRESSED_SIZE"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_STATE          15
+        {STRUCT_FLD(field_name,         "COMPRESSED"),
+         STRUCT_FLD(field_length,       3),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_IO_FIX         16
+        {STRUCT_FLD(field_name,         "IO_FIX"),
+         STRUCT_FLD(field_length,       64),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_IS_OLD         17
+        {STRUCT_FLD(field_name,         "IS_OLD"),
+         STRUCT_FLD(field_length,       3),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_STRING),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_MAYBE_NULL),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+#define IDX_BUF_LRU_PAGE_FREE_CLOCK     18
+        {STRUCT_FLD(field_name,         "FREE_PAGE_CLOCK"),
+         STRUCT_FLD(field_length,       MY_INT64_NUM_DECIMAL_DIGITS),
+         STRUCT_FLD(field_type,         MYSQL_TYPE_LONGLONG),
+         STRUCT_FLD(value,              0),
+         STRUCT_FLD(field_flags,        MY_I_S_UNSIGNED),
+         STRUCT_FLD(old_name,           ""),
+         STRUCT_FLD(open_method,        SKIP_OPEN_TABLE)},
+
+        END_OF_ST_FIELD_INFO
+};
+
+/*******************************************************************//**
+Fill Information Schema table INNODB_BUFFER_PAGE_LRU with information
+cached in the buf_page_info_t array
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buf_page_lru_fill(
+/*=========================*/
+        THD*                    thd,            /*!< in: thread */
+        TABLE_LIST*             tables,         /*!< in/out: tables to fill */
+        const buf_page_info_t*  info_array,     /*!< in: array cached page
+                                                info */
+        ulint                   num_page)       /*!< in: number of page info
+                                                 cached */
+{
+        TABLE*                  table;
+        Field**                 fields;
+        mem_heap_t*             heap;
+
+        DBUG_ENTER("i_s_innodb_buf_page_lru_fill");
+
+        table = tables->table;
+
+        fields = table->field;
+
+        heap = mem_heap_create(1000);
+
+        /* Iterate through the cached array and fill the I_S table rows */
+        for (ulint i = 0; i < num_page; i++) {
+                const buf_page_info_t*  page_info;
+                const char*             table_name;
+                const char*             index_name;
+                const char*             state_str;
+                enum buf_page_state     state;
+
+                table_name = NULL;
+                index_name = NULL;
+                state_str = NULL;
+
+                page_info = info_array + i;
+
+                OK(fields[IDX_BUF_LRU_POS]->store(page_info->block_id));
+
+                OK(fields[IDX_BUF_LRU_PAGE_SPACE]->store(page_info->space_id));
+
+                OK(fields[IDX_BUF_LRU_PAGE_NUM]->store(page_info->page_num));
+
+                OK(field_store_string(
+                        fields[IDX_BUF_LRU_PAGE_TYPE],
+                        i_s_page_type[page_info->page_type].type_str));
+
+                OK(fields[IDX_BUF_LRU_PAGE_FLUSH_TYPE]->store(
+                        page_info->flush_type));
+
+                OK(fields[IDX_BUF_LRU_PAGE_FIX_COUNT]->store(
+                        page_info->fix_count));
+
+                if (page_info->hashed) {
+                        OK(field_store_string(
+                                fields[IDX_BUF_LRU_PAGE_HASHED], "YES"));
+                } else {
+                        OK(field_store_string(
+                                fields[IDX_BUF_LRU_PAGE_HASHED], "NO"));
+                }
+
+                OK(fields[IDX_BUF_LRU_PAGE_NEWEST_MOD]->store(
+                        page_info->newest_mod, true));
+
+                OK(fields[IDX_BUF_LRU_PAGE_OLDEST_MOD]->store(
+                        page_info->oldest_mod, true));
+
+                OK(fields[IDX_BUF_LRU_PAGE_ACCESS_TIME]->store(
+                        page_info->access_time));
+
+                /* If this is an index page, fetch the index name
+                and table name */
+                if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
+                        const dict_index_t*     index;
+
+                        mutex_enter(&dict_sys->mutex);
+                        index = dict_index_get_if_in_cache_low(
+                                page_info->index_id);
+
+                        /* Copy the index/table name under mutex. We
+                        do not want to hold the InnoDB mutex while
+                        filling the IS table */
+                        if (index) {
+                                const char*     name_ptr = index->name;
+
+                                if (name_ptr[0] == TEMP_INDEX_PREFIX) {
+                                        name_ptr++;
+                                }
+
+                                index_name = mem_heap_strdup(heap, name_ptr);
+
+                                table_name = mem_heap_strdup(heap,
+                                                             index->table_name);
+                        }
+
+                        mutex_exit(&dict_sys->mutex);
+                }
+
+                OK(field_store_string(
+                        fields[IDX_BUF_LRU_PAGE_TABLE_NAME], table_name));
+
+                OK(field_store_string(
+                        fields[IDX_BUF_LRU_PAGE_INDEX_NAME], index_name));
+                OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store(
+                        page_info->num_recs));
+
+                OK(fields[IDX_BUF_LRU_PAGE_DATA_SIZE]->store(
+                        page_info->data_size));
+
+                OK(fields[IDX_BUF_LRU_PAGE_ZIP_SIZE]->store(
+                        page_info->zip_ssize ?
+                                 512 << page_info->zip_ssize : 0));
+
+                state = static_cast<enum buf_page_state>(page_info->page_state);
+
+                switch (state) {
+                /* Compressed page */
+                case BUF_BLOCK_ZIP_PAGE:
+                case BUF_BLOCK_ZIP_DIRTY:
+                        state_str = "YES";
+                        break;
+                /* Uncompressed page */
+                case BUF_BLOCK_FILE_PAGE:
+                        state_str = "NO";
+                        break;
+                /* We should not see following states */
+                case BUF_BLOCK_ZIP_FREE:
+                case BUF_BLOCK_READY_FOR_USE:
+                case BUF_BLOCK_NOT_USED:
+                case BUF_BLOCK_MEMORY:
+                case BUF_BLOCK_REMOVE_HASH:
+                        state_str = NULL;
+                        break;
+                };
+
+                OK(field_store_string(fields[IDX_BUF_LRU_PAGE_STATE],
+                                      state_str));
+
+                switch (page_info->io_fix) {
+                case BUF_IO_NONE:
+                        OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX],
+                                              "IO_NONE"));
+                        break;
+                case BUF_IO_READ:
+                        OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX],
+                                              "IO_READ"));
+                        break;
+                case BUF_IO_WRITE:
+                        OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX],
+                                              "IO_WRITE"));
+                        break;
+                }
+
+                OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IS_OLD],
+                                      (page_info->is_old) ? "YES" : "NO"));
+
+                OK(fields[IDX_BUF_LRU_PAGE_FREE_CLOCK]->store(
+                        page_info->freed_page_clock));
+
+                if (schema_table_store_record(thd, table)) {
+                        mem_heap_free(heap);
+                        DBUG_RETURN(1);
+                }
+
+                mem_heap_empty(heap);
+        }
+
+        mem_heap_free(heap);
+
+        DBUG_RETURN(0);
+}
+
+/*******************************************************************//**
+This is the function that goes through buffer pool's LRU list
+and fetch information to INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU.
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_fill_buffer_lru(
+/*=======================*/
+        THD*                    thd,            /*!< in: thread */
+        TABLE_LIST*             tables)         /*!< in/out: tables to fill */
+{
+        int                     status = 0;
+        buf_page_info_t*        info_buffer;
+        ulint                   lru_pos = 0;
+        const buf_page_t*       bpage;
+        ulint                   lru_len;
+
+        DBUG_ENTER("i_s_innodb_fill_buffer_lru");
+
+        /* Obtain buf_pool mutex before allocate info_buffer, since
+        UT_LIST_GET_LEN(buf_pool->LRU) could change */
+        buf_pool_mutex_enter();
+
+        lru_len = UT_LIST_GET_LEN(buf_pool->LRU);
+
+        /* Print error message if malloc fail */
+        info_buffer = (buf_page_info_t*) my_malloc(
+                lru_len * sizeof *info_buffer, MYF(MY_WME));
+
+        if (!info_buffer) {
+                status = 1;
+                goto exit;
+        }
+
+        memset(info_buffer, 0, lru_len * sizeof *info_buffer);
+
+        /* Walk through Pool's LRU list and print the buffer page
+        information */
+        bpage = UT_LIST_GET_LAST(buf_pool->LRU);
+
+        while (bpage != NULL) {
+                /* Use the same function that collect buffer info for
+                INNODB_BUFFER_PAGE to get buffer page info */
+                i_s_innodb_buffer_page_get_info(bpage, lru_pos,
+                                                (info_buffer + lru_pos));
+
+                bpage = UT_LIST_GET_PREV(LRU, bpage);
+
+                lru_pos++;
+        }
+
+        ut_ad(lru_pos == lru_len);
+        ut_ad(lru_pos == UT_LIST_GET_LEN(buf_pool->LRU));
+
+exit:
+        buf_pool_mutex_exit();
+
+        if (info_buffer) {
+                status = i_s_innodb_buf_page_lru_fill(
+                        thd, tables, info_buffer, lru_len);
+
+                my_free(info_buffer, MYF(MY_ALLOW_ZERO_PTR));
+        }
+
+        DBUG_RETURN(status);
+}
+
+/*******************************************************************//**
+Fill page information for pages in InnoDB buffer pool to the
+dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buf_page_lru_fill_table(
+/*===============================*/
+        THD*            thd,            /*!< in: thread */
+        TABLE_LIST*     tables,         /*!< in/out: tables to fill */
+        Item*           )               /*!< in: condition (ignored) */
+{
+        int     status  = 0;
+
+        DBUG_ENTER("i_s_innodb_buf_page_lru_fill_table");
+
+        /* deny access to any users that do not hold PROCESS_ACL */
+        if (check_global_access(thd, PROCESS_ACL)) {
+                DBUG_RETURN(0);
+        }
+
+        /* Fetch information from pages in this buffer pool's LRU list,
+        and fill the corresponding I_S table */
+        status = i_s_innodb_fill_buffer_lru(thd, tables);
+
+        DBUG_RETURN(status);
+}
+
+/*******************************************************************//**
+Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU.
+ at return 0 on success, 1 on failure */
+static
+int
+i_s_innodb_buffer_page_lru_init(
+/*============================*/
+        void*   p)      /*!< in/out: table schema object */
+{
+        ST_SCHEMA_TABLE*        schema;
+
+        DBUG_ENTER("i_s_innodb_buffer_page_lru_init");
+
+        schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p);
+
+        schema->fields_info = i_s_innodb_buf_page_lru_fields_info;
+        schema->fill_table = i_s_innodb_buf_page_lru_fill_table;
+
+        DBUG_RETURN(0);
+}
+
+UNIV_INTERN struct st_mysql_plugin      i_s_innodb_buffer_page_lru =
+{
+        /* the plugin type (a MYSQL_XXX_PLUGIN value) */
+        /* int */
+        STRUCT_FLD(type, MYSQL_INFORMATION_SCHEMA_PLUGIN),
+
+        /* pointer to type-specific plugin descriptor */
+        /* void* */
+        STRUCT_FLD(info, &i_s_info),
+
+        /* plugin name */
+        /* const char* */
+        STRUCT_FLD(name, "INNODB_BUFFER_PAGE_LRU"),
+
+        /* plugin author (for SHOW PLUGINS) */
+        /* const char* */
+        STRUCT_FLD(author, plugin_author),
+
+        /* general descriptive text (for SHOW PLUGINS) */
+        /* const char* */
+        STRUCT_FLD(descr, "InnoDB Buffer Page in LRU"),
+
+        /* the plugin license (PLUGIN_LICENSE_XXX) */
+        /* int */
+        STRUCT_FLD(license, PLUGIN_LICENSE_GPL),
+
+        /* the function to invoke when plugin is loaded */
+        /* int (*)(void*); */
+        STRUCT_FLD(init, i_s_innodb_buffer_page_lru_init),
+
+        /* the function to invoke when plugin is unloaded */
+        /* int (*)(void*); */
+        STRUCT_FLD(deinit, i_s_common_deinit),
+
+        /* plugin version (for SHOW PLUGINS) */
+        /* unsigned int */
+        STRUCT_FLD(version, INNODB_VERSION_SHORT),
+
+        /* struct st_mysql_show_var* */
+        STRUCT_FLD(status_vars, NULL),
+
+        /* struct st_mysql_sys_var** */
+        STRUCT_FLD(system_vars, NULL),
+
+        /* reserved for dependency checking */
+        /* void* */
+        STRUCT_FLD(__reserved1, NULL),
+};

=== modified file 'storage/innodb_plugin/handler/i_s.h'
--- a/storage/innodb_plugin/handler/i_s.h	2009-05-25 09:52:29 +0000
+++ b/storage/innodb_plugin/handler/i_s.h	2012-07-25 08:21:39 +0000
@@ -33,5 +33,8 @@ extern struct st_mysql_plugin	i_s_innodb
 extern struct st_mysql_plugin   i_s_innodb_cmp_reset;
 extern struct st_mysql_plugin   i_s_innodb_cmpmem;
 extern struct st_mysql_plugin   i_s_innodb_cmpmem_reset;
+extern struct st_mysql_plugin   i_s_innodb_buffer_page;
+extern struct st_mysql_plugin   i_s_innodb_buffer_page_lru;
+extern struct st_mysql_plugin   i_s_innodb_buffer_stats;
 
 #endif /* i_s_h */

=== modified file 'storage/innodb_plugin/ibuf/ibuf0ibuf.c'
--- a/storage/innodb_plugin/ibuf/ibuf0ibuf.c	2012-03-15 17:30:17 +0000
+++ b/storage/innodb_plugin/ibuf/ibuf0ibuf.c	2012-08-21 07:47:17 +0000
@@ -2752,11 +2752,19 @@ ibuf_insert_low(
 
                 root = ibuf_tree_root_get(&mtr);
 
-                err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
-                                                 | BTR_NO_UNDO_LOG_FLAG,
-                                                 cursor,
-                                                 ibuf_entry, &ins_rec,
-                                                 &dummy_big_rec, 0, thr, &mtr);
+                err = btr_cur_optimistic_insert(
+                        BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG,
+                        cursor, ibuf_entry, &ins_rec,
+                        &dummy_big_rec, 0, thr, &mtr);
+
+                if (err == DB_FAIL) {
+                        err = btr_cur_pessimistic_insert(
+                                BTR_NO_LOCKING_FLAG
+                                | BTR_NO_UNDO_LOG_FLAG,
+                                cursor, ibuf_entry, &ins_rec,
+                                &dummy_big_rec, 0, thr, &mtr);
+                }
+
                 if (err == DB_SUCCESS) {
                         /* Update the page max trx id field */
                         page_update_max_trx_id(btr_cur_get_block(cursor), NULL,

=== modified file 'storage/innodb_plugin/include/buf0buf.h'
--- a/storage/innodb_plugin/include/buf0buf.h	2012-02-17 09:42:04 +0000
+++ b/storage/innodb_plugin/include/buf0buf.h	2012-07-25 08:21:39 +0000
@@ -103,6 +103,81 @@ enum buf_page_state {
                                         before putting to the free list */
 };
 
+/** This structure defines information we will fetch from each buffer pool. It
+will be used to print table IO stats */
+struct buf_pool_info_struct{
+        /* General buffer pool info */
+        ulint   pool_size;              /*!< Buffer Pool size in pages */
+        ulint   lru_len;                /*!< Length of buf_pool->LRU */
+        ulint   old_lru_len;            /*!< buf_pool->LRU_old_len */
+        ulint   free_list_len;          /*!< Length of buf_pool->free list */
+        ulint   flush_list_len;         /*!< Length of buf_pool->flush_list */
+        ulint   n_pend_unzip;           /*!< buf_pool->n_pend_unzip, pages
+                                        pending decompress */
+        ulint   n_pend_reads;           /*!< buf_pool->n_pend_reads, pages
+                                        pending read */
+        ulint   n_pending_flush_lru;    /*!< Pages pending flush in LRU */
+        ulint   n_pending_flush_single_page;/*!< Pages pending to be
+                                        flushed as part of single page
+                                        flushes issued by various user
+                                        threads */
+        ulint   n_pending_flush_list;   /*!< Pages pending flush in FLUSH
+                                        LIST */
+        ulint   n_pages_made_young;     /*!< number of pages made young */
+        ulint   n_pages_not_made_young; /*!< number of pages not made young */
+        ulint   n_pages_read;           /*!< buf_pool->n_pages_read */
+        ulint   n_pages_created;        /*!< buf_pool->n_pages_created */
+        ulint   n_pages_written;        /*!< buf_pool->n_pages_written */
+        ulint   n_page_gets;            /*!< buf_pool->n_page_gets */
+        ulint   n_ra_pages_read_rnd;    /*!< buf_pool->n_ra_pages_read_rnd,
+                                        number of pages readahead */
+        ulint   n_ra_pages_read;        /*!< buf_pool->n_ra_pages_read, number
+                                        of pages readahead */
+        ulint   n_ra_pages_evicted;     /*!< buf_pool->n_ra_pages_evicted,
+                                        number of readahead pages evicted
+                                        without access */
+        ulint   n_page_get_delta;       /*!< num of buffer pool page gets since
+                                        last printout */
+
+        /* Buffer pool access stats */
+        double  page_made_young_rate;   /*!< page made young rate in pages
+                                        per second */
+        double  page_not_made_young_rate;/*!< page not made young rate
+                                        in pages per second */
+        double  pages_read_rate;        /*!< num of pages read per second */
+        double  pages_created_rate;     /*!< num of pages create per second */
+        double  pages_written_rate;     /*!< num of  pages written per second */
+        ulint   page_read_delta;        /*!< num of pages read since last
+                                        printout */
+        ulint   young_making_delta;     /*!< num of pages made young since
+                                        last printout */
+        ulint   not_young_making_delta; /*!< num of pages not make young since
+                                        last printout */
+
+        /* Statistics about read ahead algorithm.  */
+        double  pages_readahead_rnd_rate;/*!< random readahead rate in pages per
+                                        second */
+        double  pages_readahead_rate;   /*!< readahead rate in pages per
+                                        second */
+        double  pages_evicted_rate;     /*!< rate of readahead page evicted
+                                        without access, in pages per second */
+
+        /* Stats about LRU eviction */
+        ulint   unzip_lru_len;          /*!< length of buf_pool->unzip_LRU
+                                        list */
+        /* Counters for LRU policy */
+        ulint   io_sum;                 /*!< buf_LRU_stat_sum.io */
+        ulint   io_cur;                 /*!< buf_LRU_stat_cur.io, num of IO
+                                        for current interval */
+        ulint   unzip_sum;              /*!< buf_LRU_stat_sum.unzip */
+        ulint   unzip_cur;              /*!< buf_LRU_stat_cur.unzip, num
+                                        pages decompressed in current
+                                        interval */
+};
+
+typedef struct buf_pool_info_struct     buf_pool_info_t;
+
+
 #ifndef UNIV_HOTBACKUP
 /********************************************************************//**
 Creates the buffer pool.
@@ -618,6 +693,16 @@ void
 buf_print_io(
 /*=========*/
         FILE*   file);  /*!< in: file where to print */
+/*******************************************************************//**
+Collect buffer pool stats information for a buffer pool. Also
+record aggregated stats if there are more than one buffer pool
+in the server */
+UNIV_INTERN
+void
+buf_stats_get_pool_info(
+/*====================*/
+        buf_pool_info_t*        pool_info); /*!< in/out: buffer pool info
+                                                to fill */
 /*********************************************************************//**
 Returns the ratio in percents of modified pages in the buffer pool /
 database pages in the buffer pool.
@@ -1037,12 +1122,27 @@ UNIV_INTERN
 ulint
 buf_get_free_list_len(void);
 /*=======================*/
+
+/*********************************************************************//**
+Get the nth chunk's buffer block in the specified buffer pool.
+ at return the nth chunk's buffer block. */
+UNIV_INLINE
+buf_block_t*
+buf_get_nth_chunk_block(
+/*====================*/
+        const buf_pool_t* buf_pool,     /*!< in: buffer pool instance */
+        ulint           n,              /*!< in: nth chunk in the buffer pool */
+        ulint*          chunk_size);    /*!< in: chunk size */
+
 #endif /* !UNIV_HOTBACKUP */
 
 
 /** The common buffer control block structure
 for compressed and uncompressed frames */
 
+/** Number of bits used for buffer page states. */
+#define BUF_PAGE_STATE_BITS     3
+
 struct buf_page_struct{
         /** @name General fields
         None of these bit-fields must be modified without holding
@@ -1057,7 +1157,8 @@ struct buf_page_struct{
         unsigned        offset:32;      /*!< page number; also protected
                                         by buf_pool_mutex. */
 
-        unsigned        state:3;        /*!< state of the control block; also
+        unsigned        state:BUF_PAGE_STATE_BITS;
+                                        /*!< state of the control block; also
                                         protected by buf_pool_mutex.
                                         State transitions from
                                         BUF_BLOCK_READY_FOR_USE to

=== modified file 'storage/innodb_plugin/include/buf0buf.ic'
--- a/storage/innodb_plugin/include/buf0buf.ic	2012-02-17 09:42:04 +0000
+++ b/storage/innodb_plugin/include/buf0buf.ic	2012-07-25 08:21:39 +0000
@@ -36,6 +36,16 @@ Created 11/5/1995 Heikki Tuuri
 #include "buf0lru.h"
 #include "buf0rea.h"
 
+/** A chunk of buffers. The buffer pool is allocated in chunks. */
+struct buf_chunk_struct{
+        ulint           mem_size;       /*!< allocated size of the chunk */
+        ulint           size;           /*!< size of frames[] and blocks[] */
+        void*           mem;            /*!< pointer to the memory area which
+                                        was allocated for the frames */
+        buf_block_t*    blocks;         /*!< array of buffer control blocks */
+};
+
+
 /********************************************************************//**
 Reads the freed_page_clock of a buffer block.
 @return freed_page_clock */
@@ -1106,4 +1116,23 @@ buf_block_dbg_add_level(
         sync_thread_add_level(&block->lock, level, FALSE);
 }
 #endif /* UNIV_SYNC_DEBUG */
+
+/*********************************************************************//**
+Get the nth chunk's buffer block in the specified buffer pool.
+ at return the nth chunk's buffer block. */
+UNIV_INLINE
+buf_block_t*
+buf_get_nth_chunk_block(
+/*====================*/
+        const buf_pool_t* buf_pool,     /*!< in: buffer pool instance */
+        ulint           n,              /*!< in: nth chunk in the buffer pool */
+        ulint*          chunk_size)     /*!< in: chunk size */
+{
+        const buf_chunk_t*      chunk;
+
+        chunk = buf_pool->chunks + n;
+        *chunk_size = chunk->size;
+        return(chunk->blocks);
+}
 #endif /* !UNIV_HOTBACKUP */
+

=== modified file 'storage/innodb_plugin/include/fil0fil.h'
--- a/storage/innodb_plugin/include/fil0fil.h	2012-03-15 17:30:17 +0000
+++ b/storage/innodb_plugin/include/fil0fil.h	2012-07-25 08:21:39 +0000
@@ -141,6 +141,8 @@ extern fil_addr_t	fil_addr_null;
 #define FIL_PAGE_TYPE_BLOB      10      /*!< Uncompressed BLOB page */
 #define FIL_PAGE_TYPE_ZBLOB     11      /*!< First compressed BLOB page */
 #define FIL_PAGE_TYPE_ZBLOB2    12      /*!< Subsequent compressed BLOB page */
+#define FIL_PAGE_TYPE_LAST      FIL_PAGE_TYPE_ZBLOB2
+                                        /*!< Last page type */
 /* @} */
 
 /** Space types @{ */

=== modified file 'storage/innodb_plugin/include/log0log.h'
--- a/storage/innodb_plugin/include/log0log.h	2012-02-16 10:20:41 +0000
+++ b/storage/innodb_plugin/include/log0log.h	2012-07-25 08:21:39 +0000
@@ -41,6 +41,9 @@ Created 12/9/1995 Heikki Tuuri
 #include "sync0rw.h"
 #endif /* !UNIV_HOTBACKUP */
 
+/* Type used for all log sequence number storage and arithmetics */
+typedef ib_uint64_t             lsn_t;
+
 /** Redo log buffer */
 typedef struct log_struct       log_t;
 /** Redo log group */

=== modified file 'storage/innodb_plugin/include/univ.i'
--- a/storage/innodb_plugin/include/univ.i	2012-04-05 08:49:38 +0000
+++ b/storage/innodb_plugin/include/univ.i	2012-11-06 09:52:55 +0000
@@ -267,6 +267,24 @@ management to ensure correct alignment f
                         ========================
 */
 
+/** There are currently two InnoDB file formats which are used to group
+features with similar restrictions and dependencies. Using an enum allows
+switch statements to give a compiler warning when a new one is introduced. */
+enum innodb_file_formats_enum {
+        /** Antelope File Format: InnoDB/MySQL up to 5.1.
+        This format includes REDUNDANT and COMPACT row formats */
+        UNIV_FORMAT_A           = 0,
+
+        /** Barracuda File Format: Introduced in InnoDB plugin for 5.1:
+        This format includes COMPRESSED and DYNAMIC row formats.  It
+        includes the ability to create secondary indexes from data that
+        is not on the clustered index page and the ability to store more
+        data off the clustered index page. */
+        UNIV_FORMAT_B           = 1
+};
+
+typedef enum innodb_file_formats_enum innodb_file_formats_t;
+
 /* The 2-logarithm of UNIV_PAGE_SIZE: */
 #define UNIV_PAGE_SIZE_SHIFT    14
 /* The universal page size of the database */

=== modified file 'storage/innodb_plugin/page/page0cur.c'
--- a/storage/innodb_plugin/page/page0cur.c	2012-02-17 09:42:04 +0000
+++ b/storage/innodb_plugin/page/page0cur.c	2012-08-30 18:53:41 +0000
@@ -1902,6 +1902,7 @@ page_cur_delete_rec(
 
         /* Save to local variables some data associated with current_rec */
         cur_slot_no = page_dir_find_owner_slot(current_rec);
+        ut_ad(cur_slot_no > 0);
         cur_dir_slot = page_dir_get_nth_slot(page, cur_slot_no);
         cur_n_owned = page_dir_slot_get_n_owned(cur_dir_slot);
 

=== modified file 'storage/innodb_plugin/page/page0page.c'
--- a/storage/innodb_plugin/page/page0page.c	2012-02-17 09:42:04 +0000
+++ b/storage/innodb_plugin/page/page0page.c	2012-08-30 18:53:41 +0000
@@ -780,17 +780,23 @@ page_copy_rec_list_start(
         if (UNIV_LIKELY_NULL(new_page_zip)) {
                 mtr_set_log_mode(mtr, log_mode);
 
+                DBUG_EXECUTE_IF("page_copy_rec_list_start_compress_fail",
+                                goto zip_reorganize;);
+
                 if (UNIV_UNLIKELY
                     (!page_zip_compress(new_page_zip, new_page, index, mtr))) {
+                        ulint   ret_pos;
+#ifndef DBUG_OFF
+zip_reorganize:
+#endif /* DBUG_OFF */
                         /* Before trying to reorganize the page,
                         store the number of preceding records on the page. */
-                        ulint   ret_pos
-                                = page_rec_get_n_recs_before(ret);
+                        ret_pos = page_rec_get_n_recs_before(ret);
                         /* Before copying, "ret" was the predecessor
                         of the predefined supremum record.  If it was
                         the predefined infimum record, then it would
-                        still be the infimum.  Thus, the assertion
-                        ut_a(ret_pos > 0) would fail here. */
+                        still be the infimum, and we would have
+                        ret_pos == 0. */
 
                         if (UNIV_UNLIKELY
                             (!page_zip_reorganize(new_block, index, mtr))) {
@@ -806,15 +812,10 @@ page_copy_rec_list_start(
                                 btr_blob_dbg_add(new_page, index,
                                                  "copy_start_reorg_fail");
                                 return(NULL);
-                        } else {
-                                /* The page was reorganized:
-                                Seek to ret_pos. */
-                                ret = new_page + PAGE_NEW_INFIMUM;
-
-                                do {
-                                        ret = rec_get_next_ptr(ret, TRUE);
-                                } while (--ret_pos);
                         }
+
+                        /* The page was reorganized: Seek to ret_pos. */
+                        ret = page_rec_get_nth(new_page, ret_pos);
                 }
         }
 
@@ -1050,6 +1051,7 @@ page_delete_rec_list_end(
 
                 n_owned = rec_get_n_owned_new(rec2) - count;
                 slot_index = page_dir_find_owner_slot(rec2);
+                ut_ad(slot_index > 0);
                 slot = page_dir_get_nth_slot(page, slot_index);
         } else {
                 rec_t*  rec2    = rec;
@@ -1065,6 +1067,7 @@ page_delete_rec_list_end(
 
                 n_owned = rec_get_n_owned_old(rec2) - count;
                 slot_index = page_dir_find_owner_slot(rec2);
+                ut_ad(slot_index > 0);
                 slot = page_dir_get_nth_slot(page, slot_index);
         }
 
@@ -1491,6 +1494,10 @@ page_rec_get_nth_const(
         ulint                   n_owned;
         const rec_t*            rec;
 
+        if (nth == 0) {
+                return(page_get_infimum_rec(page));
+        }
+
         ut_ad(nth < UNIV_PAGE_SIZE / (REC_N_NEW_EXTRA_BYTES + 1));
 
         for (i = 0;; i++) {

=== modified file 'storage/innodb_plugin/row/row0ins.c'
--- a/storage/innodb_plugin/row/row0ins.c	2012-05-15 12:04:39 +0000
+++ b/storage/innodb_plugin/row/row0ins.c	2012-08-21 07:47:17 +0000
@@ -2179,9 +2179,16 @@ row_ins_index_entry_low(
 
                                 goto function_exit;
                         }
-                        err = btr_cur_pessimistic_insert(
+
+                        err = btr_cur_optimistic_insert(
                                 0, &cursor, entry, &insert_rec, &big_rec,
                                 n_ext, thr, &mtr);
+
+                        if (err == DB_FAIL) {
+                                err = btr_cur_pessimistic_insert(
+                                        0, &cursor, entry, &insert_rec,
+                                        &big_rec, n_ext, thr, &mtr);
+                        }
                 }
         }
 

=== modified file 'storage/innodb_plugin/row/row0merge.c'
--- a/storage/innodb_plugin/row/row0merge.c	2012-02-10 03:09:12 +0000
+++ b/storage/innodb_plugin/row/row0merge.c	2012-08-09 06:55:29 +0000
@@ -1214,11 +1214,25 @@ row_merge_read_clustered_index(
                                 goto err_exit;
                         }
 
+                        /* Store the cursor position on the last user
+                        record on the page. */
+                        btr_pcur_move_to_prev_on_page(&pcur);
+                        /* Leaf pages must never be empty, unless
+                        this is the only page in the index tree. */
+                        ut_ad(btr_pcur_is_on_user_rec(&pcur)
+                              || buf_block_get_page_no(
+                                      btr_pcur_get_block(&pcur))
+                              == clust_index->page);
+
                         btr_pcur_store_position(&pcur, &mtr);
                         mtr_commit(&mtr);
                         mtr_start(&mtr);
+                        /* Restore position on the record, or its
+                        predecessor if the record was purged
+                        meanwhile. */
                         btr_pcur_restore_position(BTR_SEARCH_LEAF,
                                                   &pcur, &mtr);
+                        /* Move to the successor of the original record. */
                         has_next = btr_pcur_move_to_next_user_rec(&pcur, &mtr);
                 }
 

=== modified file 'storage/innodb_plugin/scripts/install_innodb_plugins.sql'
--- a/storage/innodb_plugin/scripts/install_innodb_plugins.sql	2008-10-30 10:38:18 +0000
+++ b/storage/innodb_plugin/scripts/install_innodb_plugins.sql	2012-07-25 08:21:39 +0000
@@ -7,3 +7,6 @@ INSTALL PLUGIN innodb_cmp SONAME 'ha_inn
 INSTALL PLUGIN innodb_cmp_reset SONAME 'ha_innodb.so';
 INSTALL PLUGIN innodb_cmpmem SONAME 'ha_innodb.so';
 INSTALL PLUGIN innodb_cmpmem_reset SONAME 'ha_innodb.so';
+INSTALL PLUGIN innodb_buffer_pool_stats SONAME 'ha_innodb.so';
+INSTALL PLUGIN innodb_buffer_page SONAME 'ha_innodb.so';
+INSTALL PLUGIN innodb_buffer_page_lru SONAME 'ha_innodb.so';

=== modified file 'storage/innodb_plugin/scripts/install_innodb_plugins_win.sql'
--- a/storage/innodb_plugin/scripts/install_innodb_plugins_win.sql	2008-10-31 12:21:43 +0000
+++ b/storage/innodb_plugin/scripts/install_innodb_plugins_win.sql	2012-07-25 08:21:39 +0000
@@ -7,3 +7,6 @@ INSTALL PLUGIN innodb_cmp SONAME 'ha_inn
 INSTALL PLUGIN innodb_cmp_reset SONAME 'ha_innodb.dll';
 INSTALL PLUGIN innodb_cmpmem SONAME 'ha_innodb.dll';
 INSTALL PLUGIN innodb_cmpmem_reset SONAME 'ha_innodb.dll';
+INSTALL PLUGIN innodb_buffer_pool_stats SONAME 'ha_innodb.dll';
+INSTALL PLUGIN innodb_buffer_page SONAME 'ha_innodb.dll';
+INSTALL PLUGIN innodb_buffer_page_lru SONAME 'ha_innodb.dll';

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2011-11-23 17:32:14 +0000
+++ b/support-files/mysql.spec.sh	2012-11-06 09:52:55 +0000
@@ -390,7 +390,7 @@ CXXFLAGS=${CXXFLAGS:-$RPM_OPT_FLAGS -fel
 # Evaluate current setting of $DEBUG
 if [ $DEBUG -gt 0 ] ; then
         OPT_COMMENT='--with-comment="%{debug_comment}"'
-        OPT_DEBUG='--with-debug'
+        OPT_DEBUG='--with-debug --enable-mysql-maintainer-mode=no'
         CFLAGS=`echo   " $CFLAGS "   | \
             sed -e 's/ -O[0-9]* / /' -e 's/ -unroll2 / /' -e 's/ -ip / /' \
                 -e 's/^ //' -e 's/ $//'`
@@ -1226,6 +1226,11 @@ fi
 # merging BK trees)
 ##############################################################################
 %changelog
+* Tue Sep 11 2012 Joerg Bruehe <joerg.bruehe at oracle.com>
+
+- Disable "maintainer mode" in debug builds, there is a cast ulonglong -> int
+  in the sources (since 2007) that would cause builds to fail.
+
 * Wed Sep 14 2011 Joerg Bruehe <joerg.bruehe at oracle.com>
 
 - Let the RPM capabilities ("obsoletes" etc) ensure that an upgrade may replace

=== modified file 'vio/viosslfactories.c'
--- a/vio/viosslfactories.c	2012-08-22 09:40:39 +0000
+++ b/vio/viosslfactories.c	2012-11-06 09:52:55 +0000
@@ -101,47 +101,51 @@ vio_set_cert_stuff(SSL_CTX *ctx, const c
   DBUG_ENTER("vio_set_cert_stuff");
   DBUG_PRINT("enter", ("ctx: 0x%lx  cert_file: %s  key_file: %s",
                        (long) ctx, cert_file, key_file));
-  if (cert_file)
-  {
-    if (SSL_CTX_use_certificate_file(ctx, cert_file, SSL_FILETYPE_PEM) <= 0)
-    {
-      *error= SSL_INITERR_CERT;
-      DBUG_PRINT("error",("%s from file '%s'", sslGetErrString(*error), cert_file));
-      DBUG_EXECUTE("error", ERR_print_errors_fp(DBUG_FILE););
-      fprintf(stderr, "SSL error: %s from '%s'\n", sslGetErrString(*error),
-              cert_file);
-      fflush(stderr);
-      DBUG_RETURN(1);
-    }
 
-    if (!key_file)
-      key_file= cert_file;
+  if (!cert_file &&  key_file)
+    cert_file= key_file;
+  
+  if (!key_file &&  cert_file)
+    key_file= cert_file;
+
+  if (cert_file &&
+      SSL_CTX_use_certificate_file(ctx, cert_file, SSL_FILETYPE_PEM) <= 0)
+  {
+    *error= SSL_INITERR_CERT;
+    DBUG_PRINT("error",("%s from file '%s'", sslGetErrString(*error), cert_file));
+    DBUG_EXECUTE("error", ERR_print_errors_fp(DBUG_FILE););
+    fprintf(stderr, "SSL error: %s from '%s'\n", sslGetErrString(*error),
+            cert_file);
+    fflush(stderr);
+    DBUG_RETURN(1);
+  }
 
-    if (SSL_CTX_use_PrivateKey_file(ctx, key_file, SSL_FILETYPE_PEM) <= 0)
-    {
-      *error= SSL_INITERR_KEY;
-      DBUG_PRINT("error", ("%s from file '%s'", sslGetErrString(*error), key_file));
-      DBUG_EXECUTE("error", ERR_print_errors_fp(DBUG_FILE););
-      fprintf(stderr, "SSL error: %s from '%s'\n", sslGetErrString(*error),
-              key_file);
-      fflush(stderr);
-      DBUG_RETURN(1);
-    }
+  if (key_file &&
+      SSL_CTX_use_PrivateKey_file(ctx, key_file, SSL_FILETYPE_PEM) <= 0)
+  {
+    *error= SSL_INITERR_KEY;
+    DBUG_PRINT("error", ("%s from file '%s'", sslGetErrString(*error), key_file));
+    DBUG_EXECUTE("error", ERR_print_errors_fp(DBUG_FILE););
+    fprintf(stderr, "SSL error: %s from '%s'\n", sslGetErrString(*error),
+            key_file);
+    fflush(stderr);
+    DBUG_RETURN(1);
+  }
 
-    /*
-      If we are using DSA, we can copy the parameters from the private key
-      Now we know that a key and cert have been set against the SSL context
-    */
-    if (!SSL_CTX_check_private_key(ctx))
-    {
-      *error= SSL_INITERR_NOMATCH;
-      DBUG_PRINT("error", ("%s",sslGetErrString(*error)));
-      DBUG_EXECUTE("error", ERR_print_errors_fp(DBUG_FILE););
-      fprintf(stderr, "SSL error: %s\n", sslGetErrString(*error));
-      fflush(stderr);
-      DBUG_RETURN(1);
-    }
+  /*
+    If we are using DSA, we can copy the parameters from the private key
+    Now we know that a key and cert have been set against the SSL context
+  */
+  if (cert_file && !SSL_CTX_check_private_key(ctx))
+  {
+    *error= SSL_INITERR_NOMATCH;
+    DBUG_PRINT("error", ("%s",sslGetErrString(*error)));
+    DBUG_EXECUTE("error", ERR_print_errors_fp(DBUG_FILE););
+    fprintf(stderr, "SSL error: %s\n", sslGetErrString(*error));
+    fflush(stderr);
+    DBUG_RETURN(1);
   }
+
   DBUG_RETURN(0);
 }
 
@@ -253,6 +257,20 @@ new_VioSSLFd(const char *key_file, const
   if (SSL_CTX_load_verify_locations(ssl_fd->ssl_context, ca_file, ca_path) == 0)
   {
     DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed"));
+    if (ca_file || ca_path)
+    {
+      /* fail only if ca file or ca path were supplied and looking into 
+         them fails. */
+      *error= SSL_INITERR_BAD_PATHS;
+      DBUG_PRINT("error", ("SSL_CTX_load_verify_locations failed : %s", 
+                 sslGetErrString(*error)));
+      report_errors();
+      SSL_CTX_free(ssl_fd->ssl_context);
+      my_free((void*)ssl_fd,MYF(0));
+      DBUG_RETURN(0);
+    }
+
+    /* otherwise go use the defaults */
     if (SSL_CTX_set_default_verify_paths(ssl_fd->ssl_context) == 0)
     {
       *error= SSL_INITERR_BAD_PATHS;



More information about the commits mailing list