[packages/percona-server/v5.1.x: 11/21] This commit was manufactured by cvs2git to create branch 'MYSQL_5_1'.

glen glen at pld-linux.org
Wed Oct 21 16:09:04 CEST 2015


commit 6a746021687cde674b9bba0d4a7a9d207efa1346
Author: cvs2git <feedback at pld-linux.org>
Date:   Fri Sep 16 19:29:57 2011 +0000

    This commit was manufactured by cvs2git to create branch 'MYSQL_5_1'.
    
    Sprout from unlabeled-1.1.2 2011-06-13 07:02:42 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- up to 5.1.57'
    Cherrypick from master 2010-12-14 16:24:03 UTC Elan Ruusamäe <glen at pld-linux.org> '- minor cosmetic: utf8 first':
        my.cnf -> 1.1
        mysql-acc-pslist.patch -> 1.7
        mysql-bug-34192.patch -> 1.2
        mysql-bug-43594.patch -> 1.3
        mysql-build.patch -> 1.1
        mysql-c++.patch -> 1.9
        mysql-client-config.patch -> 1.4
        mysql-client.conf -> 1.4
        mysql-clusters.conf -> 1.6
        mysql-config.patch -> 1.3
        mysql-fix-dummy-thread-race-condition.patch -> 1.2
        mysql-info.patch -> 1.5
        mysql-innodb_rw_lock.patch -> 1.2
        mysql-libwrap.patch -> 1.4
        mysql-microslow.patch -> 1.7
        mysql-ndb-cpc.init -> 1.4
        mysql-ndb-cpc.sysconfig -> 1.1
        mysql-ndb-mgm.init -> 1.4
        mysql-ndb-mgm.sysconfig -> 1.1
        mysql-ndb.init -> 1.4
        mysql-ndb.sysconfig -> 1.1
        mysql-noproc.patch -> 1.2
        mysql-sphinx.patch -> 1.7
        mysql-split_buf_pool_mutex_fixed_optimistic_safe.patch -> 1.2
        mysql-system-users.patch -> 1.4
        mysql-upgrade.patch -> 1.10
        mysql-userstats.patch -> 1.8
        mysql.logrotate -> 1.27
        mysql.sysconfig -> 1.20
        mysqld.conf -> 1.53
    Cherrypick from master 2011-09-08 18:24:15 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- rel 3; update percona patches':
        bug813587.patch -> 1.1
        response_time_distribution.patch -> 1.7
        slave_timeout_fix.patch -> 1.2
        utf8_general50_ci.patch -> 1.1
        xtradb_bug317074.patch -> 1.1
    Cherrypick from master 2010-12-16 09:53:58 UTC Elan Ruusamäe <glen at pld-linux.org> '- merged from MYSQL_5_1 branch (1.144.2.1)':
        mysql.init -> 1.145
    Cherrypick from unlabeled-1.2.2 2011-06-13 07:01:31 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- up to 5.1.57':
        mysql-innodb_dict_size_limit.patch -> 1.2.2.3
        mysql-innodb_extend_slow.patch -> 1.2.2.3
        mysql-innodb_extra_rseg.patch -> 1.2.2.3
        mysql-innodb_thread_concurrency_timer_based.patch -> 1.2.2.3
        mysql-profiling_slow.patch -> 1.2.2.3
        mysql-sql-cxx-pic.patch -> 1.2.2.1
        mysql-userstat.patch -> 1.2.2.3
    Cherrypick from unlabeled-1.1.4 2011-06-13 07:01:31 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- up to 5.1.57':
        mysql-innodb_io_patches.patch -> 1.1.4.3
        mysql-innodb_recovery_patches.patch -> 1.1.4.3
        mysql-show_patches.patch -> 1.1.4.3
    Cherrypick from unlabeled-1.3.2 2011-06-13 07:01:31 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- up to 5.1.57':
        mysql-innodb_split_buf_pool_mutex.patch -> 1.3.2.2
        mysql-microsec_process.patch -> 1.3.2.2
        plugin-avoid-version.patch -> 1.3.2.1
    Cherrypick from unlabeled-1.24.2 2010-12-17 11:45:06 UTC Elan Ruusamäe <glen at pld-linux.org> '- fix libmysqlclient linking after percona patches (missing -lrt for clock_gettime)':
        mysql-libs.patch -> 1.24.2.1
    Cherrypick from unlabeled-1.4.2 2011-03-13 16:02:03 UTC Elan Ruusamäe <glen at pld-linux.org> '- really update to 5.1.55':
        mysql-alpha.patch -> 1.4.2.2
    Cherrypick from unlabeled-1.496.2 2011-06-13 07:01:31 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- up to 5.1.57':
        mysql.spec -> 1.496.2.12
    Cherrypick from unlabeled-1.7.4.3.2 2011-09-16 19:29:57 UTC Arkadiusz Miśkiewicz <arekm at maven.pl> '- from head':
        percona.sh -> 1.7.4.3.2.1

 bug813587.patch                                    |   30 +
 my.cnf                                             |    2 +
 mysql-acc-pslist.patch                             |   80 +
 mysql-alpha.patch                                  |   10 +
 mysql-bug-34192.patch                              |   58 +
 mysql-bug-43594.patch                              |   30 +
 mysql-build.patch                                  |   12 +
 mysql-c++.patch                                    |   12 +
 mysql-client-config.patch                          |   33 +-
 mysql-client.conf                                  |    7 +
 mysql-clusters.conf                                |   10 +
 mysql-config.patch                                 |   30 +
 mysql-fix-dummy-thread-race-condition.patch        |   65 +
 mysql-info.patch                                   |   15 +
 mysql-innodb_dict_size_limit.patch                 |  497 +++
 mysql-innodb_extend_slow.patch                     |  963 +++++
 mysql-innodb_extra_rseg.patch                      |  395 ++
 mysql-innodb_io_patches.patch                      | 1520 +++++++
 mysql-innodb_recovery_patches.patch                |  522 +++
 mysql-innodb_rw_lock.patch                         | 1309 ++++++
 mysql-innodb_split_buf_pool_mutex.patch            | 4209 ++++++++++++++++++++
 mysql-innodb_thread_concurrency_timer_based.patch  |  201 +
 mysql-libs.patch                                   |   64 +
 mysql-libwrap.patch                                |    7 +-
 mysql-microsec_process.patch                       |   52 +
 mysql-microslow.patch                              |  699 ++++
 mysql-ndb-cpc.init                                 |   92 +
 mysql-ndb-cpc.sysconfig                            |    2 +
 mysql-ndb-mgm.init                                 |   92 +
 mysql-ndb-mgm.sysconfig                            |    2 +
 mysql-ndb.init                                     |   92 +
 mysql-ndb.sysconfig                                |    2 +
 mysql-noproc.patch                                 |   33 +
 mysql-profiling_slow.patch                         |  390 ++
 mysql-show_patches.patch                           |  297 ++
 mysql-sphinx.patch                                 |   33 +
 ...plit_buf_pool_mutex_fixed_optimistic_safe.patch | 1281 ++++++
 mysql-sql-cxx-pic.patch                            |   10 +
 mysql-system-users.patch                           |   34 +
 mysql-upgrade.patch                                |   31 +
 mysql-userstat.patch                               | 3488 ++++++++++++++++
 mysql-userstats.patch                              | 1466 +++++++
 mysql.init                                         |  652 +++
 mysql.logrotate                                    |   27 +
 mysql.spec                                         | 1234 ++++++
 mysql.sysconfig                                    |   27 +
 mysqld.conf                                        |  208 +
 percona.sh                                         |   88 +
 plugin-avoid-version.patch                         |  114 +
 response_time_distribution.patch                   | 3310 +++++++++++++++
 slave_timeout_fix.patch                            |   11 +
 utf8_general50_ci.patch                            |  440 ++
 xtradb_bug317074.patch                             |   58 +
 53 files changed, 24314 insertions(+), 32 deletions(-)
---
diff --git a/mysql.spec b/mysql.spec
new file mode 100644
index 0000000..97ef1c5
--- /dev/null
+++ b/mysql.spec
@@ -0,0 +1,1234 @@
+# TODO:
+# - http://bugs.mysql.com/bug.php?id=16470
+# - innodb are dynamic (= as plugins) ?
+# - missing have_archive, have_merge
+# - is plugin_dir lib64 safe?
+# - Using NDB Cluster... could not find sci transporter in /{include, lib}
+# - !!! Makefiles for libmysqld.so !!!
+# - segfaults on select from non-mysql user (caused by builder environment):
+#     https://bugs.launchpad.net/pld-linux/+bug/381904
+#     (profiling disabled temporaily to workaround this)
+#
+# Conditional build:
+%bcond_with	autodeps	# BR packages needed only for resolving deps
+%bcond_without	innodb		# InnoDB storage engine support
+%bcond_without	big_tables	# Support tables with more than 4G rows even on 32 bit platforms
+%bcond_without	federated	# Federated storage engine support
+%bcond_without	raid		# RAID support
+%bcond_without	ssl		# OpenSSL support
+%bcond_without	tcpd		# libwrap (tcp_wrappers) support
+%bcond_without	sphinx		# Sphinx storage engine support
+%bcond_with	tests		# FIXME: don't run correctly
+%bcond_with	ndb		# NDB is now a separate product, this here is broken, so disable it
+
+%include	/usr/lib/rpm/macros.perl
+Summary:	MySQL: a very fast and reliable SQL database engine
+Summary(de.UTF-8):	MySQL: ist eine SQL-Datenbank
+Summary(fr.UTF-8):	MySQL: un serveur SQL rapide et fiable
+Summary(pl.UTF-8):	MySQL: bardzo szybka i niezawodna baza danych (SQL)
+Summary(pt_BR.UTF-8):	MySQL: Um servidor SQL rápido e confiável
+Summary(ru.UTF-8):	MySQL - быстрый SQL-сервер
+Summary(uk.UTF-8):	MySQL - швидкий SQL-сервер
+Summary(zh_CN.UTF-8):	MySQL数据库服务器
+Name:		mysql
+Version:	5.1.57
+Release:	1
+License:	GPL + MySQL FLOSS Exception
+Group:		Applications/Databases
+#Source0Download: http://dev.mysql.com/downloads/mysql/5.1.html#source
+Source0:	http://vesta.informatik.rwth-aachen.de/mysql/Downloads/MySQL-5.1/%{name}-%{version}.tar.gz
+# Source0-md5:	8d6998ef0f2e2d1dac2a761348c71c21
+Source100:	http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
+# Source100-md5:	7b9b618cb9b378f949bb1b91ddcc4f54
+Source1:	%{name}.init
+Source2:	%{name}.sysconfig
+Source3:	%{name}.logrotate
+Source4:	%{name}d.conf
+Source5:	%{name}-clusters.conf
+Source7:	%{name}-ndb.init
+Source8:	%{name}-ndb.sysconfig
+Source9:	%{name}-ndb-mgm.init
+Source10:	%{name}-ndb-mgm.sysconfig
+Source11:	%{name}-ndb-cpc.init
+Source12:	%{name}-ndb-cpc.sysconfig
+Source13:	%{name}-client.conf
+Source14:	my.cnf
+Source15:	percona.sh
+Patch0:		%{name}-libs.patch
+Patch1:		%{name}-libwrap.patch
+Patch2:		%{name}-c++.patch
+Patch3:		%{name}-info.patch
+Patch4:		%{name}-sql-cxx-pic.patch
+Patch5:		%{name}-noproc.patch
+Patch6:		%{name}-system-users.patch
+Patch7:		%{name}-bug-34192.patch
+Patch8:		%{name}-client-config.patch
+Patch9:		%{name}-build.patch
+Patch10:	%{name}-alpha.patch
+Patch11:	%{name}-upgrade.patch
+Patch12:	%{name}-config.patch
+Patch13:	gcc-ice.patch
+Patch14:	%{name}-bug-43594.patch
+Patch15:	plugin-avoid-version.patch
+Patch16:	%{name}-fix-dummy-thread-race-condition.patch
+Patch18:	%{name}-sphinx.patch
+# <percona patches, http://www.percona.com/percona-lab.html>
+Patch100:	%{name}-innodb_swap_builtin_plugin.patch
+Patch101:	%{name}-show_patches.patch
+Patch102:	%{name}-slow_extended.patch
+Patch103:	%{name}-profiling_slow.patch
+Patch104:	%{name}-microsec_process.patch
+Patch105:	%{name}-userstat.patch
+Patch106:	%{name}-optimizer_fix.patch
+Patch107:	%{name}-show_temp_51.patch
+Patch108:	%{name}-suppress_log_warning_1592.patch
+Patch109:	%{name}-innodb_show_enhancements.patch
+Patch110:	%{name}-innodb_show_status.patch
+Patch111:	%{name}-innodb_io_patches.patch
+Patch112:	%{name}-innodb_opt_lru_count.patch
+Patch113:	%{name}-i_s_innodb_buffer_pool_pages.patch
+Patch114:	%{name}-innodb_expand_undo_slots.patch
+Patch115:	%{name}-innodb_extra_rseg.patch
+Patch116:	%{name}-innodb_overwrite_relay_log_info.patch
+Patch117:	%{name}-innodb_thread_concurrency_timer_based.patch
+Patch118:	%{name}-innodb_dict_size_limit.patch
+Patch119:	%{name}-innodb_split_buf_pool_mutex.patch
+Patch120:	%{name}-innodb_expand_import.patch
+Patch121:	%{name}-innodb_stats.patch
+Patch122:	%{name}-innodb_recovery_patches.patch
+Patch123:	%{name}-innodb_purge_thread.patch
+Patch124:	%{name}-innodb_admin_command_base.patch
+Patch125:	%{name}-innodb_show_lock_name.patch
+Patch126:	%{name}-innodb_extend_slow.patch
+Patch127:	%{name}-innodb_lru_dump_restore.patch
+Patch128:	%{name}-innodb_separate_doublewrite.patch
+Patch129:	%{name}-innodb_pass_corrupt_table.patch
+Patch130:	%{name}-innodb_fast_checksum.patch
+Patch131:	%{name}-innodb_files_extend.patch
+Patch132:	%{name}-innodb_show_sys_tables.patch
+Patch133:	%{name}-innodb_fix_misc.patch
+Patch134:	%{name}-innodb_adjust_defaults.patch
+Patch135:	%{name}-innodb_deadlock_count.patch
+Patch136:	%{name}-bug580324.patch
+Patch137:	%{name}-bugfix48929.patch
+Patch138:	%{name}-query_cache_enhance.patch
+Patch139:	%{name}-control_online_alter_index.patch
+Patch140:	%{name}-log_connection_error.patch
+Patch141:	%{name}-mysql-syslog.patch
+Patch142:	%{name}-innodb_buffer_pool_shm.patch
+Patch143:	%{name}-response-time-distribution.patch
+Patch144:	%{name}-error_pad.patch
+Patch145:	%{name}-remove_fcntl_excessive_calls.patch
+Patch146:	%{name}-sql_no_fcache.patch
+Patch147:	%{name}-show_slave_status_nolock.patch
+Patch148:	%{name}-innodb_fast_shutdown.patch
+Patch149:	%{name}-bug677407.patch
+Patch150:	%{name}-fix-bug671764.patch
+Patch151:	%{name}-mysql_remove_eol_carret.patch
+Patch152:	%{name}-innodb_expand_fast_index_creation.patch
+Patch153:	%{name}-innodb_bug60788.patch
+# </percona>
+URL:		http://www.mysql.com/products/community/
+BuildRequires:	autoconf
+BuildRequires:	automake
+BuildRequires:	bison
+BuildRequires:	groff
+%if "%{pld_release}" == "ac"
+BuildRequires:	libstdc++4-devel >= 5:4.0
+%else
+BuildRequires:	libstdc++-devel >= 5:4.0
+%endif
+BuildRequires:	libtool
+%{?with_tcpd:BuildRequires:	libwrap-devel}
+BuildRequires:	ncurses-devel >= 4.2
+%{?with_ssl:BuildRequires:	openssl-devel >= 0.9.7d}
+%{?with_autodeps:BuildRequires:	perl-DBI}
+BuildRequires:	perl-devel >= 1:5.6.1
+BuildRequires:	readline-devel >= 4.2
+BuildRequires:	rpm-perlprov >= 4.1-13
+BuildRequires:	rpmbuild(macros) >= 1.453
+BuildRequires:	sed >= 4.0
+BuildRequires:	zlib-devel
+Requires(post,preun):	/sbin/chkconfig
+Requires(postun):	/usr/sbin/groupdel
+Requires(postun):	/usr/sbin/userdel
+Requires(pre):	/bin/id
+Requires(pre):	/usr/bin/getgid
+Requires(pre):	/usr/sbin/groupadd
+Requires(pre):	/usr/sbin/useradd
+Requires(triggerpostun):	sed >= 4.0
+Requires:	%{name}-charsets = %{version}-%{release}
+Requires:	%{name}-libs = %{version}-%{release}
+Requires:	/usr/bin/setsid
+Requires:	rc-scripts >= 0.2.0
+Suggests:	mysql-client
+%{?with_tcpd:Suggests:	tcp_wrappers}
+Suggests:	vim-syntax-mycnf
+Provides:	MySQL-server
+Provides:	group(mysql)
+Provides:	msqlormysql
+Provides:	user(mysql)
+Obsoletes:	MySQL
+Obsoletes:	mysql-server
+Conflicts:	logrotate < 3.7-4
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%define		_libexecdir	%{_sbindir}
+%define		_localstatedir	/var/lib/mysql
+%define		_mysqlhome	/home/services/mysql
+
+%define		_noautoreqdep	perl(DBD::mysql)
+
+# readline/libedit detection goes wrong
+%undefine	configure_cache
+
+%description
+MySQL is a true multi-user, multi-threaded SQL (Structured Query
+Language) database server. SQL is the most popular database language
+in the world. MySQL is a client/server implementation that consists of
+a server daemon mysqld and many different client programs/libraries.
+
+The main goals of MySQL are speed, robustness and easy to use. MySQL
+was originally developed because we at Tcx needed a SQL server that
+could handle very big databases with magnitude higher speed than what
+any database vendor could offer to us. We have now been using MySQL
+since 1996 in a environment with more than 40 databases, 10,000
+tables, of which more than 500 have more than 7 million rows. This is
+about 50G of mission critical data.
+
+The base upon which MySQL is built is a set of routines that have been
+used in a highly demanding production environment for many years.
+While MySQL is still in development, it already offers a rich and
+highly useful function set.
+
+%description -l fr.UTF-8
+MySQL est un serveur de bases de donnees SQL vraiment multi-usagers et
+multi-taches. Le langage SQL est le langage de bases de donnees le
+plus populaire au monde. MySQL est une implementation client/serveur
+qui consiste en un serveur (mysqld) et differents
+programmes/bibliotheques clientes.
+
+Les objectifs principaux de MySQL sont: vitesse, robustesse et
+facilite d'utilisation. MySQL fut originalement developpe parce que
+nous, chez Tcx, avions besoin d'un serveur SQL qui pouvait gerer de
+tres grandes bases de donnees avec une vitesse d'un ordre de magnitude
+superieur a ce que n'importe quel vendeur pouvait nous offrir. Nous
+utilisons MySQL depuis 1996 dans un environnement avec plus de 40
+bases de donnees, 10000 tables, desquelles plus de 500 ont plus de 7
+millions de lignes. Ceci represente environ 50G de donnees critiques.
+
+A la base de la conception de MySQL, on retrouve une serie de routines
+qui ont ete utilisees dans un environnement de production pendant
+plusieurs annees. Meme si MySQL est encore en developpement, il offre
+deja une riche et utile serie de fonctions.
+
+%description -l pl.UTF-8
+MySQL to prawdziwie wieloużytkownikowy, wielowątkowy serwer baz danych
+SQL. SQL jest najpopularniejszym na świecie językiem używanym do baz
+danych. MySQL to implementacja klient/serwer składająca się z demona
+mysqld i wielu różnych programów i bibliotek klienckich.
+
+Głównymi celami MySQL-a są szybkość, potęga i łatwość użytkowania.
+MySQL oryginalnie był tworzony, ponieważ autorzy w Tcx potrzebowali
+serwera SQL do obsługi bardzo dużych baz danych z szybkością o wiele
+większą, niż mogli zaoferować inni producenci baz danych. Używają go
+od 1996 roku w środowisku z ponad 40 bazami danych, 10 000 tabel, z
+których ponad 500 zawiera ponad 7 milionów rekordów - w sumie około
+50GB krytycznych danych.
+
+Baza, na której oparty jest MySQL, składa się ze zbioru procedur,
+które były używane w bardzo wymagającym środowisku produkcyjnym przez
+wiele lat. Pomimo, że MySQL jest ciągle rozwijany, już oferuje bogaty
+i użyteczny zbiór funkcji.
+
+%description -l de.UTF-8
+MySQL ist eine SQL-Datenbank. Allerdings ist sie im Gegensatz zu
+Oracle, DB2 oder PostgreSQL keine relationale Datenbank. Die Daten
+werden zwar in zweidimensionalen Tabellen gespeichert und können mit
+einem Primärschlüssel versehen werden. Es ist aber keine Definition
+eines Fremdschlüssels möglich. Der Benutzer ist somit bei einer
+MySQL-Datenbank völlig allein für die (referenzielle) Integrität der
+Daten verantwortlich. Allein durch die Nutzung externer
+Tabellenformate, wie InnoDB bzw Berkeley DB wird eine Relationalität
+ermöglicht. Diese Projekte sind aber getrennt von MySQL zu betrachten.
+
+%description -l pt_BR.UTF-8
+O MySQL é um servidor de banco de dados SQL realmente multiusuário e
+multi-tarefa. A linguagem SQL é a mais popular linguagem para banco de
+dados no mundo. O MySQL é uma implementação cliente/servidor que
+consiste de um servidor chamado mysqld e diversos
+programas/bibliotecas clientes. Os principais objetivos do MySQL são:
+velocidade, robustez e facilidade de uso. O MySQL foi originalmente
+desenvolvido porque nós na Tcx precisávamos de um servidor SQL que
+pudesse lidar com grandes bases de dados e com uma velocidade muito
+maior do que a que qualquer vendedor podia nos oferecer. Estamos
+usando o MySQL desde 1996 em um ambiente com mais de 40 bases de dados
+com 10.000 tabelas, das quais mais de 500 têm mais de 7 milhões de
+linhas. Isto é o equivalente a aproximadamente 50G de dados críticos.
+A base da construção do MySQL é uma série de rotinas que foram usadas
+em um ambiente de produção com alta demanda por muitos anos. Mesmo o
+MySQL estando ainda em desenvolvimento, ele já oferece um conjunto de
+funções muito ricas e úteis. Veja a documentação para maiores
+informações.
+
+%description -l ru.UTF-8
+MySQL - это SQL (Structured Query Language) сервер базы данных. MySQL
+была написана Michael'ом (monty) Widenius'ом. См. файл CREDITS в
+дистрибутиве на предмет других участников проекта и прочей информации
+о MySQL.
+
+%description -l uk.UTF-8
+MySQL - це SQL (Structured Query Language) сервер бази даних. MySQL
+було написано Michael'ом (monty) Widenius'ом. Див. файл CREDITS в
+дистрибутиві для інформації про інших учасників проекту та іншої
+інформації.
+
+%package charsets
+Summary:	MySQL - character sets definitions
+Summary(pl.UTF-8):	MySQL - definicje kodowań znaków
+Group:		Applications/Databases
+
+%description charsets
+This package contains character sets definitions needed by both client
+and server.
+
+%description charsets -l pl.UTF-8
+Ten pakiet zawiera definicje kodowań znaków potrzebne dla serwera i
+klienta.
+
+%package -n mysqlhotcopy
+Summary:	mysqlhotcopy - A MySQL database backup program
+Summary(pl.UTF-8):	mysqlhotcopy - program do tworzenia kopii zapasowych baz MySQL
+Group:		Applications/Databases
+Requires:	perl-DBD-mysql
+
+%description -n mysqlhotcopy
+mysqlhotcopy uses LOCK TABLES, FLUSH TABLES, and cp or scp to make a
+database backup quickly. It is the fastest way to make a backup of the
+database or single tables, but it can be run only on the same machine
+where the database directories are located. mysqlhotcopy works only
+for backing up MyISAM and ARCHIVE tables.
+
+See innobackup package to backup InnoDB tables.
+
+%description -n mysqlhotcopy -l pl.UTF-8
+mysqlhotcopy wykorzystuje LOCK TABLES, FLUSH TABLES oraz cp i scp do
+szybkiego tworzenia kopii zapasowych baz danych. Jest to najszybszy
+sposób wykonania kopii zapasowej bazy danych lub pojedynczych tabel,
+ale może działać tylko na maszynie, na której znajdują się katalogi z
+bazą danych. mysqlhotcopy działa tylko dla tabel typu MyISAM i
+ARCHIVE.
+
+Narzędzie do tworzenia kopii tabel InnoDB znajduje się w pakiecie
+innobackup.
+
+%package extras
+Summary:	MySQL additional utilities
+Summary(pl.UTF-8):	Dodatkowe narzędzia do MySQL
+Group:		Applications/Databases
+Requires:	%{name}-libs = %{version}-%{release}
+
+%description extras
+MySQL additional utilities except Perl scripts (they may be found in
+%{name}-extras-perl package).
+
+%description extras -l pl.UTF-8
+Dodatkowe narzędzia do MySQL - z wyjątkiem skryptów Perla (które są w
+pakiecie %{name}-extras-perl).
+
+%package extras-perl
+Summary:	MySQL additional utilities written in Perl
+Summary(pl.UTF-8):	Dodatkowe narzędzia do MySQL napisane w Perlu
+Group:		Applications/Databases
+Requires:	%{name}-extras = %{version}-%{release}
+# this is just for the sake of smooth upgrade, not to break systems
+Requires:	mysqlhotcopy = %{version}-%{release}
+Requires:	perl(DBD::mysql)
+
+%description extras-perl
+MySQL additional utilities written in Perl.
+
+%description extras-perl -l pl.UTF-8
+Dodatkowe narzędzia do MySQL napisane w Perlu.
+
+%package client
+Summary:	MySQL - Client
+Summary(pl.UTF-8):	MySQL - Klient
+Summary(pt.UTF-8):	MySQL - Cliente
+Summary(ru.UTF-8):	MySQL клиент
+Summary(uk.UTF-8):	MySQL клієнт
+Group:		Applications/Databases
+Requires:	%{name}-charsets = %{version}-%{release}
+Requires:	%{name}-libs = %{version}-%{release}
+Obsoletes:	MySQL-client
+
+%description client
+This package contains the standard MySQL clients.
+
+%description client -l fr.UTF-8
+Ce package contient les clients MySQL standards.
+
+%description client -l pl.UTF-8
+Standardowe programy klienckie MySQL.
+
+%description client -l pt_BR.UTF-8
+Este pacote contém os clientes padrão para o MySQL.
+
+%description client -l ru.UTF-8
+Этот пакет содержит только клиент MySQL.
+
+%description client -l uk.UTF-8
+Цей пакет містить тільки клієнта MySQL.
+
+%package libs
+Summary:	Shared libraries for MySQL
+Summary(pl.UTF-8):	Biblioteki współdzielone MySQL
+Group:		Libraries
+Obsoletes:	libmysql10
+Obsoletes:	mysql-doc < 4.1.12
+
+%description libs
+Shared libraries for MySQL.
+
+%description libs -l pl.UTF-8
+Biblioteki współdzielone MySQL.
+
+%package devel
+Summary:	MySQL - development header files and other files
+Summary(pl.UTF-8):	MySQL - Pliki nagłówkowe i inne dla programistów
+Summary(pt.UTF-8):	MySQL - Medições de desempenho
+Summary(ru.UTF-8):	MySQL - хедеры и библиотеки разработчика
+Summary(uk.UTF-8):	MySQL - хедери та бібліотеки програміста
+Group:		Development/Libraries
+Requires:	%{name}-libs = %{version}-%{release}
+%{?with_ssl:Requires:	openssl-devel}
+Requires:	zlib-devel
+Obsoletes:	MySQL-devel
+Obsoletes:	libmysql10-devel
+
+%description devel
+This package contains the development header files and other files
+necessary to develop MySQL client applications.
+
+%description devel -l fr.UTF-8
+Ce package contient les fichiers entetes et les librairies de
+developpement necessaires pour developper des applications clientes
+MySQL.
+
+%description devel -l pl.UTF-8
+Pliki nagłówkowe i inne pliki konieczne do kompilacji aplikacji
+klienckich MySQL.
+
+%description devel -l pt_BR.UTF-8
+Este pacote contém os arquivos de cabeçalho (header files) e
+bibliotecas necessárias para desenvolver aplicações clientes do MySQL.
+
+%description devel -l ru.UTF-8
+Этот пакет содержит хедеры и библиотеки разработчика, необходимые для
+разработки клиентских приложений.
+
+%description devel -l uk.UTF-8
+Цей пакет містить хедери та бібліотеки програміста, необхідні для
+розробки програм-клієнтів.
+
+%package static
+Summary:	MySQL static libraries
+Summary(pl.UTF-8):	Biblioteki statyczne MySQL
+Summary(ru.UTF-8):	MySQL - статические библиотеки
+Summary(uk.UTF-8):	MySQL - статичні бібліотеки
+Group:		Development/Libraries
+Requires:	%{name}-devel = %{version}-%{release}
+Obsoletes:	MySQL-static
+
+%description static
+MySQL static libraries.
+
+%description static -l pl.UTF-8
+Biblioteki statyczne MySQL.
+
+%description static -l ru.UTF-8
+Этот пакет содержит статические библиотеки разработчика, необходимые
+для разработки клиентских приложений.
+
+%description static -l uk.UTF-8
+Цей пакет містить статичні бібліотеки програміста, необхідні для
+розробки програм-клієнтів.
+
+%package bench
+Summary:	MySQL - Benchmarks
+Summary(pl.UTF-8):	MySQL - Programy testujące szybkość działania bazy
+Summary(pt.UTF-8):	MySQL - Medições de desempenho
+Summary(ru.UTF-8):	MySQL - бенчмарки
+Summary(uk.UTF-8):	MySQL - бенчмарки
+Group:		Applications/Databases
+Requires:	%{name} = %{version}-%{release}
+Requires:	%{name}-client
+Requires:	perl(DBD::mysql)
+Obsoletes:	MySQL-bench
+
+%description bench
+This package contains MySQL benchmark scripts and data.
+
+%description bench -l pl.UTF-8
+Programy testujące szybkość serwera MySQL.
+
+%description bench -l pt_BR.UTF-8
+Este pacote contém medições de desempenho de scripts e dados do MySQL.
+
+%description bench -l ru.UTF-8
+Этот пакет содержит скрипты и данные для оценки производительности
+MySQL.
+
+%description bench -l uk.UTF-8
+Цей пакет містить скрипти та дані для оцінки продуктивності MySQL.
+
+%package doc
+Summary:	MySQL manual
+Summary(pl.UTF-8):	Podręcznik użytkownika MySQL
+Group:		Applications/Databases
+
+%description doc
+This package contains manual in HTML format.
+
+%description doc -l pl.UTF-8
+Podręcznik MySQL-a w formacie HTML.
+
+%package ndb
+Summary:	MySQL - NDB Storage Engine Daemon
+Summary(pl.UTF-8):	MySQL - demon silnika przechowywania danych NDB
+Group:		Applications/Databases
+Requires:	%{name}-libs = %{version}-%{release}
+
+%description ndb
+This package contains the standard MySQL NDB Storage Engine Daemon.
+
+%description ndb -l pl.UTF-8
+Ten pakiet zawiera standardowego demona silnika przechowywania danych
+NDB.
+
+%package ndb-client
+Summary:	MySQL - NDB Clients
+Summary(pl.UTF-8):	MySQL - programy klienckie NDB
+Group:		Applications/Databases
+Requires:	%{name}-libs = %{version}-%{release}
+
+%description ndb-client
+This package contains the standard MySQL NDB Clients.
+
+%description ndb-client -l pl.UTF-8
+Ten pakiet zawiera standardowe programy klienckie MySQL NDB.
+
+%package ndb-mgm
+Summary:	MySQL - NDB Management Daemon
+Summary(pl.UTF-8):	MySQL - demon zarządzający NDB
+Group:		Applications/Databases
+Requires:	%{name}-libs = %{version}-%{release}
+
+%description ndb-mgm
+This package contains the standard MySQL NDB Management Daemon.
+
+%description ndb-mgm -l pl.UTF-8
+Ten pakiet zawiera standardowego demona zarządzającego MySQL NDB.
+
+%package ndb-cpc
+Summary:	MySQL - NDB CPC Daemon
+Summary(pl.UTF-8):	MySQL - demon NDB CPC
+Group:		Applications/Databases
+Requires:	%{name}-libs = %{version}-%{release}
+
+%description ndb-cpc
+This package contains the standard MySQL NDB CPC Daemon.
+
+%description ndb-cpc -l pl.UTF-8
+Ten pakiet zawiera standardowego demona MySQL NDB CPC.
+
+%prep
+%setup -q %{?with_sphinx:-a100}
+%if %{with sphinx}
+# http://www.sphinxsearch.com/docs/manual-0.9.9.html#sphinxse-mysql51
+mv sphinx-*/mysqlse storage/sphinx
+%patch18 -p1
+%endif
+%patch0 -p1
+#%{?with_tcpd:%patch1 -p1}  # WHATS PURPOSE OF THIS PATCH?
+#%patch2 -p1 # NEEDS CHECK, which exact program needs -lc++
+%patch3 -p1
+%ifarch alpha
+# this is strange: mysqld functions for UDF modules are not explicitly defined,
+# so -rdynamic is used; in such case gcc3+ld on alpha doesn't like C++ vtables
+# in objects compiled without -fPIC
+%patch4 -p1
+# gcc 3.3.x ICE
+%patch10 -p1
+%endif
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%patch11 -p1
+%patch12 -p1
+%if "%{cc_version}" < "3.4"
+%patch13 -p1
+%endif
+%patch14 -p0
+%patch15 -p1
+%patch16 -p1
+# <percona %patches>
+%patch100 -p1
+%patch101 -p1
+%patch102 -p1
+%patch103 -p1
+%patch104 -p1
+%patch105 -p1
+%patch106 -p1
+%patch107 -p1
+%patch108 -p1
+%patch109 -p1
+%patch110 -p1
+%patch111 -p1
+%patch112 -p1
+%patch113 -p1
+%patch114 -p1
+%patch115 -p1
+%patch116 -p1
+%patch117 -p1
+%patch118 -p1
+%patch119 -p1
+%patch120 -p1
+%patch121 -p1
+%patch122 -p1
+%patch123 -p1
+%patch124 -p1
+%patch125 -p1
+%patch126 -p1
+%patch127 -p1
+%patch128 -p1
+%patch129 -p1
+%patch130 -p1
+%patch131 -p1
+%patch132 -p1
+%patch133 -p1
+%patch134 -p1
+%patch135 -p1
+%patch136 -p1
+%patch137 -p1
+%patch138 -p1
+%patch139 -p1
+%patch140 -p1
+%patch141 -p1
+%patch142 -p1
+%patch143 -p1
+%patch144 -p1
+%patch145 -p1
+%patch146 -p1
+%patch147 -p1
+%patch148 -p1
+%patch149 -p1
+%patch150 -p1
+%patch151 -p1
+%patch152 -p1
+%patch153 -p1
+# </percona>
+
+%build
+%if "%{pld_release}" == "ac"
+# add suffix, but allow ccache, etc in ~/.rpmmacros
+%{expand:%%define	__cc	%(echo '%__cc' | sed -e 's,-gcc,-gcc4,')}
+%{expand:%%define	__cxx	%(echo '%__cxx' | sed -e 's,-g++,-g++4,')}
+%{expand:%%define	__cpp	%(echo '%__cpp' | sed -e 's,-gcc,-gcc4,')}
+%endif
+
+%{__libtoolize}
+%{__aclocal} -I config/ac-macros
+%{__automake}
+%{__autoconf}
+
+# The compiler flags are as per their "official" spec ;)
+CXXFLAGS="%{rpmcxxflags} -fPIC -fno-implicit-templates -fno-rtti -fno-exceptions"
+CFLAGS="%{rpmcflags} -fPIC"
+CPPFLAGS="%{rpmcppflags}"
+
+# NOTE: the PS, FIND_PROC, KILL, CHECK_PID are not used by PLD Linux
+# and therefore do not add BR on these. These are here just to satisfy
+# configure.
+
+%configure \
+	PS='/bin/ps' \
+	FIND_PROC='/bin/ps p $$PID' \
+	KILL='/bin/kill' \
+	CHECK_PID='/bin/kill -0 $$PID' \
+	--enable-assembler \
+	--enable-largefile=yes \
+	--enable-shared \
+	--enable-static \
+	--enable-thread-safe-client \
+	--with%{!?with_ssl:out}-ssl=/usr \
+	--with%{!?with_tcpd:out}-libwrap \
+	%{?with_big_tables:--with-big-tables} \
+	--with-comment="PLD Linux Distribution MySQL RPM" \
+	--with%{!?debug:out}-debug%{?debug:=full} \
+	--with-embedded-server \
+	--with-extra-charsets=all \
+	--with-low-memory \
+	--with-mysqld-user=mysql \
+	--with-named-curses-libs="-lncurses" \
+	--with-named-thread-libs="-lpthread" \
+	--with-unix-socket-path=/var/lib/mysql/mysql.sock \
+	--with-plugins=max \
+	--with-fast-mutexes \
+	--without-readline \
+	--without-libedit \
+%if %{with ndb}
+	--with%{!?debug:out}-ndb-debug \
+	--with-ndbcluster \
+	--with-ndb-docs \
+%else
+	--without-plugin-ndbcluster \
+%endif
+	--with-docs
+
+#--with-error-inject
+
+# NOTE that /var/lib/mysql/mysql.sock is symlink to real sock file
+# (it defaults to first cluster but user may change it to whatever
+# cluster it wants)
+
+echo -e "all:\ninstall:\nclean:\nlink_sources:\n" > libmysqld/examples/Makefile
+
+%{__make} \
+	benchdir=$RPM_BUILD_ROOT%{_datadir}/sql-bench
+
+%{__make} -C Docs mysql.info
+
+%{?with_tests:%{__make} test}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT/etc/{logrotate.d,rc.d/init.d,sysconfig,mysql,skel} \
+	   $RPM_BUILD_ROOT/var/{log/{archive,}/mysql,lib/mysql} \
+	   $RPM_BUILD_ROOT{%{_infodir},%{_mysqlhome}}
+
+# Make install
+%{__make} install \
+	DESTDIR=$RPM_BUILD_ROOT \
+	benchdir=%{_datadir}/sql-bench \
+	libsdir=/tmp
+# libsdir is to avoid installing innodb static libs in $RPM_BUILD_ROOT../libs
+
+install Docs/mysql.info $RPM_BUILD_ROOT%{_infodir}
+
+install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/mysql
+install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/mysql
+install %{SOURCE3} $RPM_BUILD_ROOT/etc/logrotate.d/mysql
+# This is template for configuration file which is created after 'service mysql init'
+install %{SOURCE4} mysqld.conf
+install %{SOURCE5} $RPM_BUILD_ROOT%{_sysconfdir}/mysql/clusters.conf
+touch $RPM_BUILD_ROOT/var/log/mysql/{mysqld,query,slow}.log
+
+# remove innodb directives from mysqld.conf if mysqld is configured without
+%if %{without innodb}
+	cp mysqld.conf mysqld.tmp
+	awk 'BEGIN { RS="\n\n" } !/innodb/ { printf("%s\n\n", $0) }' < mysqld.tmp > mysqld.conf
+%endif
+
+# remove berkeley-db directives from mysqld.conf if mysqld is configured without
+cp mysqld.conf mysqld.tmp
+awk 'BEGIN { RS="\n\n" } !/bdb/ { printf("%s\n\n", $0) }' < mysqld.tmp > mysqld.conf
+
+install mysqld.conf $RPM_BUILD_ROOT%{_datadir}/mysql/mysqld.conf
+cp -a %{SOURCE13} $RPM_BUILD_ROOT%{_sysconfdir}/mysql/mysql-client.conf
+cp -a %{SOURCE14} $RPM_BUILD_ROOT/etc/skel/.my.cnf
+
+# NDB
+%if %{with ndb}
+install %{SOURCE7} $RPM_BUILD_ROOT/etc/rc.d/init.d/mysql-ndb
+install %{SOURCE8} $RPM_BUILD_ROOT/etc/sysconfig/mysql-ndb
+install %{SOURCE9} $RPM_BUILD_ROOT/etc/rc.d/init.d/mysql-ndb-mgm
+install %{SOURCE10} $RPM_BUILD_ROOT/etc/sysconfig/mysql-ndb-mgm
+install %{SOURCE11} $RPM_BUILD_ROOT/etc/rc.d/init.d/mysql-ndb-cpc
+install %{SOURCE12} $RPM_BUILD_ROOT/etc/sysconfig/mysql-ndb-cpc
+%endif
+
+mv -f $RPM_BUILD_ROOT%{_libdir}/mysql/lib* $RPM_BUILD_ROOT%{_libdir}
+sed -i -e 's,%{_libdir}/mysql,%{_libdir},' $RPM_BUILD_ROOT{%{_libdir}/libmysqlclient{,_r}.la,%{_bindir}/mysql_config}
+sed -i -e '/libs/s/$ldflags//' $RPM_BUILD_ROOT%{_bindir}/mysql_config
+
+# remove known unpackaged files
+rm -rf $RPM_BUILD_ROOT%{_prefix}/mysql-test
+
+# remove .txt variants for .sys messages
+rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/*/*.txt
+
+# rename not to be so generic name
+mv $RPM_BUILD_ROOT%{_bindir}/{,mysql_}resolve_stack_dump
+mv $RPM_BUILD_ROOT%{_mandir}/man1/{,mysql_}resolve_stack_dump.1
+
+# not useful without -debug build
+%{!?debug:rm -f $RPM_BUILD_ROOT%{_bindir}/mysql_resolve_stack_dump}
+%{!?debug:rm -f $RPM_BUILD_ROOT%{_mandir}/man1/mysql_resolve_stack_dump.1}
+# generate symbols file, so one can generate backtrace using it
+# mysql_resolve_stack_dump -s %{_datadir}/mysql/mysqld.sym -n mysqld.stack.
+# http://dev.mysql.com/doc/refman/5.0/en/using-stack-trace.html
+%{?debug:nm -n $RPM_BUILD_ROOT%{_sbindir}/mysqld > $RPM_BUILD_ROOT%{_datadir}/mysql/mysqld.sym}
+
+# do not clobber users $PATH
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/mysql_upgrade
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/innochecksum
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/myisamchk
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/myisamlog
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/myisampack
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/mysql_fix_privilege_tables
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/my_print_defaults
+sed -i -e 's#/usr/bin/my_print_defaults#%{_sbindir}/my_print_defaults#g' $RPM_BUILD_ROOT%{_bindir}/mysql_install_db
+mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/mysqlcheck
+
+# delete - functionality in initscript / rpm
+# mysql_install_db is needed by digikam
+#rm $RPM_BUILD_ROOT%{_bindir}/mysql_install_db
+#rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql_install_db.1*
+rm $RPM_BUILD_ROOT%{_bindir}/mysqld_safe
+rm $RPM_BUILD_ROOT%{_bindir}/mysqld_multi
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysqld_{multi,safe}*
+rm $RPM_BUILD_ROOT%{_datadir}/%{name}/mysql-log-rotate
+rm $RPM_BUILD_ROOT%{_datadir}/%{name}/mysql.server
+rm $RPM_BUILD_ROOT%{_datadir}/%{name}/binary-configure
+rm $RPM_BUILD_ROOT%{_datadir}/%{name}/errmsg.txt
+rm $RPM_BUILD_ROOT%{_bindir}/mysql_waitpid
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql_waitpid.1*
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql.server*
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysqlman.1*
+rm $RPM_BUILD_ROOT%{_bindir}/resolveip
+rm $RPM_BUILD_ROOT%{_mandir}/man1/resolveip.1*
+rm $RPM_BUILD_ROOT%{_mandir}/man1/comp_err.1*
+rm $RPM_BUILD_ROOT%{_datadir}/mysql/ChangeLog
+
+# we don't package those (we have no -test or -testsuite pkg) and some of them just segfault
+rm $RPM_BUILD_ROOT%{_bindir}/mysql_client_test
+rm $RPM_BUILD_ROOT%{_datadir}/mysql/mi_test_all
+rm $RPM_BUILD_ROOT%{_datadir}/mysql/mi_test_all.res
+rm $RPM_BUILD_ROOT%{_datadir}/mysql/mysqld_multi.server
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql_client_test.1*
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql_client_test_embedded.1*
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql-stress-test.pl.1*
+rm $RPM_BUILD_ROOT%{_mandir}/man1/mysql-test-run.pl.1*
+
+# in %doc
+rm $RPM_BUILD_ROOT%{_datadir}/%{name}/*.{ini,cnf}
+
+# not needed
+rm -f $RPM_BUILD_ROOT%{_libdir}/mysql/plugin/ha_*.{a,la}
+rm -f $RPM_BUILD_ROOT%{_libdir}/mysql/plugin/ha_example.*
+rm -f $RPM_BUILD_ROOT%{_libdir}/mysql/plugin/sphinx.{a,la}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+%groupadd -g 89 mysql
+%useradd -u 89 -d %{_mysqlhome} -s /bin/sh -g mysql -c "MySQL Server" mysql
+
+%post
+[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>&1
+/sbin/chkconfig --add mysql
+%service mysql restart
+
+%preun
+if [ "$1" = "0" ]; then
+	%service -q mysql stop
+	/sbin/chkconfig --del mysql
+fi
+
+%postun
+[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>&1
+
+if [ "$1" = "0" ]; then
+	%userremove mysql
+	%groupremove mysql
+fi
+
+%post ndb
+/sbin/chkconfig --add mysql-ndb
+%service mysql-ndb restart "mysql NDB engine"
+
+%preun ndb
+if [ "$1" = "0" ]; then
+	%service mysql-ndb stop
+	/sbin/chkconfig --del mysql-ndb
+fi
+
+%post ndb-mgm
+/sbin/chkconfig --add mysql-ndb-mgm
+%service mysql-ndb-mgm restart "mysql NDB management node"
+
+%preun ndb-mgm
+if [ "$1" = "0" ]; then
+	%service mysql-ndb-mgm stop
+	/sbin/chkconfig --del mysql-ndb-mgm
+fi
+
+%post ndb-cpc
+/sbin/chkconfig --add mysql-ndb-cpc
+%service mysql-ndb-cpc restart "mysql NDB CPC"
+
+%preun ndb-cpc
+if [ "$1" = "0" ]; then
+	%service mysql-ndb-cpc stop
+	/sbin/chkconfig --del mysql-ndb-cpc
+fi
+
+%post   libs -p /sbin/ldconfig
+%postun libs -p /sbin/ldconfig
+
+%triggerpostun -- mysql < 4.0.20-2.4
+# For clusters in /etc/%{name}/clusters.conf
+if [ -f /etc/sysconfig/mysql ]; then
+	. /etc/sysconfig/mysql
+	if [ -n "$MYSQL_DB_CLUSTERS" ]; then
+		for i in "$MYSQL_DB_CLUSTERS"; do
+			echo "$i/mysqld.conf=$i" >> /etc/%{name}/clusters.conf
+		done
+		echo "# Do not use **obsolete** option MYSQL_DB_CLUSTERS" >> /etc/sysconfig/mysql
+		echo "# USE /etc/%{name}/clusters.conf instead" >> /etc/sysconfig/mysql
+		echo "Converted clusters from MYSQL_DB_CLUSTERS to /etc/%{name}/clusters.conf."
+		echo "You NEED to fix your /etc/sysconfig/mysql and verify /etc/%{name}/clusters.conf."
+	fi
+fi
+
+%triggerpostun -- mysql < 4.1.1
+# For better compatibility with prevoius versions:
+for config in $(awk -F= '!/^#/ && /=/{print $1}' /etc/%{name}/clusters.conf); do
+	if echo "$config" | grep -q '^/'; then
+		config_file="$config"
+	elif [ -f "/etc/%{name}/$config" ]; then
+		config_file=/etc/%{name}/$config
+	else
+		clusterdir=$(awk -F= "/^$config/{print \$2}" /etc/%{name}/clusters.conf)
+		if [ -z "$clusterdir" ]; then
+			echo >&2 "Can't find cluster dir for $config!"
+			echo >&2 "Please remove extra (leading) spaces from /etc/%{name}/clusters.conf"
+			exit 1
+		fi
+		config_file="$clusterdir/mysqld.conf"
+	fi
+
+	if [ ! -f "$config_file" ]; then
+			echo >&2 "Lost myself! Please report this (with above errors, if any) to http://bugs.pld-linux.org/"
+			exit 1
+	fi
+	echo "Adding option old-passwords to config: $config_file"
+	echo "If you want to use new, better passwords - remove it"
+
+	# sed magic to add 'old-passwords' to [mysqld] section
+	sed -i -e '/./{H;$!d;};x;/\[mysqld\]/{
+		a
+		a; Compatibility options:
+		aold-passwords
+	}
+	' $config_file
+done
+
+%banner -e %{name}-4.1.x <<-EOF
+	If you want to use new help tables in MySQL 4.1.x then You'll need to import the help data:
+	mysql -u mysql mysql < %{_datadir}/%{name}/fill_help_tables.sql
+EOF
+#'
+
+%triggerpostun -- mysql < 5.1.0
+configs=""
+for config in $(awk -F= '!/^#/ && /=/{print $1}' /etc/%{name}/clusters.conf); do
+	if echo "$config" | grep -q '^/'; then
+		config_file="$config"
+	elif [ -f "/etc/%{name}/$config" ]; then
+		config_file=/etc/%{name}/$config
+	else
+		clusterdir=$(awk -F= "/^$config/{print \$2}" /etc/%{name}/clusters.conf)
+		if [ -z "$clusterdir" ]; then
+			echo >&2 "Can't find cluster dir for $config!"
+			echo >&2 "Please remove extra (leading) spaces from /etc/%{name}/clusters.conf"
+			exit 1
+		fi
+		config_file="$clusterdir/mysqld.conf"
+	fi
+
+	if [ ! -f "$config_file" ]; then
+		echo >&2 "ERROR: Can't find real config file for $config! Please report this (with above errors, if any) to http://bugs.pld-linux.org/"
+		continue
+	fi
+	configs="$configs $config_file"
+done
+
+(
+echo 'You should run MySQL upgrade script *after* restarting MySQL server for all MySQL clusters.'
+echo 'Thus, you should invoke:'
+for config in $configs; do
+	sed -i -e '
+		#set-variable\s*=\s* ##
+	' $config
+
+	datadir=$(awk -F= '!/^#/ && $1 ~ /datadir/{print $2}' $config | xargs)
+	echo "# mysql_upgrade --datadir=$datadir"
+done
+) | %banner -e %{name}-5.1
+
+%files
+%defattr(644,root,root,755)
+%doc support-files/*.cnf support-files/*.ini ChangeLog
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/mysql
+%attr(754,root,root) /etc/rc.d/init.d/mysql
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/mysql
+%attr(640,root,mysql) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mysql/clusters.conf
+%attr(755,root,root) %{_sbindir}/innochecksum
+%attr(755,root,root) %{_sbindir}/my_print_defaults
+%attr(755,root,root) %{_sbindir}/myisamchk
+%attr(755,root,root) %{_sbindir}/myisamlog
+%attr(755,root,root) %{_sbindir}/myisampack
+%attr(755,root,root) %{_sbindir}/mysql_fix_privilege_tables
+%attr(755,root,root) %{_sbindir}/mysql_upgrade
+%attr(755,root,root) %{_sbindir}/mysqlcheck
+%attr(755,root,root) %{_sbindir}/mysqld
+%attr(755,root,root) %{_bindir}/mysql_install_db
+%dir %{_libdir}/mysql
+%dir %{_libdir}/mysql/plugin
+%attr(755,root,root) %{_libdir}/mysql/plugin/ha_innodb.so
+%if %{with sphinx}
+%attr(755,root,root) %{_libdir}/mysql/plugin/sphinx.so
+%endif
+%{_mandir}/man1/innochecksum.1*
+%{_mandir}/man1/my_print_defaults.1*
+%{_mandir}/man1/myisamchk.1*
+%{_mandir}/man1/myisamlog.1*
+%{_mandir}/man1/myisampack.1*
+%{_mandir}/man1/mysql_fix_privilege_tables.1*
+%{_mandir}/man1/mysql_install_db.1*
+%{_mandir}/man1/mysql_upgrade.1*
+%{_mandir}/man1/mysqlcheck.1*
+%{_mandir}/man8/mysqld.8*
+
+%if %{?debug:1}0
+%attr(755,root,root) %{_bindir}/*resolve_stack_dump
+%{_datadir}/mysql/mysqld.sym
+%{_mandir}/man1/*resolve_stack_dump.1*
+%endif
+
+%attr(700,mysql,mysql) %{_mysqlhome}
+# root:root is proper here for mysql.rpm while mysql:mysql is potential security hole
+%attr(751,root,root) /var/lib/mysql
+%attr(750,mysql,mysql) %dir /var/log/mysql
+%attr(750,mysql,mysql) %dir /var/log/archive/mysql
+%attr(640,mysql,mysql) %ghost /var/log/mysql/*
+
+%{_infodir}/mysql.info*
+# This is template for configuration file which is created after 'service mysql init'
+%{_datadir}/mysql/mysqld.conf
+%{_datadir}/mysql/mysql_system_tables.sql
+%{_datadir}/mysql/mysql_system_tables_data.sql
+%{_datadir}/mysql/mysql_test_data_timezone.sql
+
+%{_datadir}/mysql/english
+%{_datadir}/mysql/fill_help_tables.sql
+%{_datadir}/mysql/mysql_fix_privilege_tables.sql
+%lang(cs) %{_datadir}/mysql/czech
+%lang(da) %{_datadir}/mysql/danish
+%lang(de) %{_datadir}/mysql/german
+%lang(el) %{_datadir}/mysql/greek
+%lang(es) %{_datadir}/mysql/spanish
+%lang(et) %{_datadir}/mysql/estonian
+%lang(fr) %{_datadir}/mysql/french
+%lang(hu) %{_datadir}/mysql/hungarian
+%lang(it) %{_datadir}/mysql/italian
+%lang(ja) %{_datadir}/mysql/japanese
+%lang(ko) %{_datadir}/mysql/korean
+%lang(nl) %{_datadir}/mysql/dutch
+%lang(nb) %{_datadir}/mysql/norwegian
+%lang(nn) %{_datadir}/mysql/norwegian-ny
+%lang(pl) %{_datadir}/mysql/polish
+%lang(pt) %{_datadir}/mysql/portuguese
+%lang(ro) %{_datadir}/mysql/romanian
+%lang(ru) %{_datadir}/mysql/russian
+%lang(sr) %{_datadir}/mysql/serbian
+%lang(sk) %{_datadir}/mysql/slovak
+%lang(sv) %{_datadir}/mysql/swedish
+%lang(uk) %{_datadir}/mysql/ukrainian
+
+%files charsets
+%defattr(644,root,root,755)
+%dir %{_datadir}/mysql
+%{_datadir}/mysql/charsets
+
+%files extras
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/msql2mysql
+%attr(755,root,root) %{_bindir}/myisam_ftdump
+%attr(755,root,root) %{_bindir}/mysql_secure_installation
+%attr(755,root,root) %{_bindir}/mysql_tzinfo_to_sql
+%attr(755,root,root) %{_bindir}/perror
+%attr(755,root,root) %{_bindir}/replace
+%{_mandir}/man1/msql2mysql.1*
+%{_mandir}/man1/myisam_ftdump.1*
+%{_mandir}/man1/mysql_secure_installation.1*
+%{_mandir}/man1/mysql_tzinfo_to_sql.1*
+%{_mandir}/man1/perror.1*
+%{_mandir}/man1/replace.1*
+
+%files -n mysqlhotcopy
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/mysqlhotcopy
+%{_mandir}/man1/mysqlhotcopy.1*
+
+%files extras-perl
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/mysql_convert_table_format
+%attr(755,root,root) %{_bindir}/mysql_find_rows
+%attr(755,root,root) %{_bindir}/mysql_fix_extensions
+%attr(755,root,root) %{_bindir}/mysql_setpermission
+%attr(755,root,root) %{_bindir}/mysql_zap
+%attr(755,root,root) %{_bindir}/mysqlaccess
+%attr(755,root,root) %{_bindir}/mysqldumpslow
+%{_mandir}/man1/mysql_convert_table_format.1*
+%{_mandir}/man1/mysql_find_rows.1*
+%{_mandir}/man1/mysql_fix_extensions.1*
+%{_mandir}/man1/mysql_setpermission.1*
+%{_mandir}/man1/mysql_zap.1*
+%{_mandir}/man1/mysqlaccess.1*
+%{_mandir}/man1/mysqldumpslow.1*
+
+%files client
+%defattr(644,root,root,755)
+%attr(600,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/skel/.my.cnf
+%attr(755,root,root) %{_bindir}/mysql
+%attr(755,root,root) %{_bindir}/mysqladmin
+%attr(755,root,root) %{_bindir}/mysqlbinlog
+%attr(755,root,root) %{_bindir}/mysqlbug
+%attr(755,root,root) %{_bindir}/mysqldump
+%attr(755,root,root) %{_bindir}/mysqlimport
+%attr(755,root,root) %{_bindir}/mysqlshow
+%attr(755,root,root) %{_sbindir}/mysqlmanager
+%{_mandir}/man1/mysql.1*
+%{_mandir}/man1/mysqladmin.1*
+%{_mandir}/man1/mysqlbinlog.1*
+%{_mandir}/man1/mysqlbug.1*
+%{_mandir}/man1/mysqldump.1*
+%{_mandir}/man1/mysqlimport.1*
+%{_mandir}/man1/mysqlshow.1*
+%{_mandir}/man8/mysqlmanager.8*
+
+%files libs
+%defattr(644,root,root,755)
+%attr(751,root,root) %dir %{_sysconfdir}/mysql
+%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/mysql/mysql-client.conf
+%attr(755,root,root) %{_libdir}/libmysqlclient.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libmysqlclient.so.16
+%attr(755,root,root) %{_libdir}/libmysqlclient_r.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libmysqlclient_r.so.16
+%if %{with ndb}
+%attr(755,root,root) %{_libdir}/libndbclient.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libndbclient.so.3
+%endif
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/mysql_config
+%attr(755,root,root) %{_libdir}/libmysqlclient.so
+%attr(755,root,root) %{_libdir}/libmysqlclient_r.so
+%if %{with ndb}
+%attr(755,root,root) %{_libdir}/libndbclient.so
+%{_libdir}/libndbclient.la
+%endif
+%{_libdir}/libmysqlclient.la
+%{_libdir}/libmysqlclient_r.la
+# static-only
+%{_libdir}/libdbug.a
+%{_libdir}/libheap.a
+%{_libdir}/libmyisam.a
+%{_libdir}/libmyisammrg.a
+%{_libdir}/libmysqld.a
+%{_libdir}/libmystrings.a
+%{_libdir}/libmysys.a
+%{_libdir}/libvio.a
+%{_includedir}/mysql
+%{_aclocaldir}/mysql.m4
+%{_mandir}/man1/mysql_config.1*
+
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libmysqlclient.a
+%{_libdir}/libmysqlclient_r.a
+%if %{with ndb}
+%{_libdir}/libndbclient.a
+%endif
+
+%files bench
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/mysqlslap
+%attr(755,root,root) %{_bindir}/mysqltest
+%dir %{_datadir}/sql-bench
+%{_datadir}/sql-bench/[CDRl]*
+%attr(755,root,root) %{_datadir}/sql-bench/[bcgirst]*
+%{_mandir}/man1/mysqlslap.1*
+%{_mandir}/man1/mysqltest.1*
+%{_mandir}/man1/mysqltest_embedded.1*
+
+#%files doc
+#%defattr(644,root,root,755)
+#%doc Docs/manual.html Docs/manual_toc.html
+
+%if %{with ndb}
+%files ndb
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_sbindir}/ndbd
+%attr(754,root,root) /etc/rc.d/init.d/mysql-ndb
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/mysql-ndb
+%{_mandir}/man1/ndbd_redo_log_reader.1*
+%{_mandir}/man8/ndbd.8*
+
+%files ndb-client
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/ndb_config
+%attr(755,root,root) %{_bindir}/ndb_delete_all
+%attr(755,root,root) %{_bindir}/ndb_desc
+%attr(755,root,root) %{_bindir}/ndb_drop_index
+%attr(755,root,root) %{_bindir}/ndb_drop_table
+%attr(755,root,root) %{_bindir}/ndb_error_reporter
+%attr(755,root,root) %{_bindir}/ndb_mgm
+%attr(755,root,root) %{_bindir}/ndb_print_backup_file
+%attr(755,root,root) %{_bindir}/ndb_print_schema_file
+%attr(755,root,root) %{_bindir}/ndb_print_sys_file
+%attr(755,root,root) %{_bindir}/ndb_restore
+%attr(755,root,root) %{_bindir}/ndb_select_all
+%attr(755,root,root) %{_bindir}/ndb_select_count
+%attr(755,root,root) %{_bindir}/ndb_show_tables
+%attr(755,root,root) %{_bindir}/ndb_size.pl
+%attr(755,root,root) %{_bindir}/ndb_test_platform
+%attr(755,root,root) %{_bindir}/ndb_waiter
+%{_mandir}/man1/ndb_config.1*
+%{_mandir}/man1/ndb_delete_all.1*
+%{_mandir}/man1/ndb_desc.1*
+%{_mandir}/man1/ndb_drop_index.1*
+%{_mandir}/man1/ndb_drop_table.1*
+%{_mandir}/man1/ndb_error_reporter.1*
+%{_mandir}/man1/ndb_mgm.1*
+%{_mandir}/man1/ndb_print_backup_file.1*
+%{_mandir}/man1/ndb_print_schema_file.1*
+%{_mandir}/man1/ndb_print_sys_file.1*
+%{_mandir}/man1/ndb_restore.1*
+%{_mandir}/man1/ndb_select_all.1*
+%{_mandir}/man1/ndb_select_count.1*
+%{_mandir}/man1/ndb_show_tables.1*
+%{_mandir}/man1/ndb_size.pl.1*
+%{_mandir}/man1/ndb_waiter.1*
+
+%files ndb-mgm
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_sbindir}/ndb_mgmd
+%attr(754,root,root) /etc/rc.d/init.d/mysql-ndb-mgm
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/mysql-ndb-mgm
+%{_mandir}/man8/ndb_mgmd.8*
+
+%files ndb-cpc
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_sbindir}/ndb_cpcd
+%attr(754,root,root) /etc/rc.d/init.d/mysql-ndb-cpc
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/mysql-ndb-cpc
+%{_mandir}/man1/ndb_cpcd.1*
+%endif
diff --git a/bug813587.patch b/bug813587.patch
new file mode 100644
index 0000000..ea8e838
--- /dev/null
+++ b/bug813587.patch
@@ -0,0 +1,30 @@
+# name       : bug813587.patch
+# maintainer : Alexey
+#
+# Fix for LP bug #813587 / MySQL bug #51196 / MySQL bug #61790
+#
+# Clear MySQL connection errors in ha_federated::close(), since they
+# can affect queries on other tables due to table cache eviction.
+#
+--- a/storage/federated/ha_federated.cc
++++ b/storage/federated/ha_federated.cc
+@@ -1675,6 +1675,8 @@
+ 
+ int ha_federated::close(void)
+ {
++  THD *thd= current_thd;
++
+   DBUG_ENTER("ha_federated::close");
+ 
+   free_result();
+@@ -1685,6 +1687,10 @@
+   mysql_close(mysql);
+   mysql= NULL;
+ 
++  /* Clear possible errors from mysql_close(), see LP bug #813587. */
++  if (thd)
++    thd->clear_error();
++
+   DBUG_RETURN(free_share(share));
+ }
+ 
diff --git a/my.cnf b/my.cnf
new file mode 100644
index 0000000..c84a6cf
--- /dev/null
+++ b/my.cnf
@@ -0,0 +1,2 @@
+[client]
+user=mysql
diff --git a/mysql-acc-pslist.patch b/mysql-acc-pslist.patch
new file mode 100644
index 0000000..f447f4f
--- /dev/null
+++ b/mysql-acc-pslist.patch
@@ -0,0 +1,80 @@
+diff -r 1a59073d658d mysql-test/r/create.result
+--- a/mysql-test/r/create.result	Sat Sep 13 17:31:30 2008 -0700
++++ b/mysql-test/r/create.result	Sat Sep 13 17:31:40 2008 -0700
+@@ -1720,7 +1720,8 @@
+   `COMMAND` varchar(16) NOT NULL DEFAULT '',
+   `TIME` bigint(7) NOT NULL DEFAULT '0',
+   `STATE` varchar(64) DEFAULT NULL,
+-  `INFO` longtext
++  `INFO` longtext,
++  `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000'
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8
+ drop table t1;
+ create temporary table t1 like information_schema.processlist;
+@@ -1734,7 +1735,8 @@
+   `COMMAND` varchar(16) NOT NULL DEFAULT '',
+   `TIME` bigint(7) NOT NULL DEFAULT '0',
+   `STATE` varchar(64) DEFAULT NULL,
+-  `INFO` longtext
++  `INFO` longtext,
++  `TIME_MS` decimal(22,3) NOT NULL DEFAULT '0.000'
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8
+ drop table t1;
+ create table t1 like information_schema.character_sets;
+diff -r 1a59073d658d sql/sql_show.cc
+--- a/sql/sql_show.cc	Sat Sep 13 17:31:30 2008 -0700
++++ b/sql/sql_show.cc	Sat Sep 13 17:31:40 2008 -0700
+@@ -1803,7 +1803,7 @@
+   TABLE *table= tables->table;
+   CHARSET_INFO *cs= system_charset_info;
+   char *user;
+-  time_t now= my_time(0);
++  ulonglong unow= my_micro_time();
+   DBUG_ENTER("fill_process_list");
+ 
+   user= thd->security_ctx->master_access & PROCESS_ACL ?
+@@ -1873,8 +1873,8 @@
+         table->field[4]->store(command_name[tmp->command].str,
+                                command_name[tmp->command].length, cs);
+       /* MYSQL_TIME */
+-      table->field[5]->store((longlong)(tmp->start_time ?
+-                                      now - tmp->start_time : 0), FALSE);
++      const ulonglong utime= tmp->start_utime ? unow - tmp->start_utime : 0;
++      table->field[5]->store(utime / 1000000, TRUE);
+       /* STATE */
+ #ifndef EMBEDDED_LIBRARY
+       val= (char*) (tmp->locked ? "Locked" :
+@@ -1896,11 +1896,15 @@
+         table->field[7]->set_notnull();
+       }
+ 
++      /* TIME_MS */
++      table->field[8]->store((double)(utime / 1000.0));
++
+       if (schema_table_store_record(thd, table))
+       {
+         VOID(pthread_mutex_unlock(&LOCK_thread_count));
+         DBUG_RETURN(1);
+       }
++
+     }
+   }
+ 
+@@ -5531,7 +5535,7 @@
+     into it two numbers, based on modulus of base-10 numbers.  In the ones
+     position is the number of decimals.  Tens position is unused.  In the
+     hundreds and thousands position is a two-digit decimal number representing
+-    length.  Encode this value with  (decimals*100)+length  , where
++    length.  Encode this value with  (length*100)+decimals  , where
+     0<decimals<10 and 0<=length<100 .
+ 
+   @param
+@@ -6539,6 +6543,8 @@
+   {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State", SKIP_OPEN_TABLE},
+   {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info",
+    SKIP_OPEN_TABLE},
++  {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
++    0, 0, "Time_ms", SKIP_OPEN_TABLE},
+   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
+ };
+ 
diff --git a/mysql-alpha.patch b/mysql-alpha.patch
new file mode 100644
index 0000000..68afda0
--- /dev/null
+++ b/mysql-alpha.patch
@@ -0,0 +1,10 @@
+--- mysql-5.1.55/storage/ndb/src/kernel/blocks/Makefile.am~	2011-01-25 17:04:48.000000000 +0200
++++ mysql-5.1.55/storage/ndb/src/kernel/blocks/Makefile.am	2011-03-13 13:41:42.430831048 +0200
+@@ -23,6 +23,7 @@
+ noinst_LIBRARIES = libblocks.a
+ 
+ INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/kernel/blocks/dblqh
++libblocks_a_CXXFLAGS = -O0
+ libblocks_a_SOURCES = tsman.cpp lgman.cpp pgman.cpp diskpage.cpp restore.cpp\
+   cmvmi/Cmvmi.cpp \
+   dbacc/DbaccInit.cpp dbacc/DbaccMain.cpp \
diff --git a/mysql-bug-34192.patch b/mysql-bug-34192.patch
new file mode 100644
index 0000000..d6491d4
--- /dev/null
+++ b/mysql-bug-34192.patch
@@ -0,0 +1,58 @@
+From: Chad MILLERDate: February 1 2008 5:53pm
+Subject: bk commit into 5.0 tree (cmiller:1.2572) BUG#34192
+
+Below is the list of changes that have just been committed into a local
+5.0 repository of cmiller.  When cmiller does a push these changes
+will be propagated to the main repository and, within 24 hours after the
+push, to the public repository.
+For information on how to access the public repository
+see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
+
+ChangeSet at stripped, 2008-02-01 11:53:48-05:00, cmiller at stripped +1 -0
+  Bug#34192: mysqldump from mysql 5.0.51 silently fails on dumping \
+  	databases from 4.0 server
+  
+  Contribution from Arkadiusz Miskiewicz.  No CLA required for this size.
+  
+  mysqldump treated a failure to set the results charset as a severe
+  error.  
+  
+  Now, don't try to set the charset for the SHOW CREATE TABLE statement,
+  if the dumper doesn't want SET NAMES or the remote server doesn't 
+  support changing charsets.
+  
+  (The original patch tried to set the charset to binary and back in 
+  any case, and only exited-with-failure if the dumper wanted it and
+  the remote server supported it.)
+
+  client/mysqldump.c at stripped, 2008-02-01 11:53:46-05:00, cmiller at stripped +13 -3
+    Don't set the charset for receiving results if it's not wanted or if
+    the server doesn't support it.
+
+diff -Nrup a/client/mysqldump.c b/client/mysqldump.c
+--- a/client/mysqldump.c	2007-12-04 22:07:00 -05:00
++++ b/client/mysqldump.c	2008-02-01 11:53:46 -05:00
+@@ -1705,10 +1705,20 @@ static uint get_table_structure(char *ta
+ 
+       my_snprintf(buff, sizeof(buff), "show create table %s", result_table);
+ 
+-      if (switch_character_set_results(mysql, "binary") ||
+-          mysql_query_with_error_report(mysql, &result, buff) ||
+-          switch_character_set_results(mysql, default_charset))
++      if (opt_set_charset)  /* Was forced to false if server is too old. */
++      {
++        if (switch_character_set_results(mysql, "binary") != 0)
++          DBUG_RETURN(0);
++      }
++
++      if (mysql_query_with_error_report(mysql, &result, buff) != 0)
+         DBUG_RETURN(0);
++
++      if (opt_set_charset)  /* Was forced to false if server is too old. */
++      {
++        if (switch_character_set_results(mysql, default_charset) != 0)
++          DBUG_RETURN(0);
++      }
+ 
+       if (path)
+       {
diff --git a/mysql-bug-43594.patch b/mysql-bug-43594.patch
new file mode 100644
index 0000000..b8cc07b
--- /dev/null
+++ b/mysql-bug-43594.patch
@@ -0,0 +1,30 @@
+=== modified file 'scripts/mysqlhotcopy.sh'
+--- scripts/mysqlhotcopy.sh	2008-03-07 20:45:40 +0000
++++ scripts/mysqlhotcopy.sh	2009-03-12 13:06:42 +0000
+@@ -777,7 +777,24 @@ sub get_list_of_tables {
+         } || [];
+     warn "Unable to retrieve list of tables in $db: $@" if $@;
+ 
+-    return (map { $_->[0] } @$tables);
++    my @ignore_tables = ();
++
++    # Ignore tables for the mysql database
++    if ($db eq 'mysql') {
++        @ignore_tables = qw(general_log slow_log schema apply_status);
++    }
++
++    my @res = ();
++    if ($#ignore_tables > 1) {
++       my @tmp = (map { $_->[0] } @$tables);
++       for my $t (@tmp) {
++           push(@res, $t) if not exists { map { $_=>1 } @ignore_tables }->{$t};
++       }
++    } else {
++       @res = (map { $_->[0] } @$tables);
++    }
++
++    return @res;
+ }
+ 
+ sub quote_names {
+
diff --git a/mysql-build.patch b/mysql-build.patch
new file mode 100644
index 0000000..11ef6ee
--- /dev/null
+++ b/mysql-build.patch
@@ -0,0 +1,12 @@
+diff -urNbB mysql-5.0.13-rc.org/sql/mysqld.cc mysql-5.0.13-rc/sql/mysqld.cc
+--- mysql-5.0.13-rc.org/sql/mysqld.cc	2005-09-22 21:39:56.000000000 +0200
++++ mysql-5.0.13-rc/sql/mysqld.cc	2005-09-29 19:29:59.991454000 +0200
+@@ -3183,7 +3183,7 @@
+   init_ssl();
+ 
+ #ifdef HAVE_LIBWRAP
+-  libwrapName= my_progname+dirname_length(my_progname);
++  libwrapName= (char *)my_progname+dirname_length(my_progname);
+   openlog(libwrapName, LOG_PID, LOG_AUTH);
+ #endif
+ 
diff --git a/mysql-c++.patch b/mysql-c++.patch
new file mode 100644
index 0000000..2abe3d5
--- /dev/null
+++ b/mysql-c++.patch
@@ -0,0 +1,12 @@
+diff -ur mysql-4.1.7.org/myisam/Makefile.am mysql-4.1.7/myisam/Makefile.am
+--- mysql-4.1.7.org/myisam/Makefile.am	2004-10-27 01:35:55.000000000 +0200
++++ mysql-4.1.7/myisam/Makefile.am	2004-10-27 01:41:47.764533080 +0200
+@@ -21,7 +21,7 @@
+ LDADD =			@CLIENT_EXTRA_LDFLAGS@ libmyisam.a \
+ 			$(top_builddir)/mysys/libmysys.a \
+ 			$(top_builddir)/dbug/libdbug.a \
+-			$(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@
++			$(top_builddir)/strings/libmystrings.a @ZLIB_LIBS@ $(libdir)/libsupc++.la
+ pkglib_LIBRARIES =	libmyisam.a
+ bin_PROGRAMS =		myisamchk myisamlog myisampack myisam_ftdump
+ myisamchk_DEPENDENCIES=	$(LIBRARIES)
diff --git a/mysql-client-config.patch b/mysql-client-config.patch
index e0466d1..5f56e98 100644
--- a/mysql-client-config.patch
+++ b/mysql-client-config.patch
@@ -1,33 +1,10 @@
-diff -urbB mysql-5.0.13-rc.org/libmysqld/client.c mysql-5.0.13-rc/libmysqld/client.c
---- mysql-5.0.13-rc.org/libmysqld/client.c	2005-09-22 21:40:24.000000000 +0200
-+++ mysql-5.0.13-rc/libmysqld/client.c	2005-09-29 19:35:27.947950000 +0200
-@@ -1455,6 +1455,7 @@
+--- mysql-5.1.6-alpha/sql-common/client.c~	2006-02-21 16:09:34.000000000 +0200
++++ mysql-5.1.6-alpha/sql-common/client.c	2006-02-21 16:14:10.000000000 +0200
+@@ -1456,6 +1456,7 @@
  
    mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
    mysql->options.report_data_truncation= TRUE;  /* default */
 +  mysql_read_default_options(&mysql->options, "/etc/mysql/mysql-client.conf", NULL);
-   return mysql;
- }
- 
-diff -urbB mysql-5.0.13-rc.org/sql/client.c mysql-5.0.13-rc/sql/client.c
---- mysql-5.0.13-rc.org/sql/client.c	2005-09-22 21:40:24.000000000 +0200
-+++ mysql-5.0.13-rc/sql/client.c	2005-09-29 19:35:38.164588500 +0200
-@@ -1455,6 +1455,7 @@
- 
-   mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
-   mysql->options.report_data_truncation= TRUE;  /* default */
-+  mysql_read_default_options(&mysql->options, "/etc/mysql/mysql-client.conf", NULL);
-   return mysql;
- }
- 
-diff -urbB mysql-5.0.13-rc.org/sql-common/client.c mysql-5.0.13-rc/sql-common/client.c
---- mysql-5.0.13-rc.org/sql-common/client.c	2005-09-22 21:40:24.000000000 +0200
-+++ mysql-5.0.13-rc/sql-common/client.c	2005-09-29 19:35:54.881633250 +0200
-@@ -1455,6 +1455,7 @@
- 
-   mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION;
-   mysql->options.report_data_truncation= TRUE;  /* default */
-+  mysql_read_default_options(&mysql->options, "/etc/mysql/mysql-client.conf", NULL);
-   return mysql;
- }
  
+   /*
+     By default we don't reconnect because it could silently corrupt data (after
diff --git a/mysql-client.conf b/mysql-client.conf
new file mode 100644
index 0000000..ccaab92
--- /dev/null
+++ b/mysql-client.conf
@@ -0,0 +1,7 @@
+#[client]
+#default-character-set=utf8
+#default-character-set=latin2
+
+[mysql]
+prompt='\\R:\\m:\\s mysql{\\c}> '
+show-warnings
diff --git a/mysql-clusters.conf b/mysql-clusters.conf
new file mode 100644
index 0000000..c617647
--- /dev/null
+++ b/mysql-clusters.conf
@@ -0,0 +1,10 @@
+# This file contains MySQL clusters configuration.
+# If you want to use more than one cluster read carefuly
+# http://www.mysql.com/doc/en/Multiple_servers.html
+# and set properly all described there options.
+#
+# You can add one cluster per line
+# /config/location.conf=/cluster/directory
+# If you give config name without path it defaults to /etc/mysql/
+
+mysqld.conf=/var/lib/mysql
diff --git a/mysql-config.patch b/mysql-config.patch
new file mode 100644
index 0000000..7a8fc65
--- /dev/null
+++ b/mysql-config.patch
@@ -0,0 +1,30 @@
+--- mysql-5.1.26-rc/scripts/mysql_config.sh.orig	2008-07-01 00:36:15.000000000 +0200
++++ mysql-5.1.26-rc/scripts/mysql_config.sh	2008-08-25 19:39:20.111236513 +0200
+@@ -132,21 +132,21 @@
+               DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
+               'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
+               Xa xstrconst "xc99=none" AC99 \
+-              unroll2 ip mp restrict
++              unroll2 ip mp restrict 'f[-a-z0-9]*' 'g[-a-z0-9]*' 'm[-a-z0-9]*'
+ do
+   # The first option we might strip will always have a space before it because
+   # we set -I$pkgincludedir as the first option
+-  cflags=`echo "$cflags"|sed -e "s/ -$remove  */ /g"` 
++  cflags=`echo "$cflags"|sed -e "s/ \(-$remove  *\)\{1,\}/ /g"` 
+ done
+ cflags=`echo "$cflags"|sed -e 's/ *\$//'` 
+ 
+ # Same for --libs(_r)
+-for remove in lmtmalloc static-libcxa i-static static-intel
++for remove in lmtmalloc static-libcxa i-static static-intel 'Wl,-[-a-z0-9,]*'
+ do
+   # We know the strings starts with a space
+-  libs=`echo "$libs"|sed -e "s/ -$remove  */ /g"` 
+-  libs_r=`echo "$libs_r"|sed -e "s/ -$remove  */ /g"` 
+-  embedded_libs=`echo "$embedded_libs"|sed -e "s/ -$remove  */ /g"` 
++  libs=`echo "$libs"|sed -e "s/ \(-$remove  *\)\{1,\}/ /g"` 
++  libs_r=`echo "$libs_r"|sed -e "s/ \(-$remove  *\)\{1,\}/ /g"` 
++  embedded_libs=`echo "$embedded_libs"|sed -e "s/ \(-$remove  *\)\{1,\}/ /g"` 
+ done
+ 
+ # Strip trailing and ending space if any, and '+' (FIXME why?)
diff --git a/mysql-fix-dummy-thread-race-condition.patch b/mysql-fix-dummy-thread-race-condition.patch
new file mode 100644
index 0000000..6ed7380
--- /dev/null
+++ b/mysql-fix-dummy-thread-race-condition.patch
@@ -0,0 +1,65 @@
+## fix-dummy-thread-race-condition.dpatch by  <mkoegler at auto.tuwien.ac.at>
+##
+## Avoid dummy thread for pthread_exit workaround
+
+--- mysql-5.1.40/mysys/my_thr_init.c~	2009-10-06 20:49:02.000000000 +0300
++++ mysql-5.1.40/mysys/my_thr_init.c	2009-10-27 15:01:59.807275693 +0200
+@@ -47,24 +47,6 @@
+ pthread_mutexattr_t my_errorcheck_mutexattr;
+ #endif
+ 
+-#ifdef TARGET_OS_LINUX
+-
+-/*
+-  Dummy thread spawned in my_thread_global_init() below to avoid
+-  race conditions in NPTL pthread_exit code.
+-*/
+-
+-static pthread_handler_t
+-nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
+-{
+-  /* Do nothing! */
+-  pthread_exit(0);
+-  return 0;
+-}
+-
+-#endif /* TARGET_OS_LINUX */
+-
+-
+ static uint get_thread_lib(void);
+ 
+ /*
+@@ -89,33 +71,6 @@
+     return 1;
+   }
+ 
+-#ifdef TARGET_OS_LINUX
+-  /*
+-    BUG#24507: Race conditions inside current NPTL pthread_exit()
+-    implementation.
+-
+-    To avoid a possible segmentation fault during concurrent
+-    executions of pthread_exit(), a dummy thread is spawned which
+-    initializes internal variables of pthread lib. See bug description
+-    for a full explanation.
+-
+-    TODO: Remove this code when fixed versions of glibc6 are in common
+-    use.
+-  */
+-  if (thd_lib_detected == THD_LIB_NPTL)
+-  {
+-    pthread_t       dummy_thread;
+-    pthread_attr_t  dummy_thread_attr;
+-
+-    pthread_attr_init(&dummy_thread_attr);
+-    pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_JOINABLE);
+-
+-    if (pthread_create(&dummy_thread,&dummy_thread_attr,
+-                       nptl_pthread_exit_hack_handler, NULL) == 0)
+-      (void)pthread_join(dummy_thread, NULL);
+-  }
+-#endif /* TARGET_OS_LINUX */
+-
+ #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
+   /*
+     Set mutex type to "fast" a.k.a "adaptive"
diff --git a/mysql-info.patch b/mysql-info.patch
new file mode 100644
index 0000000..179f823
--- /dev/null
+++ b/mysql-info.patch
@@ -0,0 +1,15 @@
+--- mysql-4.1.12/Docs/mysql.info~	2005-05-16 08:05:46.000000000 +0300
++++ mysql-4.1.12/Docs/mysql.info	2005-05-16 08:06:36.000000000 +0300
+@@ -1,8 +1,9 @@
+ This is mysql.info, produced by makeinfo version 4.7 from manual.texi.
+ 
+-START-INFO-DIR-ENTRY
+-* mysql: (mysql).               MySQL documentation.
+-END-INFO-DIR-ENTRY
++ at dircategory Data bases:
++ at direntry
++* mysql: (mysql).			MySQL documentation
++ at end direntry
+ 
+ 
+ File: mysql.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
diff --git a/mysql-innodb_dict_size_limit.patch b/mysql-innodb_dict_size_limit.patch
new file mode 100644
index 0000000..565f7c1
--- /dev/null
+++ b/mysql-innodb_dict_size_limit.patch
@@ -0,0 +1,497 @@
+# name       : innodb_dict_size_limit.patch
+# introduced : 11 or before
+# maintainer : Yasufumi
+#
+#!!! notice !!!
+# Any small change to this file in the main branch
+# should be done or reviewed by the maintainer!
+diff -ruN a/storage/innodb_plugin/btr/btr0sea.c b/storage/innodb_plugin/btr/btr0sea.c
+--- a/storage/innodb_plugin/btr/btr0sea.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/btr/btr0sea.c	2010-08-27 16:09:42.926020757 +0900
+@@ -1173,6 +1173,173 @@
+ 	mem_free(folds);
+ }
+ 
++/************************************************************************
++Drops a page hash index based on index */
++UNIV_INTERN
++void
++btr_search_drop_page_hash_index_on_index(
++/*=====================================*/
++	dict_index_t*	index)		/* in: record descriptor */
++{
++
++	hash_table_t*	table;
++	buf_block_t*	block;
++	ulint		n_fields;
++	ulint		n_bytes;
++	const page_t*		page;
++	const rec_t*		rec;
++	ulint		fold;
++	ulint		prev_fold;
++	dulint			index_id;
++	ulint		n_cached;
++	ulint		n_recs;
++	ulint*		folds;
++	ulint		i;
++	mem_heap_t*	heap	= NULL;
++	ulint*		offsets;
++	ibool		released_search_latch;
++
++	rw_lock_s_lock(&btr_search_latch);
++
++	table = btr_search_sys->hash_index;
++
++	do {
++		buf_chunk_t*	chunks	= buf_pool->chunks;
++		buf_chunk_t*	chunk	= chunks + buf_pool->n_chunks;
++
++		released_search_latch = FALSE;
++
++		while (--chunk >= chunks) {
++			block	= chunk->blocks;
++			i	= chunk->size;
++
++retry:
++			for (; i--; block++) {
++				if (buf_block_get_state(block)
++				    != BUF_BLOCK_FILE_PAGE
++				    || block->index != index
++				    || !block->is_hashed) {
++					continue;
++				}
++
++				page = block->frame;
++
++				/* from btr_search_drop_page_hash_index() */
++				n_fields = block->curr_n_fields;
++				n_bytes = block->curr_n_bytes;
++
++
++				/* keeping latch order */
++				rw_lock_s_unlock(&btr_search_latch);
++				released_search_latch = TRUE;
++				rw_lock_x_lock(&block->lock);
++
++
++				ut_a(n_fields + n_bytes > 0);
++
++				n_recs = page_get_n_recs(page);
++
++				/* Calculate and cache fold values into an array for fast deletion
++				from the hash index */
++
++				folds = mem_alloc(n_recs * sizeof(ulint));
++
++				n_cached = 0;
++
++				rec = page_get_infimum_rec(page);
++				rec = page_rec_get_next_low(rec, page_is_comp(page));
++
++				index_id = btr_page_get_index_id(page);
++	
++				ut_a(0 == ut_dulint_cmp(index_id, index->id));
++
++				prev_fold = 0;
++
++				offsets = NULL;
++
++				while (!page_rec_is_supremum(rec)) {
++					offsets = rec_get_offsets(rec, index, offsets,
++								n_fields + (n_bytes > 0), &heap);
++					ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
++					fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
++
++					if (fold == prev_fold && prev_fold != 0) {
++
++						goto next_rec;
++					}
++
++					/* Remove all hash nodes pointing to this page from the
++					hash chain */
++
++					folds[n_cached] = fold;
++					n_cached++;
++next_rec:
++					rec = page_rec_get_next_low(rec, page_rec_is_comp(rec));
++					prev_fold = fold;
++				}
++
++				if (UNIV_LIKELY_NULL(heap)) {
++					mem_heap_empty(heap);
++				}
++
++				rw_lock_x_lock(&btr_search_latch);
++
++				if (UNIV_UNLIKELY(!block->is_hashed)) {
++					goto cleanup;
++				}
++
++				ut_a(block->index == index);
++
++				if (UNIV_UNLIKELY(block->curr_n_fields != n_fields)
++				    || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) {
++					rw_lock_x_unlock(&btr_search_latch);
++					rw_lock_x_unlock(&block->lock);
++
++					mem_free(folds);
++
++					rw_lock_s_lock(&btr_search_latch);
++					goto retry;
++				}
++
++				for (i = 0; i < n_cached; i++) {
++
++					ha_remove_all_nodes_to_page(table, folds[i], page);
++				}
++
++				ut_a(index->search_info->ref_count > 0);
++				index->search_info->ref_count--;
++
++				block->is_hashed = FALSE;
++				block->index = NULL;
++
++cleanup:	
++#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
++				if (UNIV_UNLIKELY(block->n_pointers)) {
++					/* Corruption */
++					ut_print_timestamp(stderr);
++					fprintf(stderr,
++"  InnoDB: Corruption of adaptive hash index. After dropping\n"
++"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n",
++						index->name, (ulong) block->n_pointers);
++				}
++#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
++				rw_lock_x_unlock(&btr_search_latch);
++				rw_lock_x_unlock(&block->lock);
++
++				mem_free(folds);
++
++				rw_lock_s_lock(&btr_search_latch);
++			}
++		}
++	} while (released_search_latch);
++
++	rw_lock_s_unlock(&btr_search_latch);
++
++	if (UNIV_LIKELY_NULL(heap)) {
++		mem_heap_free(heap);
++	}
++}
++
+ /********************************************************************//**
+ Drops a page hash index when a page is freed from a fseg to the file system.
+ Drops possible hash index if the page happens to be in the buffer pool. */
+diff -ruN a/storage/innodb_plugin/dict/dict0boot.c b/storage/innodb_plugin/dict/dict0boot.c
+--- a/storage/innodb_plugin/dict/dict0boot.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/dict/dict0boot.c	2010-08-27 16:09:42.927104460 +0900
+@@ -283,6 +283,7 @@
+ 	system tables */
+ 	/*-------------------------*/
+ 	table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0);
++	table->n_mysql_handles_opened = 1; /* for pin */
+ 
+ 	dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
+ 	dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
+@@ -335,6 +336,7 @@
+ 
+ 	/*-------------------------*/
+ 	table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
++	table->n_mysql_handles_opened = 1; /* for pin */
+ 
+ 	dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
+ 	dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
+@@ -367,6 +369,7 @@
+ 
+ 	/*-------------------------*/
+ 	table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
++	table->n_mysql_handles_opened = 1; /* for pin */
+ 
+ 	dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
+ 	dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
+@@ -412,6 +415,7 @@
+ 
+ 	/*-------------------------*/
+ 	table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
++	table->n_mysql_handles_opened = 1; /* for pin */
+ 
+ 	dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
+ 	dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
+diff -ruN a/storage/innodb_plugin/dict/dict0crea.c b/storage/innodb_plugin/dict/dict0crea.c
+--- a/storage/innodb_plugin/dict/dict0crea.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/dict/dict0crea.c	2010-08-27 16:09:42.928062387 +0900
+@@ -1211,6 +1211,9 @@
+ 		/* Foreign constraint system tables have already been
+ 		created, and they are ok */
+ 
++		table1->n_mysql_handles_opened = 1; /* for pin */
++		table2->n_mysql_handles_opened = 1; /* for pin */
++
+ 		mutex_exit(&(dict_sys->mutex));
+ 
+ 		return(DB_SUCCESS);
+@@ -1292,6 +1295,11 @@
+ 
+ 	trx_commit_for_mysql(trx);
+ 
++	table1 = dict_table_get_low("SYS_FOREIGN");
++	table2 = dict_table_get_low("SYS_FOREIGN_COLS");
++	table1->n_mysql_handles_opened = 1; /* for pin */
++	table2->n_mysql_handles_opened = 1; /* for pin */
++
+ 	row_mysql_unlock_data_dictionary(trx);
+ 
+ 	trx_free_for_mysql(trx);
+diff -ruN a/storage/innodb_plugin/dict/dict0dict.c b/storage/innodb_plugin/dict/dict0dict.c
+--- a/storage/innodb_plugin/dict/dict0dict.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/dict/dict0dict.c	2010-08-27 16:09:42.930057360 +0900
+@@ -613,6 +613,8 @@
+ 
+ 	table = dict_table_get_on_id_low(table_id);
+ 
++	dict_table_LRU_trim(table);
++
+ 	mutex_exit(&(dict_sys->mutex));
+ 
+ 	return(table);
+@@ -728,6 +730,8 @@
+ 		table->n_mysql_handles_opened++;
+ 	}
+ 
++	dict_table_LRU_trim(table);
++
+ 	mutex_exit(&(dict_sys->mutex));
+ 
+ 	if (table != NULL) {
+@@ -1241,6 +1245,64 @@
+ 	dict_mem_table_free(table);
+ }
+ 
++/**************************************************************************
++Frees tables from the end of table_LRU if the dictionary cache occupies
++too much space. */
++UNIV_INTERN
++void
++dict_table_LRU_trim(
++/*================*/
++	dict_table_t*	self)
++{
++	dict_table_t*	table;
++	dict_table_t*	prev_table;
++	dict_foreign_t*	foreign;
++	ulint		n_removed;
++	ulint		n_have_parent;
++	ulint		cached_foreign_tables;
++
++#ifdef UNIV_SYNC_DEBUG
++	ut_ad(mutex_own(&(dict_sys->mutex)));
++#endif /* UNIV_SYNC_DEBUG */
++
++retry:
++	n_removed = n_have_parent = 0;
++	table = UT_LIST_GET_LAST(dict_sys->table_LRU);
++
++	while ( srv_dict_size_limit && table
++		&& ((dict_sys->table_hash->n_cells
++		     + dict_sys->table_id_hash->n_cells) * sizeof(hash_cell_t)
++		    + dict_sys->size) > srv_dict_size_limit ) {
++		prev_table = UT_LIST_GET_PREV(table_LRU, table);
++
++		if (table == self || table->n_mysql_handles_opened)
++			goto next_loop;
++
++		cached_foreign_tables = 0;
++		foreign = UT_LIST_GET_FIRST(table->foreign_list);
++		while (foreign != NULL) {
++			if (foreign->referenced_table)
++				cached_foreign_tables++;
++			foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
++		}
++
++		if (cached_foreign_tables == 0) {
++			dict_table_remove_from_cache(table);
++			n_removed++;
++		} else {
++			n_have_parent++;
++		}
++next_loop:
++		table = prev_table;
++	}
++
++	if ( srv_dict_size_limit && n_have_parent && n_removed
++		&& ((dict_sys->table_hash->n_cells
++		     + dict_sys->table_id_hash->n_cells) * sizeof(hash_cell_t)
++		    + dict_sys->size) > srv_dict_size_limit )
++		goto retry;
++}
++
+ /****************************************************************//**
+ If the given column name is reserved for InnoDB system columns, return
+ TRUE.
+@@ -1709,6 +1771,11 @@
+ 	ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
+ 	ut_ad(mutex_own(&(dict_sys->mutex)));
+ 
++	/* remove all entry of the index from adaptive hash index,
++	because removing from adaptive hash index needs dict_index */
++	if (btr_search_enabled && srv_dict_size_limit)
++		btr_search_drop_page_hash_index_on_index(index);
++
+ 	/* We always create search info whether or not adaptive
+ 	hash index is enabled or not. */
+ 	info = index->search_info;
+diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
+--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:09:22.832057795 +0900
++++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:09:42.939059876 +0900
+@@ -560,6 +560,8 @@
+   (char*) &export_vars.innodb_dblwr_pages_written,	  SHOW_LONG},
+   {"dblwr_writes",
+   (char*) &export_vars.innodb_dblwr_writes,		  SHOW_LONG},
++  {"dict_tables",
++  (char*) &export_vars.innodb_dict_tables,		  SHOW_LONG},
+   {"have_atomic_builtins",
+   (char*) &export_vars.innodb_have_atomic_builtins,	  SHOW_BOOL},
+   {"log_waits",
+@@ -11390,6 +11392,11 @@
+   "Number of extra user rollback segments when create new database.",
+   NULL, NULL, 0, 0, 126, 0);
+ 
++static MYSQL_SYSVAR_ULONG(dict_size_limit, srv_dict_size_limit,
++  PLUGIN_VAR_RQCMDARG,
++  "Limit the allocated memory for dictionary cache. (0: unlimited)",
++  NULL, NULL, 0, 0, LONG_MAX, 0);
++
+ static struct st_mysql_sys_var* innobase_system_variables[]= {
+   MYSQL_SYSVAR(additional_mem_pool_size),
+   MYSQL_SYSVAR(autoextend_increment),
+@@ -11458,6 +11465,7 @@
+   MYSQL_SYSVAR(flush_log_at_trx_commit_session),
+   MYSQL_SYSVAR(enable_unsafe_group_commit),
+   MYSQL_SYSVAR(extra_rsegments),
++  MYSQL_SYSVAR(dict_size_limit),
+   MYSQL_SYSVAR(use_sys_malloc),
+   MYSQL_SYSVAR(change_buffering),
+ #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
+diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
+--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 16:09:22.832057795 +0900
++++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 16:09:42.944058939 +0900
+@@ -32,5 +32,6 @@
+ {"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {"innodb_overwrite_relay_log_info","overwrite relay-log.info when slave recovery","Building as plugin, it is not used.","http://www.percona.com/docs/wiki/percona-xtradb:innodb_overwrite_relay_log_info"},
+ {"innodb_thread_concurrency_timer_based","use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)","",""},
++{"innodb_dict_size_limit","Limit dictionary cache size","Variable innodb_dict_size_limit in bytes","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {NULL, NULL, NULL, NULL}
+ };
+diff -ruN a/storage/innodb_plugin/ibuf/ibuf0ibuf.c b/storage/innodb_plugin/ibuf/ibuf0ibuf.c
+--- a/storage/innodb_plugin/ibuf/ibuf0ibuf.c	2010-08-27 15:54:18.077987587 +0900
++++ b/storage/innodb_plugin/ibuf/ibuf0ibuf.c	2010-08-27 16:09:42.949020590 +0900
+@@ -514,6 +514,7 @@
+ 
+ 	/* Use old-style record format for the insert buffer. */
+ 	table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0);
++	table->n_mysql_handles_opened = 1; /* for pin */
+ 
+ 	dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
+ 
+diff -ruN a/storage/innodb_plugin/include/btr0sea.h b/storage/innodb_plugin/include/btr0sea.h
+--- a/storage/innodb_plugin/include/btr0sea.h	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/include/btr0sea.h	2010-08-27 16:09:42.951112397 +0900
+@@ -140,6 +140,13 @@
+ 				s- or x-latched, or an index page
+ 				for which we know that
+ 				block->buf_fix_count == 0 */
++/************************************************************************
++Drops a page hash index based on index */
++UNIV_INTERN
++void
++btr_search_drop_page_hash_index_on_index(
++/*=====================================*/
++	dict_index_t*	index);		/* in: record descriptor */
+ /********************************************************************//**
+ Drops a page hash index when a page is freed from a fseg to the file system.
+ Drops possible hash index if the page happens to be in the buffer pool. */
+diff -ruN a/storage/innodb_plugin/include/dict0dict.h b/storage/innodb_plugin/include/dict0dict.h
+--- a/storage/innodb_plugin/include/dict0dict.h	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/include/dict0dict.h	2010-08-27 16:09:42.953188223 +0900
+@@ -1131,6 +1131,12 @@
+ /*====================================*/
+ 	dict_table_t*	table,	/*!< in: table */
+ 	const char*	name);	/*!< in: name of the index to find */
++
++UNIV_INTERN
++void
++dict_table_LRU_trim(
++/*================*/
++	dict_table_t*	self);
+ /* Buffers for storing detailed information about the latest foreign key
+ and unique key errors */
+ extern FILE*	dict_foreign_err_file;
+diff -ruN a/storage/innodb_plugin/include/dict0dict.ic b/storage/innodb_plugin/include/dict0dict.ic
+--- a/storage/innodb_plugin/include/dict0dict.ic	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/include/dict0dict.ic	2010-08-27 16:09:42.955104393 +0900
+@@ -786,6 +786,13 @@
+ 	HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold,
+ 		    dict_table_t*, table, ut_ad(table->cached),
+ 		    !strcmp(table->name, table_name));
++
++	/* make young in table_LRU */
++	if (table) {
++		UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
++		UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
++	}
++
+ 	return(table);
+ }
+ 
+@@ -839,6 +846,12 @@
+ 		table = dict_load_table_on_id(table_id);
+ 	}
+ 
++	/* make young in table_LRU */
++	if (table) {
++		UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table);
++		UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table);
++	}
++
+ 	ut_ad(!table || table->cached);
+ 
+ 	/* TODO: should get the type information from MySQL */
+diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
+--- a/storage/innodb_plugin/include/srv0srv.h	2010-08-27 16:09:22.833022367 +0900
++++ b/storage/innodb_plugin/include/srv0srv.h	2010-08-27 16:09:42.957104575 +0900
+@@ -219,7 +219,7 @@
+ extern ulint	srv_adaptive_checkpoint;
+ 
+ extern ulint	srv_extra_rsegments;
+-
++extern ulint	srv_dict_size_limit;
+ /*-------------------------------------------*/
+ 
+ extern ulint	srv_n_rows_inserted;
+@@ -625,6 +625,7 @@
+ 	ulint innodb_data_writes;		/*!< I/O write requests */
+ 	ulint innodb_data_written;		/*!< Data bytes written */
+ 	ulint innodb_data_reads;		/*!< I/O read requests */
++	ulint innodb_dict_tables;
+ 	ulint innodb_buffer_pool_pages_total;	/*!< Buffer pool size */
+ 	ulint innodb_buffer_pool_pages_data;	/*!< Data pages */
+ 	ulint innodb_buffer_pool_pages_dirty;	/*!< Dirty data pages */
+diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
+--- a/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 16:09:22.834056830 +0900
++++ b/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 16:09:42.960059093 +0900
+@@ -391,6 +391,7 @@
+ UNIV_INTERN ulint	srv_adaptive_checkpoint = 0; /* 0: none  1: reflex  2: estimate */
+ 
+ UNIV_INTERN ulint	srv_extra_rsegments = 0; /* extra rseg for users */
++UNIV_INTERN ulint	srv_dict_size_limit = 0;
+ /*-------------------------------------------*/
+ UNIV_INTERN ulong	srv_n_spin_wait_rounds	= 30;
+ UNIV_INTERN ulong	srv_n_free_tickets_to_enter = 500;
+@@ -2091,6 +2092,7 @@
+ 	export_vars.innodb_data_reads = os_n_file_reads;
+ 	export_vars.innodb_data_writes = os_n_file_writes;
+ 	export_vars.innodb_data_written = srv_data_written;
++	export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0);
+ 	export_vars.innodb_buffer_pool_read_requests = buf_pool->stat.n_page_gets;
+ 	export_vars.innodb_buffer_pool_write_requests
+ 		= srv_buf_pool_write_requests;
diff --git a/mysql-innodb_extend_slow.patch b/mysql-innodb_extend_slow.patch
new file mode 100644
index 0000000..f2d17bc
--- /dev/null
+++ b/mysql-innodb_extend_slow.patch
@@ -0,0 +1,963 @@
+# name       : innodb_extend_slow.patch
+# introduced : 11 or before
+# maintainer : Yasufumi
+#
+#!!! notice !!!
+# Any small change to this file in the main branch
+# should be done or reviewed by the maintainer!
+diff -ruN a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0buf.c
+--- a/storage/innodb_plugin/buf/buf0buf.c	2010-08-27 16:13:11.061058561 +0900
++++ b/storage/innodb_plugin/buf/buf0buf.c	2010-08-27 16:30:47.341987400 +0900
+@@ -51,6 +51,40 @@
+ #include "dict0dict.h"
+ #include "log0recv.h"
+ #include "page0zip.h"
++#include "trx0trx.h"
++
++/* prototypes for new functions added to ha_innodb.cc */
++trx_t* innobase_get_trx();
++
++inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
++{
++	ulint           block_hash;
++	ulint           block_hash_byte;
++	byte            block_hash_offset;
++
++	ut_ad(block);
++
++	if (!innobase_get_slow_log() || !trx || !trx->take_stats)
++		return;
++
++	if (!trx->distinct_page_access_hash) {
++		trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
++		memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
++	}
++
++	block_hash = ut_hash_ulint((block->page.space << 20) + block->page.space +
++					block->page.offset, DPAH_SIZE << 3);
++	block_hash_byte = block_hash >> 3;
++	block_hash_offset = (byte) block_hash & 0x07;
++	if (block_hash_byte >= DPAH_SIZE)
++		fprintf(stderr, "!!! block_hash_byte = %lu  block_hash_offset = %d !!!\n", block_hash_byte, block_hash_offset);
++	if (block_hash_offset > 7)
++		fprintf(stderr, "!!! block_hash_byte = %lu  block_hash_offset = %d !!!\n", block_hash_byte, block_hash_offset);
++	if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
++		trx->distinct_page_access++;
++	trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
++	return;
++}
+ 
+ /*
+ 		IMPLEMENTATION OF THE BUFFER POOL
+@@ -1728,10 +1762,18 @@
+ 	mutex_t*	block_mutex;
+ 	ibool		must_read;
+ 	unsigned	access_time;
++	trx_t*		trx = NULL;
++	ulint		sec;
++	ulint		ms;
++	ib_uint64_t	start_time;
++	ib_uint64_t	finish_time;
+ 
+ #ifndef UNIV_LOG_DEBUG
+ 	ut_ad(!ibuf_inside());
+ #endif
++	if (innobase_get_slow_log()) {
++		trx = innobase_get_trx();
++	}
+ 	buf_pool->stat.n_page_gets++;
+ 
+ 	for (;;) {
+@@ -1748,7 +1790,7 @@
+ 		//buf_pool_mutex_exit();
+ 		rw_lock_s_unlock(&page_hash_latch);
+ 
+-		buf_read_page(space, zip_size, offset);
++		buf_read_page(space, zip_size, offset, trx);
+ 
+ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
+ 		ut_a(++buf_dbg_counter % 37 || buf_validate());
+@@ -1823,6 +1865,13 @@
+ 		/* Let us wait until the read operation
+ 		completes */
+ 
++		if (innobase_get_slow_log() && trx && trx->take_stats)
++		{
++			ut_usectime(&sec, &ms);
++			start_time = (ib_uint64_t)sec * 1000000 + ms;
++		} else {
++			start_time = 0;
++		}
+ 		for (;;) {
+ 			enum buf_io_fix	io_fix;
+ 
+@@ -1837,6 +1886,12 @@
+ 				break;
+ 			}
+ 		}
++		if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
++		{
++			ut_usectime(&sec, &ms);
++			finish_time = (ib_uint64_t)sec * 1000000 + ms;
++			trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
++		}
+ 	}
+ 
+ #ifdef UNIV_IBUF_COUNT_DEBUG
+@@ -2096,6 +2151,11 @@
+ 	ibool		must_read;
+ 	ulint		retries = 0;
+ 	mutex_t*	block_mutex;
++	trx_t*          trx = NULL;
++	ulint           sec;
++	ulint           ms;
++	ib_uint64_t     start_time;
++	ib_uint64_t     finish_time;
+ 
+ 	ut_ad(mtr);
+ 	ut_ad(mtr->state == MTR_ACTIVE);
+@@ -2120,6 +2180,9 @@
+ #ifndef UNIV_LOG_DEBUG
+ 	ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset, NULL));
+ #endif
++	if (innobase_get_slow_log()) {
++		trx = innobase_get_trx();
++	}
+ 	buf_pool->stat.n_page_gets++;
+ loop:
+ 	block = guess;
+@@ -2174,7 +2237,7 @@
+ 			return(NULL);
+ 		}
+ 
+-		if (buf_read_page(space, zip_size, offset)) {
++		if (buf_read_page(space, zip_size, offset, trx)) {
+ 			retries = 0;
+ 		} else if (retries < BUF_PAGE_READ_MAX_RETRIES) {
+ 			++retries;
+@@ -2462,6 +2525,13 @@
+ 			/* Let us wait until the read operation
+ 			completes */
+ 
++			if (innobase_get_slow_log() && trx && trx->take_stats)
++			{
++				ut_usectime(&sec, &ms);
++				start_time = (ib_uint64_t)sec * 1000000 + ms;
++			} else {
++				start_time = 0;
++			}
+ 			for (;;) {
+ 				enum buf_io_fix	io_fix;
+ 
+@@ -2476,6 +2546,12 @@
+ 					break;
+ 				}
+ 			}
++			if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
++			{
++				ut_usectime(&sec, &ms);
++				finish_time = (ib_uint64_t)sec * 1000000 + ms;
++				trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
++			}
+ 		}
+ 
+ 		fix_type = MTR_MEMO_BUF_FIX;
+@@ -2501,13 +2577,17 @@
+ 		/* In the case of a first access, try to apply linear
+ 		read-ahead */
+ 
+-		buf_read_ahead_linear(space, zip_size, offset);
++		buf_read_ahead_linear(space, zip_size, offset, trx);
+ 	}
+ 
+ #ifdef UNIV_IBUF_COUNT_DEBUG
+ 	ut_a(ibuf_count_get(buf_block_get_space(block),
+ 			    buf_block_get_page_no(block)) == 0);
+ #endif
++	if (innobase_get_slow_log()) {
++		_increment_page_get_statistics(block, trx);
++	}
++
+ 	return(block);
+ }
+ 
+@@ -2530,6 +2610,7 @@
+ 	unsigned	access_time;
+ 	ibool		success;
+ 	ulint		fix_type;
++	trx_t*		trx = NULL;
+ 
+ 	ut_ad(block);
+ 	ut_ad(mtr);
+@@ -2607,13 +2688,17 @@
+ #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
+ 	ut_a(block->page.file_page_was_freed == FALSE);
+ #endif
++	if (innobase_get_slow_log()) {
++		trx = innobase_get_trx();
++	}
++
+ 	if (UNIV_UNLIKELY(!access_time)) {
+ 		/* In the case of a first access, try to apply linear
+ 		read-ahead */
+ 
+ 		buf_read_ahead_linear(buf_block_get_space(block),
+ 				      buf_block_get_zip_size(block),
+-				      buf_block_get_page_no(block));
++				      buf_block_get_page_no(block), trx);
+ 	}
+ 
+ #ifdef UNIV_IBUF_COUNT_DEBUG
+@@ -2622,6 +2707,9 @@
+ #endif
+ 	buf_pool->stat.n_page_gets++;
+ 
++	if (innobase_get_slow_log()) {
++		_increment_page_get_statistics(block, trx);
++	}
+ 	return(TRUE);
+ }
+ 
+@@ -2643,6 +2731,7 @@
+ {
+ 	ibool		success;
+ 	ulint		fix_type;
++	trx_t*		trx = NULL;
+ 
+ 	ut_ad(mtr);
+ 	ut_ad(mtr->state == MTR_ACTIVE);
+@@ -2727,6 +2816,11 @@
+ #endif
+ 	buf_pool->stat.n_page_gets++;
+ 
++	if (innobase_get_slow_log()) {
++		trx = innobase_get_trx();
++		_increment_page_get_statistics(block, trx);
++	}
++
+ 	return(TRUE);
+ }
+ 
+diff -ruN a/storage/innodb_plugin/buf/buf0rea.c b/storage/innodb_plugin/buf/buf0rea.c
+--- a/storage/innodb_plugin/buf/buf0rea.c	2010-08-27 16:23:31.014020792 +0900
++++ b/storage/innodb_plugin/buf/buf0rea.c	2010-08-27 16:30:47.342987531 +0900
+@@ -75,7 +75,8 @@
+ 			treat the tablespace as dropped; this is a timestamp we
+ 			use to stop dangling page reads from a tablespace
+ 			which we have DISCARDed + IMPORTed back */
+-	ulint	offset)	/*!< in: page number */
++	ulint	offset,	/*!< in: page number */
++	trx_t*	trx)
+ {
+ 	buf_page_t*	bpage;
+ 	ulint		wake_later;
+@@ -176,15 +177,15 @@
+ 	ut_ad(buf_page_in_file(bpage));
+ 
+ 	if (zip_size) {
+-		*err = fil_io(OS_FILE_READ | wake_later,
++		*err = _fil_io(OS_FILE_READ | wake_later,
+ 			      sync, space, zip_size, offset, 0, zip_size,
+-			      bpage->zip.data, bpage);
++			      bpage->zip.data, bpage, trx);
+ 	} else {
+ 		ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
+ 
+-		*err = fil_io(OS_FILE_READ | wake_later,
++		*err = _fil_io(OS_FILE_READ | wake_later,
+ 			      sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
+-			      ((buf_block_t*) bpage)->frame, bpage);
++			      ((buf_block_t*) bpage)->frame, bpage, trx);
+ 	}
+ 	ut_a(*err == DB_SUCCESS);
+ 
+@@ -209,7 +210,8 @@
+ /*==========*/
+ 	ulint	space,	/*!< in: space id */
+ 	ulint	zip_size,/*!< in: compressed page size in bytes, or 0 */
+-	ulint	offset)	/*!< in: page number */
++	ulint	offset,	/*!< in: page number */
++	trx_t*	trx)
+ {
+ 	ib_int64_t	tablespace_version;
+ 	ulint		count;
+@@ -222,7 +224,7 @@
+ 
+ 	count = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
+ 				  zip_size, FALSE,
+-				  tablespace_version, offset);
++				  tablespace_version, offset, trx);
+ 	srv_buf_pool_reads += count;
+ 	if (err == DB_TABLESPACE_DELETED) {
+ 		ut_print_timestamp(stderr);
+@@ -273,8 +275,9 @@
+ /*==================*/
+ 	ulint	space,	/*!< in: space id */
+ 	ulint	zip_size,/*!< in: compressed page size in bytes, or 0 */
+-	ulint	offset)	/*!< in: page number of a page; NOTE: the current thread
++	ulint	offset,	/*!< in: page number of a page; NOTE: the current thread
+ 			must want access to this page (see NOTE 3 above) */
++	trx_t*	trx)
+ {
+ 	ib_int64_t	tablespace_version;
+ 	buf_page_t*	bpage;
+@@ -497,7 +500,7 @@
+ 			count += buf_read_page_low(
+ 				&err, FALSE,
+ 				ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER,
+-				space, zip_size, FALSE, tablespace_version, i);
++				space, zip_size, FALSE, tablespace_version, i, trx);
+ 			if (err == DB_TABLESPACE_DELETED) {
+ 				ut_print_timestamp(stderr);
+ 				fprintf(stderr,
+@@ -587,7 +590,7 @@
+ 		buf_read_page_low(&err, sync && (i + 1 == n_stored),
+ 				  BUF_READ_ANY_PAGE, space_ids[i],
+ 				  zip_size, TRUE, space_versions[i],
+-				  page_nos[i]);
++				  page_nos[i], NULL);
+ 
+ 		if (UNIV_UNLIKELY(err == DB_TABLESPACE_DELETED)) {
+ tablespace_deleted:
+@@ -728,12 +731,12 @@
+ 		if ((i + 1 == n_stored) && sync) {
+ 			buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
+ 					  zip_size, TRUE, tablespace_version,
+-					  page_nos[i]);
++					  page_nos[i], NULL);
+ 		} else {
+ 			buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
+ 					  | OS_AIO_SIMULATED_WAKE_LATER,
+ 					  space, zip_size, TRUE,
+-					  tablespace_version, page_nos[i]);
++					  tablespace_version, page_nos[i], NULL);
+ 		}
+ 	}
+ 
+diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
+--- a/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:15:55.187400372 +0900
++++ b/storage/innodb_plugin/fil/fil0fil.c	2010-08-27 16:30:47.346992376 +0900
+@@ -4373,7 +4373,7 @@
+ 				 node->name, node->handle, buf,
+ 				 offset_low, offset_high,
+ 				 page_size * n_pages,
+-				 NULL, NULL);
++				 NULL, NULL, NULL);
+ #endif
+ 		if (success) {
+ 			node->size += n_pages;
+@@ -4700,7 +4700,7 @@
+ i/o on a tablespace which does not exist */
+ UNIV_INTERN
+ ulint
+-fil_io(
++_fil_io(
+ /*===*/
+ 	ulint	type,		/*!< in: OS_FILE_READ or OS_FILE_WRITE,
+ 				ORed to OS_FILE_LOG, if a log i/o
+@@ -4725,8 +4725,9 @@
+ 	void*	buf,		/*!< in/out: buffer where to store read data
+ 				or from where to write; in aio this must be
+ 				appropriately aligned */
+-	void*	message)	/*!< in: message for aio handler if non-sync
++	void*	message,	/*!< in: message for aio handler if non-sync
+ 				aio used, else ignored */
++	trx_t*	trx)
+ {
+ 	ulint		mode;
+ 	fil_space_t*	space;
+@@ -4896,7 +4897,7 @@
+ #else
+ 	/* Queue the aio request */
+ 	ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
+-		     offset_low, offset_high, len, node, message);
++		     offset_low, offset_high, len, node, message, trx);
+ #endif
+ 	ut_a(ret);
+ 
+diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
+--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:30:34.589021493 +0900
++++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 16:30:47.356987871 +0900
+@@ -1391,6 +1391,16 @@
+ 	trx->check_unique_secondary = !thd_test_options(
+ 		thd, OPTION_RELAXED_UNIQUE_CHECKS);
+ 
++#ifdef EXTENDED_SLOWLOG
++	if (thd_log_slow_verbosity(thd) & SLOG_V_INNODB) {
++		trx->take_stats = TRUE;
++	} else {
++		trx->take_stats = FALSE;
++	}
++#else
++	trx->take_stats = FALSE;
++#endif
++
+ 	DBUG_VOID_RETURN;
+ }
+ 
+@@ -1446,6 +1456,32 @@
+ }
+ 
+ 
++/*************************************************************************
++Gets current trx. */
++extern "C"
++trx_t*
++innobase_get_trx()
++{
++	THD *thd=current_thd;
++	if (likely(thd != 0)) {
++		trx_t*& trx = thd_to_trx(thd);
++		return(trx);
++	} else {
++		return(NULL);
++	}
++}
++
++extern "C"
++ibool
++innobase_get_slow_log()
++{
++#ifdef EXTENDED_SLOWLOG
++	return((ibool) thd_opt_slow_log());
++#else
++	return(FALSE);
++#endif
++}
++
+ /*********************************************************************//**
+ Construct ha_innobase handler. */
+ UNIV_INTERN
+@@ -9030,6 +9066,25 @@
+ 	statement has ended */
+ 
+ 	if (trx->n_mysql_tables_in_use == 0) {
++#ifdef EXTENDED_SLOWLOG
++		increment_thd_innodb_stats(thd,
++					(unsigned long long) ut_conv_dulint_to_longlong(trx->id),
++					trx->io_reads,
++					trx->io_read,
++					trx->io_reads_wait_timer,
++					trx->lock_que_wait_timer,
++					trx->innodb_que_wait_timer,
++					trx->distinct_page_access);
++
++		trx->io_reads = 0;
++		trx->io_read = 0;
++		trx->io_reads_wait_timer = 0;
++		trx->lock_que_wait_timer = 0;
++		trx->innodb_que_wait_timer = 0;
++		trx->distinct_page_access = 0;
++		if (trx->distinct_page_access_hash)
++			memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
++#endif
+ 
+ 		trx->mysql_n_tables_locked = 0;
+ 		prebuilt->used_in_HANDLER = FALSE;
+diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
+--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 16:30:34.590004526 +0900
++++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 16:30:47.361987777 +0900
+@@ -40,5 +40,6 @@
+ {"innodb_purge_thread","Enable to use purge devoted thread","","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {"innodb_admin_command_base","XtraDB specific command interface through i_s","","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {"innodb_show_lock_name","Show mutex/lock name instead of crated file/line","","http://www.percona.com/docs/wiki/percona-xtradb"},
++{"innodb_extend_slow","Extended statistics in slow.log","It is InnoDB-part only. It needs to patch also to mysqld.","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {NULL, NULL, NULL, NULL}
+ };
+diff -ruN a/storage/innodb_plugin/include/buf0rea.h b/storage/innodb_plugin/include/buf0rea.h
+--- a/storage/innodb_plugin/include/buf0rea.h	2010-08-27 15:54:18.078987755 +0900
++++ b/storage/innodb_plugin/include/buf0rea.h	2010-08-27 16:30:47.363031394 +0900
+@@ -27,6 +27,7 @@
+ #define buf0rea_h
+ 
+ #include "univ.i"
++#include "trx0types.h"
+ #include "buf0types.h"
+ 
+ /********************************************************************//**
+@@ -41,7 +42,8 @@
+ /*==========*/
+ 	ulint	space,	/*!< in: space id */
+ 	ulint	zip_size,/*!< in: compressed page size in bytes, or 0 */
+-	ulint	offset);/*!< in: page number */
++	ulint	offset, /*!< in: page number */
++	trx_t*	trx);
+ /********************************************************************//**
+ Applies linear read-ahead if in the buf_pool the page is a border page of
+ a linear read-ahead area and all the pages in the area have been accessed.
+@@ -72,8 +74,9 @@
+ /*==================*/
+ 	ulint	space,	/*!< in: space id */
+ 	ulint	zip_size,/*!< in: compressed page size in bytes, or 0 */
+-	ulint	offset);/*!< in: page number of a page; NOTE: the current thread
++	ulint	offset, /*!< in: page number of a page; NOTE: the current thread
+ 			must want access to this page (see NOTE 3 above) */
++	trx_t*	trx);
+ /********************************************************************//**
+ Issues read requests for pages which the ibuf module wants to read in, in
+ order to contract the insert buffer tree. Technically, this function is like
+diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/include/fil0fil.h
+--- a/storage/innodb_plugin/include/fil0fil.h	2010-08-27 15:52:14.325059269 +0900
++++ b/storage/innodb_plugin/include/fil0fil.h	2010-08-27 16:30:47.365059512 +0900
+@@ -610,9 +610,12 @@
+ Reads or writes data. This operation is asynchronous (aio).
+ @return DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do
+ i/o on a tablespace which does not exist */
++#define fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message) \
++	_fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message, NULL)
++
+ UNIV_INTERN
+ ulint
+-fil_io(
++_fil_io(
+ /*===*/
+ 	ulint	type,		/*!< in: OS_FILE_READ or OS_FILE_WRITE,
+ 				ORed to OS_FILE_LOG, if a log i/o
+@@ -637,8 +640,9 @@
+ 	void*	buf,		/*!< in/out: buffer where to store read data
+ 				or from where to write; in aio this must be
+ 				appropriately aligned */
+-	void*	message);	/*!< in: message for aio handler if non-sync
++	void*	message,	/*!< in: message for aio handler if non-sync
+ 				aio used, else ignored */
++	trx_t*	trx);
+ /**********************************************************************//**
+ Waits for an aio operation to complete. This function is used to write the
+ handler for completed requests. The aio array of pending requests is divided
+diff -ruN a/storage/innodb_plugin/include/os0file.h b/storage/innodb_plugin/include/os0file.h
+--- a/storage/innodb_plugin/include/os0file.h	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/include/os0file.h	2010-08-27 16:30:47.366987560 +0900
+@@ -36,6 +36,7 @@
+ #define os0file_h
+ 
+ #include "univ.i"
++#include "trx0types.h"
+ 
+ #ifndef __WIN__
+ #include <dirent.h>
+@@ -482,9 +483,12 @@
+ /*******************************************************************//**
+ Requests a synchronous read operation.
+ @return	TRUE if request was successful, FALSE if fail */
++#define os_file_read(file, buf, offset, offset_high, n)         \
++		_os_file_read(file, buf, offset, offset_high, n, NULL)
++
+ UNIV_INTERN
+ ibool
+-os_file_read(
++_os_file_read(
+ /*=========*/
+ 	os_file_t	file,	/*!< in: handle to a file */
+ 	void*		buf,	/*!< in: buffer where to read */
+@@ -492,7 +496,8 @@
+ 				offset where to read */
+ 	ulint		offset_high,/*!< in: most significant 32 bits of
+ 				offset */
+-	ulint		n);	/*!< in: number of bytes to read */
++	ulint		n,	/*!< in: number of bytes to read */
++	trx_t*		trx);
+ /*******************************************************************//**
+ Rewind file to its start, read at most size - 1 bytes from it to str, and
+ NUL-terminate str. All errors are silently ignored. This function is
+@@ -646,10 +651,11 @@
+ 				(can be used to identify a completed
+ 				aio operation); ignored if mode is
+ 				OS_AIO_SYNC */
+-	void*		message2);/*!< in: message for the aio handler
++	void*		message2,/*!< in: message for the aio handler
+ 				(can be used to identify a completed
+ 				aio operation); ignored if mode is
+ 				OS_AIO_SYNC */
++	trx_t*		trx);
+ /************************************************************************//**
+ Wakes up all async i/o threads so that they know to exit themselves in
+ shutdown. */
+diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
+--- a/storage/innodb_plugin/include/srv0srv.h	2010-08-27 16:27:30.225055856 +0900
++++ b/storage/innodb_plugin/include/srv0srv.h	2010-08-27 16:30:47.367988259 +0900
+@@ -62,6 +62,9 @@
+ #define SRV_AUTO_EXTEND_INCREMENT	\
+ 	(srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
+ 
++/* prototypes for new functions added to ha_innodb.cc */
++ibool	innobase_get_slow_log();
++
+ /* This is set to TRUE if the MySQL user has set it in MySQL */
+ extern ibool	srv_lower_case_table_names;
+ 
+diff -ruN a/storage/innodb_plugin/include/trx0trx.h b/storage/innodb_plugin/include/trx0trx.h
+--- a/storage/innodb_plugin/include/trx0trx.h	2010-08-27 16:08:45.301058614 +0900
++++ b/storage/innodb_plugin/include/trx0trx.h	2010-08-27 16:30:47.369989369 +0900
+@@ -738,6 +738,17 @@
+ 	/*------------------------------*/
+ 	char detailed_error[256];	/*!< detailed error message for last
+ 					error, or empty. */
++	/*------------------------------*/
++	ulint		io_reads;
++	ib_uint64_t	io_read;
++	ulint		io_reads_wait_timer;
++	ib_uint64_t	lock_que_wait_ustarted;
++	ulint           lock_que_wait_timer;
++	ulint           innodb_que_wait_timer;
++	ulint           distinct_page_access;
++#define	DPAH_SIZE	8192
++	byte*		distinct_page_access_hash;
++	ibool		take_stats;
+ };
+ 
+ #define TRX_MAX_N_THREADS	32	/* maximum number of
+diff -ruN a/storage/innodb_plugin/lock/lock0lock.c b/storage/innodb_plugin/lock/lock0lock.c
+--- a/storage/innodb_plugin/lock/lock0lock.c	2010-08-27 15:52:14.332058513 +0900
++++ b/storage/innodb_plugin/lock/lock0lock.c	2010-08-27 16:30:47.374058285 +0900
+@@ -1757,6 +1757,8 @@
+ {
+ 	lock_t*	lock;
+ 	trx_t*	trx;
++	ulint   sec;
++	ulint   ms;
+ 
+ 	ut_ad(mutex_own(&kernel_mutex));
+ 
+@@ -1815,6 +1817,10 @@
+ 	trx->que_state = TRX_QUE_LOCK_WAIT;
+ 	trx->was_chosen_as_deadlock_victim = FALSE;
+ 	trx->wait_started = time(NULL);
++	if (innobase_get_slow_log() && trx->take_stats) {
++		ut_usectime(&sec, &ms);
++		trx->lock_que_wait_ustarted = (ib_uint64_t)sec * 1000000 + ms;
++	}
+ 
+ 	ut_a(que_thr_stop(thr));
+ 
+@@ -3767,6 +3773,8 @@
+ {
+ 	lock_t*	lock;
+ 	trx_t*	trx;
++	ulint   sec;
++	ulint   ms;
+ 
+ 	ut_ad(mutex_own(&kernel_mutex));
+ 
+@@ -3822,6 +3830,10 @@
+ 		return(DB_SUCCESS);
+ 	}
+ 
++	if (innobase_get_slow_log() && trx->take_stats) {
++		ut_usectime(&sec, &ms);
++		trx->lock_que_wait_ustarted = (ib_uint64_t)sec * 1000000 + ms;
++	}
+ 	trx->que_state = TRX_QUE_LOCK_WAIT;
+ 	trx->was_chosen_as_deadlock_victim = FALSE;
+ 	trx->wait_started = time(NULL);
+diff -ruN a/storage/innodb_plugin/os/os0file.c b/storage/innodb_plugin/os/os0file.c
+--- a/storage/innodb_plugin/os/os0file.c	2010-08-27 16:23:31.038058669 +0900
++++ b/storage/innodb_plugin/os/os0file.c	2010-08-27 16:30:47.380058815 +0900
+@@ -38,6 +38,8 @@
+ #include "srv0start.h"
+ #include "fil0fil.h"
+ #include "buf0buf.h"
++#include "trx0sys.h"
++#include "trx0trx.h"
+ #include "log0recv.h"
+ #ifndef UNIV_HOTBACKUP
+ # include "os0sync.h"
+@@ -2087,22 +2089,30 @@
+ /*******************************************************************//**
+ Does a synchronous read operation in Posix.
+ @return	number of bytes read, -1 if error */
++#define os_file_pread(file, buf, n, offset, offset_high)        \
++		_os_file_pread(file, buf, n, offset, offset_high, NULL);
++
+ static
+ ssize_t
+-os_file_pread(
++_os_file_pread(
+ /*==========*/
+ 	os_file_t	file,	/*!< in: handle to a file */
+ 	void*		buf,	/*!< in: buffer where to read */
+ 	ulint		n,	/*!< in: number of bytes to read */
+ 	ulint		offset,	/*!< in: least significant 32 bits of file
+ 				offset from where to read */
+-	ulint		offset_high) /*!< in: most significant 32 bits of
++	ulint		offset_high, /*!< in: most significant 32 bits of
+ 				offset */
++	trx_t*		trx)
+ {
+ 	off_t	offs;
+ #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
+ 	ssize_t	n_bytes;
+ #endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
++	ulint		sec;
++	ulint		ms;
++	ib_uint64_t	start_time;
++	ib_uint64_t	finish_time;
+ 
+ 	ut_a((offset & 0xFFFFFFFFUL) == offset);
+ 
+@@ -2123,6 +2133,15 @@
+ 
+ 	os_n_file_reads++;
+ 
++	if (innobase_get_slow_log() && trx && trx->take_stats)
++	{
++	        trx->io_reads++;
++		trx->io_read += n;
++		ut_usectime(&sec, &ms);
++		start_time = (ib_uint64_t)sec * 1000000 + ms;
++	} else {
++		start_time = 0;
++	}
+ #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
+ 	os_mutex_enter(os_file_count_mutex);
+ 	os_file_n_pending_preads++;
+@@ -2136,6 +2155,13 @@
+ 	os_n_pending_reads--;
+ 	os_mutex_exit(os_file_count_mutex);
+ 
++	if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
++	{
++		ut_usectime(&sec, &ms);
++		finish_time = (ib_uint64_t)sec * 1000000 + ms;
++		trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
++	}
++
+ 	return(n_bytes);
+ #else
+ 	{
+@@ -2172,6 +2198,13 @@
+ 		os_n_pending_reads--;
+ 		os_mutex_exit(os_file_count_mutex);
+ 
++		if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
++		{
++			ut_usectime(&sec, &ms);
++			finish_time = (ib_uint64_t)sec * 1000000 + ms;
++			trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
++		}
++
+ 		return(ret);
+ 	}
+ #endif
+@@ -2302,7 +2335,7 @@
+ @return	TRUE if request was successful, FALSE if fail */
+ UNIV_INTERN
+ ibool
+-os_file_read(
++_os_file_read(
+ /*=========*/
+ 	os_file_t	file,	/*!< in: handle to a file */
+ 	void*		buf,	/*!< in: buffer where to read */
+@@ -2310,7 +2343,8 @@
+ 				offset where to read */
+ 	ulint		offset_high, /*!< in: most significant 32 bits of
+ 				offset */
+-	ulint		n)	/*!< in: number of bytes to read */
++	ulint		n,	/*!< in: number of bytes to read */
++	trx_t*		trx)
+ {
+ #ifdef __WIN__
+ 	BOOL		ret;
+@@ -2385,7 +2419,7 @@
+ 	os_bytes_read_since_printout += n;
+ 
+ try_again:
+-	ret = os_file_pread(file, buf, n, offset, offset_high);
++	ret = _os_file_pread(file, buf, n, offset, offset_high, trx);
+ 
+ 	if ((ulint)ret == n) {
+ 
+@@ -3642,10 +3676,11 @@
+ 				(can be used to identify a completed
+ 				aio operation); ignored if mode is
+ 				OS_AIO_SYNC */
+-	void*		message2)/*!< in: message for the aio handler
++	void*		message2,/*!< in: message for the aio handler
+ 				(can be used to identify a completed
+ 				aio operation); ignored if mode is
+ 				OS_AIO_SYNC */
++	trx_t*		trx)
+ {
+ 	os_aio_array_t*	array;
+ 	os_aio_slot_t*	slot;
+@@ -3687,8 +3722,8 @@
+ 		wait in the Windows case. */
+ 
+ 		if (type == OS_FILE_READ) {
+-			return(os_file_read(file, buf, offset,
+-					    offset_high, n));
++			return(_os_file_read(file, buf, offset,
++					    offset_high, n, trx));
+ 		}
+ 
+ 		ut_a(type == OS_FILE_WRITE);
+@@ -3721,6 +3756,11 @@
+ 		ut_error;
+ 	}
+ 
++	if (trx && type == OS_FILE_READ)
++	{
++		trx->io_reads++;
++		trx->io_read += n;
++	}
+ 	slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
+ 					 name, buf, offset, offset_high, n);
+ 	if (type == OS_FILE_READ) {
+diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
+--- a/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 16:27:30.233022109 +0900
++++ b/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 16:30:47.384058509 +0900
+@@ -86,6 +86,9 @@
+ #include "trx0i_s.h"
+ #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */
+ 
++/* prototypes for new functions added to ha_innodb.cc */
++ibool	innobase_get_slow_log();
++
+ /* This is set to TRUE if the MySQL user has set it in MySQL; currently
+ affects only FOREIGN KEY definition parsing */
+ UNIV_INTERN ibool	srv_lower_case_table_names	= FALSE;
+@@ -1159,6 +1162,10 @@
+ 	ibool			has_slept = FALSE;
+ 	srv_conc_slot_t*	slot	  = NULL;
+ 	ulint			i;
++	ib_uint64_t             start_time = 0L;
++	ib_uint64_t             finish_time = 0L;
++	ulint                   sec;
++	ulint                   ms;
+ 
+ 	if (trx->mysql_thd != NULL
+ 	    && thd_is_replication_slave_thread(trx->mysql_thd)) {
+@@ -1235,6 +1242,7 @@
+ 		switches. */
+ 		if (SRV_THREAD_SLEEP_DELAY > 0) {
+ 			os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
++			trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
+ 		}
+ 
+ 		trx->op_info = "";
+@@ -1290,12 +1298,25 @@
+ 	/* Go to wait for the event; when a thread leaves InnoDB it will
+ 	release this thread */
+ 
++	if (innobase_get_slow_log() && trx->take_stats) {
++		ut_usectime(&sec, &ms);
++		start_time = (ib_uint64_t)sec * 1000000 + ms;
++	} else {
++		start_time = 0;
++	}
++
+ 	trx->op_info = "waiting in InnoDB queue";
+ 
+ 	os_event_wait(slot->event);
+ 
+ 	trx->op_info = "";
+ 
++	if (innobase_get_slow_log() && trx->take_stats && start_time) {
++		ut_usectime(&sec, &ms);
++		finish_time = (ib_uint64_t)sec * 1000000 + ms;
++		trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
++	}
++
+ 	os_fast_mutex_lock(&srv_conc_mutex);
+ 
+ 	srv_conc_n_waiting_threads--;
+diff -ruN a/storage/innodb_plugin/trx/trx0trx.c b/storage/innodb_plugin/trx/trx0trx.c
+--- a/storage/innodb_plugin/trx/trx0trx.c	2010-08-27 16:08:45.306058896 +0900
++++ b/storage/innodb_plugin/trx/trx0trx.c	2010-08-27 16:30:47.387058330 +0900
+@@ -179,6 +179,15 @@
+ 	trx->global_read_view = NULL;
+ 	trx->read_view = NULL;
+ 
++	trx->io_reads = 0;
++	trx->io_read = 0;
++	trx->io_reads_wait_timer = 0;
++	trx->lock_que_wait_timer = 0;
++	trx->innodb_que_wait_timer = 0;
++	trx->distinct_page_access = 0;
++	trx->distinct_page_access_hash = NULL;
++	trx->take_stats = FALSE;
++
+ 	/* Set X/Open XA transaction identification to NULL */
+ 	memset(&trx->xid, 0, sizeof(trx->xid));
+ 	trx->xid.formatID = -1;
+@@ -216,6 +225,11 @@
+ 
+ 	trx->mysql_process_no = os_proc_get_number();
+ 
++	if (innobase_get_slow_log() && trx->take_stats) {
++		trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
++		memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
++	}
++
+ 	return(trx);
+ }
+ 
+@@ -347,6 +361,12 @@
+ /*===============*/
+ 	trx_t*	trx)	/*!< in, own: trx object */
+ {
++	if (trx->distinct_page_access_hash)
++	{
++		mem_free(trx->distinct_page_access_hash);
++		trx->distinct_page_access_hash= NULL;
++	}
++
+ 	mutex_enter(&kernel_mutex);
+ 
+ 	UT_LIST_REMOVE(mysql_trx_list, trx_sys->mysql_trx_list, trx);
+@@ -368,6 +388,12 @@
+ /*====================*/
+ 	trx_t*	trx)	/*!< in, own: trx object */
+ {
++	if (trx->distinct_page_access_hash)
++	{
++		mem_free(trx->distinct_page_access_hash);
++		trx->distinct_page_access_hash= NULL;
++	}
++
+ 	mutex_enter(&kernel_mutex);
+ 
+ 	trx_free(trx);
+@@ -1093,6 +1119,9 @@
+ 	trx_t*	trx)	/*!< in: transaction */
+ {
+ 	que_thr_t*	thr;
++	ulint           sec;
++	ulint           ms;
++	ib_uint64_t     now;
+ 
+ 	ut_ad(mutex_own(&kernel_mutex));
+ 	ut_ad(trx->que_state == TRX_QUE_LOCK_WAIT);
+@@ -1107,6 +1136,11 @@
+ 		thr = UT_LIST_GET_FIRST(trx->wait_thrs);
+ 	}
+ 
++	if (innobase_get_slow_log() && trx->take_stats) {
++		ut_usectime(&sec, &ms);
++		now = (ib_uint64_t)sec * 1000000 + ms;
++		trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
++	}
+ 	trx->que_state = TRX_QUE_RUNNING;
+ }
+ 
+@@ -1120,6 +1154,9 @@
+ 	trx_t*	trx)	/*!< in: transaction in the TRX_QUE_LOCK_WAIT state */
+ {
+ 	que_thr_t*	thr;
++	ulint           sec;
++	ulint           ms;
++	ib_uint64_t     now;
+ 
+ 	ut_ad(mutex_own(&kernel_mutex));
+ 	ut_ad(trx->que_state == TRX_QUE_LOCK_WAIT);
+@@ -1134,6 +1171,11 @@
+ 		thr = UT_LIST_GET_FIRST(trx->wait_thrs);
+ 	}
+ 
++	if (innobase_get_slow_log() && trx->take_stats) {
++		ut_usectime(&sec, &ms);
++		now = (ib_uint64_t)sec * 1000000 + ms;
++		trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
++	}
+ 	trx->que_state = TRX_QUE_RUNNING;
+ }
+ 
diff --git a/mysql-innodb_extra_rseg.patch b/mysql-innodb_extra_rseg.patch
new file mode 100644
index 0000000..837d8b9
--- /dev/null
+++ b/mysql-innodb_extra_rseg.patch
@@ -0,0 +1,395 @@
+# name       : innodb_extra_rseg.patch
+# introduced : 11 or before
+# maintainer : Yasufumi
+#
+#!!! notice !!!
+# Any small change to this file in the main branch
+# should be done or reviewed by the maintainer!
+diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
+--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 15:56:27.388990435 +0900
++++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 15:57:21.943242617 +0900
+@@ -11177,6 +11177,11 @@
+   "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
+   NULL, NULL, 0, 0, 1, 0);
+ 
++static MYSQL_SYSVAR_ULONG(extra_rsegments, srv_extra_rsegments,
++  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
++  "Number of extra user rollback segments when create new database.",
++  NULL, NULL, 0, 0, 126, 0);
++
+ static struct st_mysql_sys_var* innobase_system_variables[]= {
+   MYSQL_SYSVAR(additional_mem_pool_size),
+   MYSQL_SYSVAR(autoextend_increment),
+@@ -11242,6 +11247,7 @@
+   MYSQL_SYSVAR(adaptive_checkpoint),
+   MYSQL_SYSVAR(flush_log_at_trx_commit_session),
+   MYSQL_SYSVAR(enable_unsafe_group_commit),
++  MYSQL_SYSVAR(extra_rsegments),
+   MYSQL_SYSVAR(use_sys_malloc),
+   MYSQL_SYSVAR(change_buffering),
+ #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
+@@ -11267,6 +11273,7 @@
+   innobase_system_variables, /* system variables */
+   NULL /* reserved */
+ },
++i_s_innodb_rseg,
+ i_s_innodb_buffer_pool_pages,
+ i_s_innodb_buffer_pool_pages_index,
+ i_s_innodb_buffer_pool_pages_blob,
+diff -ruN a/storage/innodb_plugin/handler/i_s.cc b/storage/innodb_plugin/handler/i_s.cc
+--- a/storage/innodb_plugin/handler/i_s.cc	2010-08-27 15:55:39.396056760 +0900
++++ b/storage/innodb_plugin/handler/i_s.cc	2010-08-27 15:57:21.946209184 +0900
+@@ -43,6 +43,8 @@
+ #include "ha_prototypes.h" /* for innobase_convert_name() */
+ #include "srv0start.h" /* for srv_was_started */
+ #include "btr0btr.h" /* for btr_page_get_index_id */
++#include "trx0rseg.h" /* for trx_rseg_struct */
++#include "trx0sys.h" /* for trx_sys */
+ }
+ 
+ static const char plugin_author[] = "Innobase Oy";
+@@ -2435,3 +2437,166 @@
+ 
+ 	DBUG_RETURN(0);
+ }
++
++/***********************************************************************
++*/
++static ST_FIELD_INFO	i_s_innodb_rseg_fields_info[] =
++{
++	{STRUCT_FLD(field_name,		"rseg_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)},
++
++	{STRUCT_FLD(field_name,		"space_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)},
++
++	{STRUCT_FLD(field_name,		"zip_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)},
++
++	{STRUCT_FLD(field_name,		"page_no"),
++	 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)},
++
++	{STRUCT_FLD(field_name,		"max_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)},
++
++	{STRUCT_FLD(field_name,		"curr_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)},
++
++	END_OF_ST_FIELD_INFO
++};
++
++static
++int
++i_s_innodb_rseg_fill(
++/*=================*/
++	THD*		thd,	/* in: thread */
++	TABLE_LIST*	tables,	/* in/out: tables to fill */
++	COND*		cond)	/* in: condition (ignored) */
++{
++	TABLE*	table	= (TABLE *) tables->table;
++	int	status	= 0;
++	trx_rseg_t*	rseg;
++
++	DBUG_ENTER("i_s_innodb_rseg_fill");
++
++	/* deny access to non-superusers */
++	if (check_global_access(thd, PROCESS_ACL)) {
++
++		DBUG_RETURN(0);
++	}
++
++	RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
++
++	rseg = UT_LIST_GET_FIRST(trx_sys->rseg_list);
++
++	while (rseg) {
++		table->field[0]->store(rseg->id);
++		table->field[1]->store(rseg->space);
++		table->field[2]->store(rseg->zip_size);
++		table->field[3]->store(rseg->page_no);
++		table->field[4]->store(rseg->max_size);
++		table->field[5]->store(rseg->curr_size);
++
++		if (schema_table_store_record(thd, table)) {
++			status = 1;
++			break;
++		}
++
++		rseg = UT_LIST_GET_NEXT(rseg_list, rseg);
++	}
++
++	DBUG_RETURN(status);
++}
++
++static
++int
++i_s_innodb_rseg_init(
++/*=================*/
++			/* out: 0 on success */
++	void*	p)	/* in/out: table schema object */
++{
++	DBUG_ENTER("i_s_innodb_rseg_init");
++	ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p;
++
++	schema->fields_info = i_s_innodb_rseg_fields_info;
++	schema->fill_table = i_s_innodb_rseg_fill;
++
++	DBUG_RETURN(0);
++}
++
++UNIV_INTERN struct st_mysql_plugin	i_s_innodb_rseg =
++{
++	/* 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_RSEG"),
++
++	/* plugin author (for SHOW PLUGINS) */
++	/* const char* */
++	STRUCT_FLD(author, "Percona"),
++
++	/* general descriptive text (for SHOW PLUGINS) */
++	/* const char* */
++	STRUCT_FLD(descr, "InnoDB rollback segment 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_rseg_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, 0x0100 /* 1.0 */),
++
++	/* 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)
++};
+diff -ruN a/storage/innodb_plugin/handler/i_s.h b/storage/innodb_plugin/handler/i_s.h
+--- a/storage/innodb_plugin/handler/i_s.h	2010-08-27 15:55:39.398061420 +0900
++++ b/storage/innodb_plugin/handler/i_s.h	2010-08-27 15:57:21.948402335 +0900
+@@ -37,5 +37,6 @@
+ 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_patches;
++extern struct st_mysql_plugin	i_s_innodb_rseg;
+ 
+ #endif /* i_s_h */
+diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
+--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 15:56:27.390020919 +0900
++++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 15:57:21.943242617 +0900
+@@ -29,5 +29,6 @@
+ {"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"},
++{"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {NULL, NULL, NULL, NULL}
+ };
+diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
+--- a/storage/innodb_plugin/include/srv0srv.h	2010-08-27 15:56:27.391059197 +0900
++++ b/storage/innodb_plugin/include/srv0srv.h	2010-08-27 15:57:21.949178913 +0900
+@@ -216,6 +216,8 @@
+ extern ulint	srv_read_ahead;
+ extern ulint	srv_adaptive_checkpoint;
+ 
++extern ulint	srv_extra_rsegments;
++
+ /*-------------------------------------------*/
+ 
+ extern ulint	srv_n_rows_inserted;
+diff -ruN a/storage/innodb_plugin/include/trx0rseg.h b/storage/innodb_plugin/include/trx0rseg.h
+--- a/storage/innodb_plugin/include/trx0rseg.h	2010-08-27 15:56:27.392056954 +0900
++++ b/storage/innodb_plugin/include/trx0rseg.h	2010-08-27 15:57:21.951103043 +0900
+@@ -114,6 +114,17 @@
+ /*=========================*/
+ 	trx_sysf_t*	sys_header,	/*!< in: trx system header */
+ 	mtr_t*		mtr);		/*!< in: mtr */
++/****************************************************************//**
++Creates a new rollback segment to the database.
++ at return	the created segment object, NULL if fail */
++UNIV_INTERN
++trx_rseg_t*
++trx_rseg_create(
++/*============*/
++	ulint	space,		/*!< in: space id */
++	ulint	max_size,	/*!< in: max size in pages */
++	ulint*	id,		/*!< out: rseg id */
++	mtr_t*	mtr);		/*!< in: mtr */
+ /***************************************************************************
+ Free's an instance of the rollback segment in memory. */
+ UNIV_INTERN
+diff -ruN a/storage/innodb_plugin/include/trx0sys.h b/storage/innodb_plugin/include/trx0sys.h
+--- a/storage/innodb_plugin/include/trx0sys.h	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/include/trx0sys.h	2010-08-27 15:57:21.952410637 +0900
+@@ -134,6 +134,13 @@
+ void
+ trx_sys_create(void);
+ /*================*/
++/*********************************************************************
++Create extra rollback segments when create_new_db */
++UNIV_INTERN
++void
++trx_sys_create_extra_rseg(
++/*======================*/
++	ulint	num);	/* in: number of extra user rollback segments */
+ /****************************************************************//**
+ Looks for a free slot for a rollback segment in the trx system file copy.
+ @return	slot index or ULINT_UNDEFINED if not found */
+diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
+--- a/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 15:56:27.393071672 +0900
++++ b/storage/innodb_plugin/srv/srv0srv.c	2010-08-27 15:57:21.956058333 +0900
+@@ -388,6 +388,8 @@
+ UNIV_INTERN ulint	srv_enable_unsafe_group_commit = 0; /* 0:disable 1:enable */
+ UNIV_INTERN ulint	srv_read_ahead = 3; /* 1: random  2: linear  3: Both */
+ UNIV_INTERN ulint	srv_adaptive_checkpoint = 0; /* 0: none  1: reflex  2: estimate */
++
++UNIV_INTERN ulint	srv_extra_rsegments = 0; /* extra rseg for users */
+ /*-------------------------------------------*/
+ UNIV_INTERN ulong	srv_n_spin_wait_rounds	= 30;
+ UNIV_INTERN ulong	srv_n_free_tickets_to_enter = 500;
+diff -ruN a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
+--- a/storage/innodb_plugin/srv/srv0start.c	2010-08-27 15:54:18.103988092 +0900
++++ b/storage/innodb_plugin/srv/srv0start.c	2010-08-27 15:57:21.959058733 +0900
+@@ -1533,6 +1533,14 @@
+ 		dict_create();
+ 		srv_startup_is_before_trx_rollback_phase = FALSE;
+ 
++		if (trx_doublewrite == NULL) {
++			/* Create the doublewrite buffer here to avoid assertion error
++			   about page_no of doublewrite_buf */
++			trx_sys_create_doublewrite_buf();
++		}
++
++		if (srv_extra_rsegments)
++			trx_sys_create_extra_rseg(srv_extra_rsegments);
+ #ifdef UNIV_LOG_ARCHIVE
+ 	} else if (srv_archive_recovery) {
+ 		fprintf(stderr,
+diff -ruN a/storage/innodb_plugin/trx/trx0rseg.c b/storage/innodb_plugin/trx/trx0rseg.c
+--- a/storage/innodb_plugin/trx/trx0rseg.c	2010-08-04 02:24:20.000000000 +0900
++++ b/storage/innodb_plugin/trx/trx0rseg.c	2010-08-27 15:57:21.961059126 +0900
+@@ -286,3 +286,39 @@
+ 		}
+ 	}
+ }
++
++/****************************************************************//**
++Creates a new rollback segment to the database.
++ at return	the created segment object, NULL if fail */
++UNIV_INTERN
++trx_rseg_t*
++trx_rseg_create(
++/*============*/
++	ulint	space,		/*!< in: space id */
++	ulint	max_size,	/*!< in: max size in pages */
++	ulint*	id,		/*!< out: rseg id */
++	mtr_t*	mtr)		/*!< in: mtr */
++{
++	ulint		flags;
++	ulint		zip_size;
++	ulint		page_no;
++	trx_rseg_t*	rseg;
++
++	mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
++	zip_size = dict_table_flags_to_zip_size(flags);
++	mutex_enter(&kernel_mutex);
++
++	page_no = trx_rseg_header_create(space, zip_size, max_size, id, mtr);
++
++	if (page_no == FIL_NULL) {
++
++		mutex_exit(&kernel_mutex);
++		return(NULL);
++	}
++
++	rseg = trx_rseg_mem_create(*id, space, zip_size, page_no, mtr);
++
++	mutex_exit(&kernel_mutex);
++
++	return(rseg);
++}
+diff -ruN a/storage/innodb_plugin/trx/trx0sys.c b/storage/innodb_plugin/trx/trx0sys.c
+--- a/storage/innodb_plugin/trx/trx0sys.c	2010-08-04 02:24:20.000000000 +0900
++++ b/storage/innodb_plugin/trx/trx0sys.c	2010-08-27 15:57:21.963058358 +0900
+@@ -1044,6 +1044,31 @@
+ 	trx_sys_init_at_db_start();
+ }
+ 
++/*********************************************************************
++Create extra rollback segments when create_new_db */
++UNIV_INTERN
++void
++trx_sys_create_extra_rseg(
++/*======================*/
++	ulint	num)	/* in: number of extra user rollback segments */
++{
++	mtr_t	mtr;
++	ulint	slot_no;
++	ulint	i;
++
++	/* Craete extra rollback segments */
++	mtr_start(&mtr);
++	for (i = 1; i < num + 1; i++) {
++		if(!trx_rseg_create(TRX_SYS_SPACE, ULINT_MAX, &slot_no, &mtr)) {
++			fprintf(stderr,
++"InnoDB: Warning: Failed to create extra rollback segments.\n");
++			break;
++		}
++		ut_a(slot_no == i);
++	}
++	mtr_commit(&mtr);
++}
++
+ /*****************************************************************//**
+ Update the file format tag.
+ @return	always TRUE */
diff --git a/mysql-innodb_io_patches.patch b/mysql-innodb_io_patches.patch
new file mode 100644
index 0000000..ab7db76
--- /dev/null
+++ b/mysql-innodb_io_patches.patch
@@ -0,0 +1,1520 @@
+# name       : innodb_io_patches.patch
+# introduced : 11 or before
+# maintainer : Yasufumi
+#
+#!!! notice !!!
+# Any small change to this file in the main branch
+# should be done or reviewed by the maintainer!
+diff -ruN a/storage/innodb_plugin/buf/buf0flu.c b/storage/innodb_plugin/buf/buf0flu.c
+--- a/storage/innodb_plugin/buf/buf0flu.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/buf/buf0flu.c	2010-08-27 15:52:29.282007496 +0900
+@@ -1238,8 +1238,9 @@
+ /*====================*/
+ 	ulint		space,		/*!< in: space id */
+ 	ulint		offset,		/*!< in: page offset */
+-	enum buf_flush	flush_type)	/*!< in: BUF_FLUSH_LRU or
++	enum buf_flush	flush_type,	/*!< in: BUF_FLUSH_LRU or
+ 					BUF_FLUSH_LIST */
++	ulint		flush_neighbors)
+ {
+ 	buf_page_t*	bpage;
+ 	ulint		low, high;
+@@ -1248,7 +1249,7 @@
+ 
+ 	ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
+ 
+-	if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN) {
++	if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN || !flush_neighbors) {
+ 		/* If there is little space, it is better not to flush any
+ 		block except from the end of the LRU list */
+ 
+@@ -1420,7 +1421,7 @@
+ 
+ 				/* Try to flush also all the neighbors */
+ 				page_count += buf_flush_try_neighbors(
+-					space, offset, flush_type);
++					space, offset, flush_type, srv_flush_neighbor_pages);
+ 
+ 				buf_pool_mutex_enter();
+ 				goto flush_next;
+diff -ruN a/storage/innodb_plugin/buf/buf0rea.c b/storage/innodb_plugin/buf/buf0rea.c
+--- a/storage/innodb_plugin/buf/buf0rea.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/buf/buf0rea.c	2010-08-27 15:52:29.282007496 +0900
+@@ -254,6 +254,10 @@
+ 		= BUF_READ_AHEAD_LINEAR_AREA;
+ 	ulint		threshold;
+ 
++ 	if (!(srv_read_ahead & 2)) {
++ 		return(0);
++ 	}
++
+ 	if (UNIV_UNLIKELY(srv_startup_is_before_trx_rollback_phase)) {
+ 		/* No read-ahead to avoid thread deadlocks */
+ 		return(0);
+diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
+--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 15:52:14.318058668 +0900
++++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-27 15:52:29.291123270 +0900
+@@ -332,6 +332,12 @@
+   "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
+   NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
+ 
++static MYSQL_THDVAR_ULONG(flush_log_at_trx_commit_session, PLUGIN_VAR_RQCMDARG,
++  "Control innodb_flush_log_at_trx_commit for each sessions. "
++  "The value 0~2 are same meanings to innodb_flush_log_at_trx_commit. "
++  "The value 3 regards innodb_flush_log_at_trx_commit (default).",
++  NULL, NULL, 3, 0, 3, 0);
++
+ 
+ static handler *innobase_create_handler(handlerton *hton,
+                                         TABLE_SHARE *table,
+@@ -708,6 +714,17 @@
+ 	return(THDVAR((THD*) thd, lock_wait_timeout));
+ }
+ 
++/******************************************************************//**
++*/
++extern "C" UNIV_INTERN
++ulong
++thd_flush_log_at_trx_commit_session(
++/*================================*/
++	void*	thd)
++{
++	return(THDVAR((THD*) thd, flush_log_at_trx_commit_session));
++}
++
+ /********************************************************************//**
+ Obtain the InnoDB transaction of a MySQL thread.
+ @return	reference to transaction pointer */
+@@ -2232,6 +2249,9 @@
+ 	srv_n_read_io_threads = (ulint) innobase_read_io_threads;
+ 	srv_n_write_io_threads = (ulint) innobase_write_io_threads;
+ 
++	srv_read_ahead &= 3;
++	srv_adaptive_checkpoint %= 4;
++
+ 	srv_force_recovery = (ulint) innobase_force_recovery;
+ 
+ 	srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
+@@ -9932,6 +9952,10 @@
+ 	if (thd_sql_command(thd) != SQLCOM_XA_PREPARE &&
+ 	    (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+ 	{
++		if (srv_enable_unsafe_group_commit && !THDVAR(thd, support_xa)) {
++			/* choose group commit rather than binlog order */
++			return(error);
++		}
+ 
+ 		/* For ibbackup to work the order of transactions in binlog
+ 		and InnoDB must be the same. Consider the situation
+@@ -10905,7 +10929,7 @@
+ static MYSQL_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
+   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+   "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
+-  NULL, NULL, 128*1024*1024L, 5*1024*1024L, LONGLONG_MAX, 1024*1024L);
++  NULL, NULL, 128*1024*1024L, 32*1024*1024L, LONGLONG_MAX, 1024*1024L);
+ 
+ static MYSQL_SYSVAR_ULONG(commit_concurrency, innobase_commit_concurrency,
+   PLUGIN_VAR_RQCMDARG,
+@@ -11047,6 +11071,102 @@
+   "trigger a readahead.",
+   NULL, NULL, 56, 0, 64, 0);
+ 
++static MYSQL_SYSVAR_LONGLONG(ibuf_max_size, srv_ibuf_max_size,
++  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
++  "The maximum size of the insert buffer. (in bytes)",
++  NULL, NULL, LONGLONG_MAX, 0, LONGLONG_MAX, 0);
++
++static MYSQL_SYSVAR_ULONG(ibuf_active_contract, srv_ibuf_active_contract,
++  PLUGIN_VAR_RQCMDARG,
++  "Enable/Disable active_contract of insert buffer. 0:disable 1:enable",
++  NULL, NULL, 0, 0, 1, 0);
++
++static MYSQL_SYSVAR_ULONG(ibuf_accel_rate, srv_ibuf_accel_rate,
++  PLUGIN_VAR_RQCMDARG,
++  "Tunes amount of insert buffer processing of background, in addition to innodb_io_capacity. (in percentage)",
++  NULL, NULL, 100, 100, 999999999, 0);
++
++static MYSQL_SYSVAR_ULONG(checkpoint_age_target, srv_checkpoint_age_target,
++  PLUGIN_VAR_RQCMDARG,
++  "Control soft limit of checkpoint age. (0 : not control)",
++  NULL, NULL, 0, 0, ~0UL, 0);
++
++static MYSQL_SYSVAR_ULONG(flush_neighbor_pages, srv_flush_neighbor_pages,
++  PLUGIN_VAR_RQCMDARG,
++  "Enable/Disable flushing also neighbor pages. 0:disable 1:enable",
++  NULL, NULL, 1, 0, 1, 0);
++
++static
++void
++innodb_read_ahead_update(
++  THD* thd,
++  struct st_mysql_sys_var*     var,
++  void*        var_ptr,
++  const void*  save)
++{
++  *(long *)var_ptr= (*(long *)save) & 3;
++}
++const char *read_ahead_names[]=
++{
++  "none", /* 0 */
++  "random",
++  "linear",
++  "both", /* 3 */
++  /* For compatibility of the older patch */
++  "0", /* 4 ("none" + 4) */
++  "1",
++  "2",
++  "3", /* 7 ("both" + 4) */
++  NullS
++};
++TYPELIB read_ahead_typelib=
++{
++  array_elements(read_ahead_names) - 1, "read_ahead_typelib",
++  read_ahead_names, NULL
++};
++static MYSQL_SYSVAR_ENUM(read_ahead, srv_read_ahead,
++  PLUGIN_VAR_RQCMDARG,
++  "Control read ahead activity (none, random, [linear], both). [from 1.0.5: random read ahead is ignored]",
++  NULL, innodb_read_ahead_update, 2, &read_ahead_typelib);
++
++static
++void
++innodb_adaptive_checkpoint_update(
++  THD* thd,
++  struct st_mysql_sys_var*     var,
++  void*        var_ptr,
++  const void*  save)
++{
++  *(long *)var_ptr= (*(long *)save) % 4;
++}
++const char *adaptive_checkpoint_names[]=
++{
++  "none", /* 0 */
++  "reflex", /* 1 */
++  "estimate", /* 2 */
++  "keep_average", /* 3 */
++  /* For compatibility of the older patch */
++  "0", /* 4 ("none" + 3) */
++  "1", /* 5 ("reflex" + 3) */
++  "2", /* 6 ("estimate" + 3) */
++  "3", /* 7 ("keep_average" + 4) */
++  NullS
++};
++TYPELIB adaptive_checkpoint_typelib=
++{
++  array_elements(adaptive_checkpoint_names) - 1, "adaptive_checkpoint_typelib",
++  adaptive_checkpoint_names, NULL
++};
++static MYSQL_SYSVAR_ENUM(adaptive_checkpoint, srv_adaptive_checkpoint,
++  PLUGIN_VAR_RQCMDARG,
++  "Enable/Disable flushing along modified age. ([none], reflex, estimate, keep_average)",
++  NULL, innodb_adaptive_checkpoint_update, 0, &adaptive_checkpoint_typelib);
++
++static MYSQL_SYSVAR_ULONG(enable_unsafe_group_commit, srv_enable_unsafe_group_commit,
++  PLUGIN_VAR_RQCMDARG,
++  "Enable/Disable unsafe group commit when support_xa=OFF and use with binlog or other XA storage engine.",
++  NULL, NULL, 0, 0, 1, 0);
++
+ static struct st_mysql_sys_var* innobase_system_variables[]= {
+   MYSQL_SYSVAR(additional_mem_pool_size),
+   MYSQL_SYSVAR(autoextend_increment),
+@@ -11102,6 +11222,15 @@
+   MYSQL_SYSVAR(show_verbose_locks),
+   MYSQL_SYSVAR(show_locks_held),
+   MYSQL_SYSVAR(version),
++  MYSQL_SYSVAR(ibuf_max_size),
++  MYSQL_SYSVAR(ibuf_active_contract),
++  MYSQL_SYSVAR(ibuf_accel_rate),
++  MYSQL_SYSVAR(checkpoint_age_target),
++  MYSQL_SYSVAR(flush_neighbor_pages),
++  MYSQL_SYSVAR(read_ahead),
++  MYSQL_SYSVAR(adaptive_checkpoint),
++  MYSQL_SYSVAR(flush_log_at_trx_commit_session),
++  MYSQL_SYSVAR(enable_unsafe_group_commit),
+   MYSQL_SYSVAR(use_sys_malloc),
+   MYSQL_SYSVAR(change_buffering),
+ #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
+diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
+--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 15:52:14.323071350 +0900
++++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-27 15:52:29.296058625 +0900
+@@ -25,5 +25,6 @@
+ }innodb_enhancements[] = {
+ {"xtradb_show_enhancements","I_S.XTRADB_ENHANCEMENTS","","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {"innodb_show_status","Improvements to SHOW INNODB STATUS","Memory information and lock info fixes","http://www.percona.com/docs/wiki/percona-xtradb"},
++{"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"},
+ {NULL, NULL, NULL, NULL}
+ };
+diff -ruN a/storage/innodb_plugin/ibuf/ibuf0ibuf.c b/storage/innodb_plugin/ibuf/ibuf0ibuf.c
+--- a/storage/innodb_plugin/ibuf/ibuf0ibuf.c	2010-08-04 02:24:19.000000000 +0900
++++ b/storage/innodb_plugin/ibuf/ibuf0ibuf.c	2010-08-27 15:52:29.299059959 +0900
+@@ -464,8 +464,10 @@
+ 	grow in size, as the references on the upper levels of the tree can
+ 	change */
+ 
+-	ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
+-		/ IBUF_POOL_SIZE_PER_MAX_SIZE;
++	ibuf->max_size = ut_min( buf_pool_get_curr_size() / UNIV_PAGE_SIZE
++		/ IBUF_POOL_SIZE_PER_MAX_SIZE, (ulint) srv_ibuf_max_size / UNIV_PAGE_SIZE);
++
++	srv_ibuf_max_size = (long long) ibuf->max_size * UNIV_PAGE_SIZE;
<Skipped 20809 lines>
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/percona-server.git/commitdiff/bf636d07b36bfd2921b9ecf2033c78270355c98c




More information about the pld-cvs-commit mailing list