diff --git a/.bzrignore b/.bzrignore index 08dded71ee5..a9774c16645 100644 --- a/.bzrignore +++ b/.bzrignore @@ -394,6 +394,7 @@ client/rpl_tblmap.cc client/rpl_utility.h client/rpl_utility.cc client/select_test +client/sql_const.h client/sql_string.cpp client/ssl_test client/thimble @@ -1209,7 +1210,7 @@ libmysqld/stacktrace.c libmysqld/strfunc.cc libmysqld/table.cc libmysqld/thr_malloc.cc -libmysqld/time.cc +libmysqld/sql_time.cc libmysqld/tztime.cc libmysqld/uniques.cc libmysqld/unireg.cc @@ -1414,7 +1415,7 @@ mysql-test/var/* mysql-test/windows_sys_vars.inc mysql.kdevprj mysql.proj -mysql_priv.h +sql_priv.h mysqlbinlog/*.ds? mysqlbinlog/*.vcproj mysqlcheck/*.ds? diff --git a/client/Makefile.am b/client/Makefile.am index 1cd85c5840a..5da59296cdf 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -103,13 +103,13 @@ DEFS = -DMYSQL_CLIENT_NO_THREADS \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ -DMYSQL_DATADIR="\"$(localstatedir)\"" -sql_src=log_event.h mysql_priv.h rpl_constants.h \ +sql_src=log_event.h sql_priv.h rpl_constants.h \ rpl_tblmap.h rpl_tblmap.cc \ log_event.cc my_decimal.h my_decimal.cc \ log_event_old.h log_event_old.cc \ rpl_record_old.h rpl_record_old.cc \ rpl_utility.h rpl_utility.cc \ - transaction.h + transaction.h sql_const.h strings_src=decimal.c dtoa.c link_sources: diff --git a/client/client_priv.h b/client/client_priv.h index 799f6aaec2f..b0991c0134f 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 537567cbe4e..410d3a875d7 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -31,7 +31,7 @@ #include "client_priv.h" #include /* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */ -#include "mysql_priv.h" +#include "sql_priv.h" #include "log_event.h" #include "sql_common.h" diff --git a/include/Makefile.am b/include/Makefile.am index 1a0bc9c9df3..c60965fd385 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -34,7 +34,7 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_dbug.h m_string.h my_sys.h \ $(HEADERS_GEN_MAKE) probes_mysql.h probes_mysql_nodtrace.h noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \ - heap.h my_bitmap.h my_uctype.h \ + heap.h my_bitmap.h my_uctype.h password.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h help_start.h help_end.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ diff --git a/include/hash.h b/include/hash.h index 515c764214d..7b4ec1b4685 100644 --- a/include/hash.h +++ b/include/hash.h @@ -17,6 +17,21 @@ #ifndef _hash_h #define _hash_h + +#include "my_global.h" /* uchar */ +#include "my_sys.h" /* DYNAMIC_ARRAY */ + +/* + This forward declaration is used from C files where the real + definition is included before. Since C does not allow repeated + typedef declarations, even when identical, the definition may not be + repeated. +*/ +#ifndef CHARSET_INFO_DEFINED +#define CHARSET_INFO_DEFINED +typedef struct charset_info_st CHARSET_INFO; +#endif /* CHARSET_INFO_DEFINED */ + #ifdef __cplusplus extern "C" { #endif diff --git a/include/keycache.h b/include/keycache.h index baec7f40dcd..fefa31afd87 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -17,6 +17,9 @@ #ifndef _keycache_h #define _keycache_h + +#include "my_sys.h" /* flush_type */ + C_MODE_START /* declare structures that is used by st_key_cache */ diff --git a/include/m_ctype.h b/include/m_ctype.h index 7c01ebe7e5a..06cbfd779c8 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -15,13 +15,13 @@ /* A better inplementation of the UNIX ctype(3) library. - Notes: my_global.h should be included before ctype.h */ #ifndef _m_ctype_h #define _m_ctype_h #include +#include "my_global.h" /* uint16, uchar */ #ifdef __cplusplus extern "C" { @@ -265,6 +265,12 @@ extern MY_CHARSET_HANDLER my_charset_8bit_handler; extern MY_CHARSET_HANDLER my_charset_ucs2_handler; +/* + We define this CHARSET_INFO_DEFINED here to prevent a repeat of the + typedef in hash.c, which will cause a compiler error. +*/ +#define CHARSET_INFO_DEFINED + /* See strings/CHARSET_INFO.txt about information on this structure */ typedef struct charset_info_st { diff --git a/include/m_string.h b/include/m_string.h index a118144d310..7bd39e7483f 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -20,6 +20,9 @@ #ifndef _m_string_h #define _m_string_h + +#include "my_global.h" /* HAVE_* */ + #ifndef __USE_GNU #define __USE_GNU /* We want to use stpcpy */ #endif @@ -266,13 +269,6 @@ extern ulonglong strtoull(const char *str, char **ptr, int base); #endif #define longlong2str(A,B,C) ll2str((A),(B),(C),1) -/* my_vsnprintf.c */ - -extern size_t my_vsnprintf(char *str, size_t n, - const char *format, va_list ap); -extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...) - ATTRIBUTE_FORMAT(printf, 3, 4); - #if defined(__cplusplus) } #endif @@ -365,4 +361,10 @@ static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len) return (end); } +static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str) +{ + lex_str->str= (char *) c_str; + lex_str->length= strlen(c_str); +} + #endif diff --git a/include/my_dbug.h b/include/my_dbug.h index 956a5504e86..34681fbc633 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -145,7 +145,23 @@ extern const char* _db_get_func_(void); #define DBUG_CRASH_VOID_RETURN do { return; } while(0) #endif -#ifdef __cplusplus + +#ifdef EXTRA_DEBUG +/** + Sync points allow us to force the server to reach a certain line of code + and block there until the client tells the server it is ok to go on. + The client tells the server to block with SELECT GET_LOCK() + and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult + concurrency problems +*/ +#define DBUG_SYNC_POINT(lock_name,lock_timeout) \ + debug_sync_point(lock_name,lock_timeout) +void debug_sync_point(const char* lock_name, uint lock_timeout); +#else +#define DBUG_SYNC_POINT(lock_name,lock_timeout) +#endif /* EXTRA_DEBUG */ + +#ifdef __cplusplus } #endif #endif diff --git a/include/my_dir.h b/include/my_dir.h index 90d708ac811..6a65bde41f3 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -22,6 +22,8 @@ extern "C" { #ifndef MY_DIR_H #define MY_DIR_H +#include "my_global.h" + #include /* Defines for my_dir and my_stat */ diff --git a/include/my_getopt.h b/include/my_getopt.h index 32380efe289..54ae5982ea1 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -16,6 +16,8 @@ #ifndef _my_getopt_h #define _my_getopt_h +#include "my_sys.h" /* loglevel */ + C_MODE_START #define GET_NO_ARG 1 diff --git a/include/my_global.h b/include/my_global.h index b4bc61e0a48..67973ebd560 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1205,6 +1205,12 @@ typedef unsigned long my_off_t; #endif /*_WIN32*/ #define MY_FILEPOS_ERROR (~(my_off_t) 0) +/* + TODO Convert these to use Bitmap class. + */ +typedef ulonglong table_map; /* Used for table bits in join */ +typedef ulong nesting_map; /* Used for flags of nesting constructs */ + #if defined(__WIN__) #define socket_errno WSAGetLastError() #define SOCKET_EINTR WSAEINTR @@ -1675,7 +1681,13 @@ inline void operator delete[](void*, void*) { /* Do nothing */ } #if !defined(max) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) -#endif +#endif + +#define x_free(A) \ + do { my_free((uchar*)(A), MYF(MY_WME|MY_FAE|MY_ALLOW_ZERO_PTR)); } while (0) +#define safeFree(X) \ + do { if (X) { my_free((uchar*)(X), MYF(0)); (X) = NULL; } } while (0) + /* Only Linux is known to need an explicit sync of the directory to make sure a file creation/deletion/renaming in(from,to) this directory durable. @@ -1755,4 +1767,20 @@ static inline double rint(double x) #endif #endif +/* Defines that are unique to the embedded version of MySQL */ + +#ifdef EMBEDDED_LIBRARY + +/* Things we don't need in the embedded version of MySQL */ +/* TODO HF add #undef HAVE_VIO if we don't want client in embedded library */ + +#undef HAVE_PSTACK /* No stacktrace */ +#undef HAVE_OPENSSL +#undef HAVE_SMEM /* No shared memory */ +#undef HAVE_NDBCLUSTER_DB /* No NDB cluster */ + +#define DONT_USE_RAID + +#endif /* EMBEDDED_LIBRARY */ + #endif /* my_global_h */ diff --git a/include/my_handler.h b/include/my_handler.h index ae56331df86..977c0042938 100644 --- a/include/my_handler.h +++ b/include/my_handler.h @@ -23,6 +23,8 @@ extern "C" { #endif +#include "m_ctype.h" /* CHARSET_INFO */ + /* There is a hard limit for the maximum number of keys as there are only 8 bits in the index file header for the number of keys in a table. diff --git a/include/my_net.h b/include/my_net.h index 18fb3db8e88..8617f180431 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -24,6 +24,9 @@ #ifndef _my_net_h #define _my_net_h + +#include "my_global.h" /* C_MODE_START, C_MODE_END */ + C_MODE_START #include diff --git a/include/my_pthread.h b/include/my_pthread.h index 0b55c70b0fa..e41abba950e 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -18,6 +18,8 @@ #ifndef _my_pthread_h #define _my_pthread_h +#include "my_global.h" /* myf */ + #ifndef ETIME #define ETIME ETIMEDOUT /* For FreeBSD */ #endif diff --git a/include/my_sys.h b/include/my_sys.h index 8e56ef27c2d..ac10628f943 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -15,6 +15,9 @@ #ifndef _my_sys_h #define _my_sys_h + +#include "my_global.h" /* C_MODE_START, C_MODE_END */ + C_MODE_START #ifdef HAVE_AIOWAIT diff --git a/include/my_tree.h b/include/my_tree.h index 24bbdd54019..0958a37fb4c 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -20,6 +20,7 @@ extern "C" { #endif #include "my_base.h" /* get 'enum ha_rkey_function' */ +#include "my_alloc.h" /* MEM_ROOT */ /* Worst case tree is half full. This gives use 2^(MAX_TREE_HEIGHT/2) leafs */ #define MAX_TREE_HEIGHT 64 diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h index 18220a8dd4e..0a998aaa76c 100644 --- a/include/mysql/psi/mysql_file.h +++ b/include/mysql/psi/mysql_file.h @@ -20,6 +20,8 @@ #include /* For MY_STAT */ #include +/* For my_chsize */ +#include /** @file mysql/psi/mysql_file.h diff --git a/include/mysys_err.h b/include/mysys_err.h index 09e77248c17..6c18055b31b 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -16,6 +16,9 @@ #ifndef _mysys_err_h #define _mysys_err_h #ifdef __cplusplus + +#include "my_global.h" /* NEAR */ + extern "C" { #endif diff --git a/include/password.h b/include/password.h new file mode 100644 index 00000000000..e75b09297a3 --- /dev/null +++ b/include/password.h @@ -0,0 +1,32 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef PASSWORD_INCLUDED +#define PASSWORD_INCLUDED + +#include "my_global.h" + +C_MODE_START + +void my_make_scrambled_password_323(char *to, const char *password, + size_t pass_len); +void my_make_scrambled_password(char *to, const char *password, + size_t pass_len); + +void hash_password(ulong *result, const char *password, uint password_len); + +C_MODE_END + +#endif /* PASSWORD_INCLUDED */ diff --git a/include/queues.h b/include/queues.h index d01b73ba999..07962f09201 100644 --- a/include/queues.h +++ b/include/queues.h @@ -22,6 +22,9 @@ #ifndef _queues_h #define _queues_h + +#include "my_global.h" /* uchar */ + #ifdef __cplusplus extern "C" { #endif diff --git a/include/violite.h b/include/violite.h index 34dc6511b3d..904c383d64a 100644 --- a/include/violite.h +++ b/include/violite.h @@ -30,6 +30,10 @@ extern "C" { #endif /* __cplusplus */ +#ifdef __cplusplus +typedef struct st_vio Vio; +#endif /* __cplusplus */ + enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index 681b6fad1ff..c8dd0d3061c 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -83,7 +83,7 @@ link_sources: # # A list of needed headers collected from the deps information 000213 nh = my_global.h config-win32.h dbug.h errmsg.h \ - m_ctype.h m_string.h \ + m_ctype.h m_string.h password.h \ my_alarm.h my_config.h my_dir.h my_list.h my_net.h my_sys.h \ mysql.h mysql_com.h mysql_version.h mysqld_error.h \ mysys_err.h my_pthread.h thr_alarm.h violite.h hash.h \ diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 26332cab61b..077a48ede82 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -76,7 +76,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc ../sql/sql_update.cc ../sql/sql_view.cc ../sql/sql_profile.cc ../sql/strfunc.cc ../sql/table.cc ../sql/thr_malloc.cc - ../sql/time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc + ../sql/sql_time.cc ../sql/tztime.cc ../sql/uniques.cc ../sql/unireg.cc ../sql/partition_info.cc ../sql/sql_connect.cc ../sql/scheduler.cc ../sql/sql_audit.cc ../sql/event_parse_data.cc diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 380dfb1396c..1423d6bf00b 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -69,7 +69,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ sql_prepare.cc sql_derived.cc sql_rename.cc \ sql_select.cc sql_do.cc sql_show.cc set_var.cc sys_vars.cc \ sql_string.cc sql_table.cc sql_test.cc sql_udf.cc \ - sql_update.cc sql_yacc.cc table.cc thr_malloc.cc time.cc \ + sql_update.cc sql_yacc.cc table.cc thr_malloc.cc sql_time.cc \ unireg.cc uniques.cc sql_union.cc hash_filo.cc \ spatial.cc gstream.cc sql_help.cc tztime.cc sql_cursor.cc \ sp_head.cc sp_pcontext.cc sp.cc sp_cache.cc sp_rcontext.cc \ diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index 5cbced8a8ff..245dcb7f538 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -13,11 +13,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "my_global.h" // HAVE_* + #ifdef HAVE_QUERY_CACHE #include #include "emb_qcache.h" #include "embedded_priv.h" +#include "sql_class.h" // THD void Querycache_stream::store_uchar(uchar c) { diff --git a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h index ecf91487667..71e5cdd6dac 100644 --- a/libmysqld/emb_qcache.h +++ b/libmysqld/emb_qcache.h @@ -13,6 +13,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "sql_cache.h" /* Query_cache_block */ + class Querycache_stream { uchar *cur_data; diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index bca076fa938..8f7503c9d6c 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include "embedded_priv.h" diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc index af585bb4302..2a41179974d 100644 --- a/plugin/daemon_example/daemon_example.cc +++ b/plugin/daemon_example/daemon_example.cc @@ -13,13 +13,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include #include #include #include #include #include +#include "my_pthread.h" // pthread_handler_t +#include "my_sys.h" // my_write, my_malloc +#include "m_string.h" // strlen +#include "sql_plugin.h" // st_plugin_int /* Disable __attribute__() on non-gcc compilers. diff --git a/plugin/semisync/semisync.h b/plugin/semisync/semisync.h index ced25c40534..57353f3c156 100644 --- a/plugin/semisync/semisync.h +++ b/plugin/semisync/semisync.h @@ -20,11 +20,13 @@ #define MYSQL_SERVER #define HAVE_REPLICATION -#include +#include +#include "unireg.h" #include #include #include #include +#include "log.h" /* sql_print_information */ typedef struct st_mysql_show_var SHOW_VAR; typedef struct st_mysql_sys_var SYS_VAR; diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc index e371df3edc3..d6cc23a43b7 100644 --- a/plugin/semisync/semisync_master_plugin.cc +++ b/plugin/semisync/semisync_master_plugin.cc @@ -16,6 +16,7 @@ #include "semisync_master.h" +#include "sql_class.h" // THD ReplSemiSyncMaster repl_semisync; diff --git a/plugin/semisync/semisync_slave_plugin.cc b/plugin/semisync/semisync_slave_plugin.cc index 0bd9e1b8b21..66073f8a5e6 100644 --- a/plugin/semisync/semisync_slave_plugin.cc +++ b/plugin/semisync/semisync_slave_plugin.cc @@ -16,6 +16,7 @@ #include "semisync_slave.h" +#include ReplSemiSyncSlave repl_semisync; diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 913eb3464e2..31110c5e201 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -66,7 +66,7 @@ SET (SQL_SOURCE sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc sql_table.cc sql_test.cc sql_trigger.cc sql_udf.cc sql_union.cc sql_update.cc sql_view.cc strfunc.cc table.cc thr_malloc.cc - time.cc tztime.cc uniques.cc unireg.cc item_xmlfunc.cc + sql_time.cc tztime.cc uniques.cc unireg.cc item_xmlfunc.cc rpl_tblmap.cc sql_binlog.cc event_scheduler.cc event_data_objects.cc event_queue.cc event_db_repository.cc sql_tablespace.cc events.cc ../sql-common/my_user.c diff --git a/sql/Makefile.am b/sql/Makefile.am index 9a60cbcbf66..696f608c879 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -84,22 +84,29 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_strfunc.h item_timefunc.h \ item_xmlfunc.h sql_plugin_services.h \ item_create.h item_subselect.h item_row.h \ - mysql_priv.h item_geofunc.h sql_bitmap.h \ + sql_priv.h item_geofunc.h sql_bitmap.h \ procedure.h sql_class.h sql_lex.h sql_list.h \ sql_map.h sql_string.h unireg.h \ sql_error.h field.h handler.h mysqld_suffix.h \ - sql_profile.h \ + sql_profile.h mysqld.h sql_help.h frm_crypt.h \ ha_ndbcluster.h ha_ndbcluster_cond.h \ ha_ndbcluster_binlog.h ha_ndbcluster_tables.h \ ha_partition.h rpl_constants.h \ debug_sync.h \ opt_range.h protocol.h rpl_tblmap.h rpl_utility.h \ - rpl_reporting.h \ + rpl_reporting.h sql_locale.h sql_parse.h \ log.h sql_show.h rpl_rli.h rpl_mi.h \ sql_select.h structs.h table.h sql_udf.h hash_filo.h \ - lex.h lex_symbol.h sql_acl.h sql_crypt.h \ + lex.h lex_symbol.h sql_acl.h sql_crypt.h sql_base.h \ + sql_table.h key.h lock.h thr_malloc.h strfunc.h \ + sql_delete.h sql_insert.h sql_update.h sql_db.h \ + sql_connect.h sql_rename.h sql_time.h sql_tablespace.h \ + hostname.h sql_test.h records.h filesort.h \ + sql_derived.h sql_load.h sql_handler.h init.h \ + derror.h sql_union.h des_key_file.h sql_binlog.h \ + discover.h sql_manager.h sql_do.h \ sql_repl.h slave.h rpl_filter.h rpl_injector.h \ - log_event.h rpl_record.h \ + log_event.h rpl_record.h sql_const.h \ log_event_old.h rpl_record_old.h \ sql_sort.h sql_cache.h set_var.h sys_vars_shared.h \ spatial.h gstream.h client_settings.h tzfile.h \ @@ -137,7 +144,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ unireg.cc des_key_file.cc \ log_event.cc rpl_record.cc \ log_event_old.cc rpl_record_old.cc \ - discover.cc time.cc opt_range.cc opt_sum.cc \ + discover.cc sql_time.cc opt_range.cc opt_sum.cc \ records.cc filesort.cc handler.cc \ ha_partition.cc \ debug_sync.cc \ diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index a6a5dfe739a..d16fa4b2468 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -321,12 +321,13 @@ /* Due to weaknesses in our include files, we need to include - mysql_priv.h here. To have THD declared, we need to include + sql_priv.h here. To have THD declared, we need to include sql_class.h. This includes log_event.h, which in turn requires - declarations from mysql_priv.h (e.g. OPTION_AUTO_IS_NULL). - mysql_priv.h includes almost everything, so is sufficient here. + declarations from sql_priv.h (e.g. OPTION_AUTO_IS_NULL). + sql_priv.h includes almost everything, so is sufficient here. */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "sql_parse.h" /* Action to perform at a synchronization point. @@ -394,7 +395,7 @@ extern "C" void (*debug_sync_C_callback_ptr)(const char *, size_t); We cannot place a sync point directly in C files (like those in mysys or certain storage engines written mostly in C like MyISAM or Maria). Because - they are C code and do not include mysql_priv.h. So they do not know the + they are C code and do not include sql_priv.h. So they do not know the macro DEBUG_SYNC(thd, sync_point_name). The macro needs a 'thd' argument. Hence it cannot be used in files outside of the sql/ directory. diff --git a/sql/derror.cc b/sql/derror.cc index 8e47dda7bbe..04a82860d45 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -21,8 +21,13 @@ Read language depeneded messagefile */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "derror.h" #include "mysys_err.h" +#include "mysqld.h" // lc_messages_dir +#include "derror.h" // read_texts +#include "sql_class.h" // THD static void init_myfunc_errs(void); diff --git a/sql/derror.h b/sql/derror.h new file mode 100644 index 00000000000..cb8ae91acbc --- /dev/null +++ b/sql/derror.h @@ -0,0 +1,25 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef DERROR_INCLUDED +#define DERROR_INCLUDED + +#include "my_global.h" /* uint */ + +bool init_errmessage(void); +bool read_texts(const char *file_name, const char *language, + const char ***point, uint error_messages); + +#endif /* DERROR_INCLUDED */ diff --git a/sql/des_key_file.cc b/sql/des_key_file.cc index c2b632e521b..d2bf2ebdaa7 100644 --- a/sql/des_key_file.cc +++ b/sql/des_key_file.cc @@ -13,7 +13,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "my_global.h" // HAVE_* +#include "sql_priv.h" +#include "des_key_file.h" // st_des_keyschedule, st_des_keyblock +#include "log.h" // sql_print_error #include #ifdef HAVE_OPENSSL diff --git a/sql/des_key_file.h b/sql/des_key_file.h new file mode 100644 index 00000000000..d817ff93949 --- /dev/null +++ b/sql/des_key_file.h @@ -0,0 +1,40 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef DES_KEY_FILE_INCLUDED +#define DES_KEY_FILE_INCLUDED + +#ifdef HAVE_OPENSSL +#include + +#include "violite.h" /* DES_cblock, DES_key_schedule */ + +struct st_des_keyblock +{ + DES_cblock key1, key2, key3; +}; + +struct st_des_keyschedule +{ + DES_key_schedule ks1, ks2, ks3; +}; + +extern struct st_des_keyschedule des_keyschedule[10]; +extern uint des_default_key; + +bool load_des_key_file(const char *file_name); +#endif /* HAVE_OPENSSL */ + +#endif /* DES_KEY_FILE_INCLUDED */ diff --git a/sql/discover.cc b/sql/discover.cc index fcc26042fe2..f50f7deed99 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -21,7 +21,9 @@ Functions for discover of frm file from handler */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "discover.h" #include /** diff --git a/sql/discover.h b/sql/discover.h new file mode 100644 index 00000000000..54fb78ddd2f --- /dev/null +++ b/sql/discover.h @@ -0,0 +1,24 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef DISCOVER_INCLUDED +#define DISCOVER_INCLUDED + +#include "my_global.h" /* uchar */ + +int readfrm(const char *name, uchar **data, size_t *length); +int writefrm(const char* name, const uchar* data, size_t len); + +#endif /* DISCOVER_INCLUDED */ diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 7f4104f4a77..e22bfbad141 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -14,11 +14,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define MYSQL_LEX 1 -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "sql_parse.h" // parse_sql +#include "strfunc.h" // find_string_in_array +#include "sql_db.h" // get_default_db_collation +#include "sql_time.h" // interval_type_to_name, + // date_add_interval, + // calc_time_diff +#include "tztime.h" // my_tz_find, my_tz_OFFSET0, struct Time_zone +#include "sql_acl.h" // EVENT_ACL, SUPER_ACL +#include "sp.h" // load_charset, load_collation #include "events.h" #include "event_data_objects.h" #include "event_db_repository.h" #include "sp_head.h" +#include "sql_show.h" // append_definer, append_identifier /** @addtogroup Event_Scheduler diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h index e32077b9c97..9d17213bcb8 100644 --- a/sql/event_data_objects.h +++ b/sql/event_data_objects.h @@ -23,6 +23,12 @@ */ #include "event_parse_data.h" +#include "thr_lock.h" /* thr_lock_type */ + +class Field; +class THD; +class Time_zone; +struct TABLE; class Event_queue_element_for_exec { diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 0696652deb1..b7c01f10066 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -13,12 +13,21 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "sql_base.h" // close_thread_tables #include "event_db_repository.h" +#include "key.h" // key_copy +#include "sql_db.h" // get_default_db_collation +#include "sql_time.h" // interval_type_to_name +#include "tztime.h" // struct Time_zone +#include "sql_acl.h" // SUPER_ACL, MYSQL_DB_FIELD_COUNT, mysql_db_table_fields +#include "records.h" // init_read_record, end_read_record #include "sp_head.h" #include "event_data_objects.h" #include "events.h" #include "sql_show.h" +#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT /** @addtogroup Event_Scheduler diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc index 86905b38627..c36567fc8e1 100644 --- a/sql/event_parse_data.cc +++ b/sql/event_parse_data.cc @@ -13,9 +13,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" #include "sp_head.h" #include "event_parse_data.h" +#include "sql_time.h" // TIME_to_timestamp /* Returns a new instance diff --git a/sql/event_parse_data.h b/sql/event_parse_data.h index 8b42eb23937..4ca46b40d3f 100644 --- a/sql/event_parse_data.h +++ b/sql/event_parse_data.h @@ -16,6 +16,12 @@ #ifndef _EVENT_PARSE_DATA_H_ #define _EVENT_PARSE_DATA_H_ +#include "sql_list.h" /* Sql_alloc */ + +class Item; +class THD; +class sp_name; + #define EVEX_GET_FIELD_FAILED -2 #define EVEX_BAD_PARAMS -5 #define EVEX_MICROSECOND_UNSUP -6 diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 225029040b0..f0310c676d1 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -13,10 +13,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" #include "event_queue.h" #include "event_data_objects.h" #include "sql_audit.h" +#include "tztime.h" // my_tz_find, my_tz_OFFSET0, struct Time_zone +#include "log.h" // sql_print_error +#include "sql_class.h" // struct THD /** @addtogroup Event_Scheduler diff --git a/sql/event_queue.h b/sql/event_queue.h index aac9eb04e98..93af03ba901 100644 --- a/sql/event_queue.h +++ b/sql/event_queue.h @@ -30,6 +30,10 @@ extern PSI_mutex_key key_LOCK_event_queue; extern PSI_cond_key key_COND_queue_state; #endif /* HAVE_PSI_INTERFACE */ +#include "queues.h" // QUEUE +#include "sql_string.h" /* LEX_STRING */ +#include "my_time.h" /* my_time_t, interval_type */ + class Event_basic; class Event_queue_element; class Event_queue_element_for_exec; diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index 3ceb1597a41..c3cfd5c0fda 100755 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -13,12 +13,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "event_scheduler.h" #include "events.h" #include "event_data_objects.h" -#include "event_scheduler.h" #include "event_queue.h" #include "event_db_repository.h" +#include "sql_connect.h" // init_new_connection_handler_thread +#include "sql_acl.h" // SUPER_ACL /** @addtogroup Event_Scheduler diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index 2988f354f63..ecd7031f546 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -34,7 +34,9 @@ class Event_queue; class Event_job_data; class Event_db_repository; +class Event_queue_element_for_exec; class Events; +class THD; void pre_init_event_thread(THD* thd); diff --git a/sql/events.cc b/sql/events.cc index a2375b1274b..96b86e6798f 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -13,8 +13,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "sql_parse.h" // check_access +#include "sql_base.h" // close_thread_tables +#include "sql_show.h" // append_definer #include "events.h" +#include "sql_db.h" // check_db_dir_existence +#include "sql_table.h" // write_bin_log +#include "tztime.h" // struct Time_zone +#include "sql_acl.h" // EVENT_ACL +#include "records.h" // init_read_record, end_read_record #include "event_data_objects.h" #include "event_db_repository.h" #include "event_queue.h" diff --git a/sql/events.h b/sql/events.h index 380b0d97f0a..c535dda9c31 100644 --- a/sql/events.h +++ b/sql/events.h @@ -32,10 +32,17 @@ extern PSI_cond_key key_event_scheduler_COND_state; extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker; #endif /* HAVE_PSI_INTERFACE */ -class Event_parse_data; +#include "sql_string.h" /* LEX_STRING */ +#include "my_time.h" /* interval_type */ + class Event_db_repository; +class Event_parse_data; class Event_queue; class Event_scheduler; +class TABLE_LIST; +class THD; +typedef class Item COND; +typedef struct charset_info_st CHARSET_INFO; /* Return codes */ enum enum_events_error_code diff --git a/sql/field.cc b/sql/field.cc index 7eade7f91bf..bd091f7eb57 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -25,10 +25,19 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" #include "sql_select.h" #include "rpl_rli.h" // Pull in Relay_log_info #include "slave.h" // Pull in rpl_master_has_bug() +#include "strfunc.h" // find_type2, find_set +#include "sql_time.h" // str_to_datetime_with_warn, + // str_to_time_with_warn, + // TIME_to_timestamp, + // make_time, make_date, + // make_truncated_value_warning +#include "tztime.h" // struct Time_zone +#include "filesort.h" // change_double_for_sort +#include "log_event.h" // class Table_map_log_event #include #include diff --git a/sql/field.h b/sql/field.h index b4f5977d756..d1fcc40ff5d 100644 --- a/sql/field.h +++ b/sql/field.h @@ -25,6 +25,12 @@ #pragma interface /* gcc class implementation */ #endif +#include "mysqld.h" /* system_charset_info */ +#include "table.h" /* TABLE */ +#include "sql_string.h" /* String */ +#include "my_decimal.h" /* my_decimal */ +#include "sql_error.h" /* MYSQL_ERROR */ + #define DATETIME_DEC 6 const uint32 max_field_size= (uint32) 4294967295U; @@ -32,6 +38,33 @@ class Send_field; class Protocol; class Create_field; class Relay_log_info; +class Field; + +enum enum_check_fields +{ + CHECK_FIELD_IGNORE, + CHECK_FIELD_WARN, + CHECK_FIELD_ERROR_FOR_NULL +}; + + +enum Derivation +{ + DERIVATION_IGNORABLE= 6, + DERIVATION_NUMERIC= 5, + DERIVATION_COERCIBLE= 4, + DERIVATION_SYSCONST= 3, + DERIVATION_IMPLICIT= 2, + DERIVATION_NONE= 1, + DERIVATION_EXPLICIT= 0 +}; + +#define STORAGE_TYPE_MASK 7 +#define COLUMN_FORMAT_MASK 7 +#define COLUMN_FORMAT_SHIFT 3 + +#define my_charset_numeric my_charset_latin1 +#define MY_REPERTOIRE_NUMERIC MY_REPERTOIRE_ASCII struct st_cache_field; int field_conv(Field *to,Field *from); diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 3574534722e..e3be33c0f3c 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -24,7 +24,8 @@ gives much more speed. */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "sql_class.h" // THD #include static void do_field_eq(Copy_field *copy) diff --git a/sql/filesort.cc b/sql/filesort.cc index 79887577f8f..3f3dc4e1e3e 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -21,13 +21,17 @@ Sorts a database */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "filesort.h" +#include "unireg.h" // REQUIRED by other includes #ifdef HAVE_STDDEF_H #include /* for macro offsetof */ #endif #include #include "sql_sort.h" #include "probes_mysql.h" +#include "sql_test.h" // TEST_filesort +#include "opt_range.h" // SQL_SELECT #ifndef THREAD #define SKIP_DBUG_IN_FILESORT diff --git a/sql/filesort.h b/sql/filesort.h new file mode 100644 index 00000000000..c1a101cc1e8 --- /dev/null +++ b/sql/filesort.h @@ -0,0 +1,36 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef FILESORT_INCLUDED +#define FILESORT_INCLUDED + +class SQL_SELECT; + +#include "my_global.h" /* uint, uchar */ +#include "my_base.h" /* ha_rows */ + +class SQL_SELECT; +class THD; +struct TABLE; +typedef struct st_sort_field SORT_FIELD; + +ha_rows filesort(THD *thd, TABLE *table, st_sort_field *sortorder, + uint s_length, SQL_SELECT *select, + ha_rows max_rows, bool sort_positions, + ha_rows *examined_rows); +void filesort_free_buffers(TABLE *table, bool full); +void change_double_for_sort(double nr,uchar *to); + +#endif /* FILESORT_INCLUDED */ diff --git a/sql/frm_crypt.cc b/sql/frm_crypt.cc index 590205e83ab..821e61c5247 100644 --- a/sql/frm_crypt.cc +++ b/sql/frm_crypt.cc @@ -21,7 +21,8 @@ ** mysql binary. */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "frm_crypt.h" #ifdef HAVE_CRYPTED_FRM diff --git a/sql/frm_crypt.h b/sql/frm_crypt.h new file mode 100644 index 00000000000..e119dceae35 --- /dev/null +++ b/sql/frm_crypt.h @@ -0,0 +1,23 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef FRM_CRYPT_INCLUDED +#define FRM_CRYPT_INCLUDED + +class SQL_CRYPT; + +SQL_CRYPT *get_crypt_for_frm(void); + +#endif /* FRM_CRYPT_INCLUDED */ diff --git a/sql/gstream.cc b/sql/gstream.cc index e2bb41b8541..fcb9a91ac50 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -18,7 +18,9 @@ NOTE: These functions assumes that the string is end \0 terminated! */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "gstream.h" +#include "m_string.h" // LEX_STRING enum Gis_read_stream::enum_tok_types Gis_read_stream::get_next_toc_type() { diff --git a/sql/gstream.h b/sql/gstream.h index ea7158ee1a3..65acc2ff193 100644 --- a/sql/gstream.h +++ b/sql/gstream.h @@ -17,6 +17,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "my_global.h" /* NULL, NullS */ +#include "my_sys.h" /* MY_ALLOW_ZERO_PTR */ +#include "m_ctype.h" /* my_charset_latin1, my_charset_bin */ + +typedef struct charset_info_st CHARSET_INFO; +typedef struct st_mysql_lex_string LEX_STRING; + class Gis_read_stream { public: diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 05a42220caf..38324f3cf19 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -26,7 +26,15 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" // REQUIRED: for other includes +#include "sql_table.h" // build_table_filename, + // tablename_to_filename, + // filename_to_tablename +#include "sql_partition.h" // HA_CAN_*, partition_info, part_id_range +#include "sql_base.h" // close_cached_tables +#include "discover.h" // readfrm +#include "sql_acl.h" // wild_case_compare #include "rpl_mi.h" /* @@ -48,8 +56,11 @@ int ha_ndb_dummy; #include "ha_ndbcluster_binlog.h" #include "ha_ndbcluster_tables.h" -#include +#include "sql_plugin.h" #include "probes_mysql.h" +#include "sql_show.h" // init_fill_schema_files_row, + // schema_table_store_record +#include "sql_test.h" // print_where #ifdef ndb_dynamite #undef assert diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 63da24e8dda..17ba7451538 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -51,6 +51,8 @@ class NdbIndexStat; class NdbEventOperation; class ha_ndbcluster_cond; +#include "sql_partition.h" /* part_id_range */ + // connectstring to cluster if given by mysqld extern const char *ndbcluster_connectstring; diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 7097c0a1a46..edb6aeebb5c 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -14,7 +14,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" // REQUIRED: for other includes #include "sql_show.h" #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #include "ha_ndbcluster.h" @@ -28,6 +29,14 @@ #include "ndb_cluster_connection.hpp" #include +#include "sql_base.h" // close_thread_tables +#include "sql_table.h" // build_table_filename +#include "table.h" // open_table_from_share +#include "discover.h" // readfrm, writefrm +#include "lock.h" // MYSQL_LOCK_IGNORE_FLUSH, + // mysql_unlock_tables +#include "sql_parse.h" // mysql_parse + #ifdef ndb_dynamite #undef assert #define assert(x) do { if(x) break; ::printf("%s %d: assert failed: %s\n", __FILE__, __LINE__, #x); ::fflush(stdout); ::signal(SIGABRT,SIG_DFL); ::abort(); ::kill(::getpid(),6); ::kill(::getpid(),9); } while (0) diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index 32dac553ee8..4d2a49588b4 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "sql_class.h" /* THD */ + // Typedefs for long names typedef NdbDictionary::Object NDBOBJ; typedef NdbDictionary::Column NDBCOL; diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc index bb35211944b..6df1f4881c3 100644 --- a/sql/ha_ndbcluster_cond.cc +++ b/sql/ha_ndbcluster_cond.cc @@ -22,7 +22,10 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +#include "sql_class.h" // set_var.h: THD +#include "my_global.h" // WITH_* +#include "log.h" // sql_print_error #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #include diff --git a/sql/ha_ndbcluster_cond.h b/sql/ha_ndbcluster_cond.h index 4ccc7e062ec..442eac2fafd 100644 --- a/sql/ha_ndbcluster_cond.h +++ b/sql/ha_ndbcluster_cond.h @@ -25,6 +25,13 @@ #pragma interface /* gcc class implementation */ #endif +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "set_var.h" /* Item, Item_field */ + typedef enum ndb_item_type { NDB_VALUE = 0, // Qualified more with Item::Type NDB_FIELD = 1, // Qualified from table definition diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ea5b4079b3f..b8831127e3f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -51,12 +51,14 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +#include "sql_parse.h" // append_file_to_dir #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" - -#include +#include "sql_table.h" // tablename_to_filename +#include "key.h" +#include "sql_plugin.h" static const char *ha_par_ext= ".par"; #ifdef NOT_USED diff --git a/sql/ha_partition.h b/sql/ha_partition.h index b3a347612f3..9f499e7b4a9 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -20,6 +20,9 @@ #pragma interface /* gcc class implementation */ #endif +#include "sql_partition.h" /* part_id_range, partition_element */ +#include "queues.h" /* QUEUE */ + enum partition_keywords { PKW_HASH= 0, PKW_RANGE, PKW_LIST, PKW_KEY, PKW_MAXVALUE, PKW_LINEAR, diff --git a/sql/handler.cc b/sql/handler.cc index 69ac4e72555..ad3ba908173 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -23,8 +23,19 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" #include "rpl_handler.h" +#include "sql_cache.h" // query_cache, query_cache_* +#include "key.h" // key_copy, key_unpack, key_cmp_if_same, key_cmp +#include "sql_table.h" // build_table_filename +#include "lock.h" // wait_if_global_read_lock, + // start_waiting_global_read_lock +#include "sql_parse.h" // check_stack_overrun +#include "sql_acl.h" // SUPER_ACL +#include "sql_base.h" // free_io_cache +#include "discover.h" // writefrm +#include "log_event.h" // *_rows_log_event #include "rpl_filter.h" #include #include "transaction.h" diff --git a/sql/handler.h b/sql/handler.h index 1734e5727dc..9f21cb0f25d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -22,6 +22,13 @@ #pragma interface /* gcc class implementation */ #endif +#include "sql_const.h" +#include "mysqld.h" /* server_id */ +#include "sql_plugin.h" /* plugin_ref, st_plugin_int, plugin */ +#include "thr_lock.h" /* thr_lock_type, THR_LOCK_DATA */ +#include "sql_cache.h" +#include "structs.h" /* SHOW_COMP_OPTION */ + #include #include #include @@ -2173,4 +2180,15 @@ int ha_binlog_end(THD *thd); #define ha_binlog_wait(a) do {} while (0) #define ha_binlog_end(a) do {} while (0) #endif + +const char *get_canonical_filename(handler *file, const char *path, + char *tmp_path); +bool mysql_xa_recover(THD *thd); + + +inline const char *table_case_name(HA_CREATE_INFO *info, const char *name) +{ + return ((lower_case_table_names == 2 && info->alias) ? info->alias : name); +} + #endif /* HANDLER_INCLUDED */ diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index 9303120e18a..d10b7fa4907 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -23,5 +23,5 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" #include "hash_filo.h" diff --git a/sql/hash_filo.h b/sql/hash_filo.h index 805e1262020..859b4713940 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -26,6 +26,10 @@ #pragma interface /* gcc class interface */ #endif +#include "hash.h" /* my_hash_get_key, my_hash_free_key, HASH */ +#include "m_string.h" /* bzero */ +#include "mysqld.h" /* key_hash_filo_lock */ + class hash_filo_element { hash_filo_element *next_used,*prev_used; diff --git a/sql/hostname.cc b/sql/hostname.cc index 5517d85527c..d309efc4196 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -24,9 +24,18 @@ doesn't resemble an IP address. */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "hostname.h" +#include "my_global.h" +#ifndef __WIN__ +#include // getservbyname, servent +#endif #include "hash_filo.h" #include +#include "log.h" // sql_print_warning, + // sql_print_information +#include "violite.h" // vio_getnameinfo, + // vio_get_normalized_ip_string #ifdef __cplusplus extern "C" { // Because of SCO 3.2V4.2 #endif diff --git a/sql/hostname.h b/sql/hostname.h new file mode 100644 index 00000000000..03611bb5813 --- /dev/null +++ b/sql/hostname.h @@ -0,0 +1,30 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef HOSTNAME_INCLUDED +#define HOSTNAME_INCLUDED + +#include "my_global.h" /* uint */ + +bool ip_to_hostname(struct sockaddr_storage *ip_storage, + const char *ip_string, + char **hostname, uint *connect_errors); +void inc_host_errors(const char *ip_string); +void reset_host_errors(const char *ip_string); +bool hostname_cache_init(); +void hostname_cache_free(); +void hostname_cache_refresh(void); + +#endif /* HOSTNAME_INCLUDED */ diff --git a/sql/init.cc b/sql/init.cc index cada907b013..c72787300b7 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -21,7 +21,12 @@ Init and dummy functions for interface with unireg */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "init.h" +#include "my_sys.h" +#include "mysqld.h" // abort_loop, ... +#include "my_time.h" // my_init_time +#include "unireg.h" // SPECIAL_SAME_DB_NAME #include void unireg_init(ulong options) diff --git a/sql/init.h b/sql/init.h new file mode 100644 index 00000000000..2c160879223 --- /dev/null +++ b/sql/init.h @@ -0,0 +1,24 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef INIT_INCLUDED +#define INIT_INCLUDED + +#include "my_global.h" /* ulong */ + +void unireg_init(ulong options); +void unireg_end(void) __attribute__((noreturn)); + +#endif /* INIT_INCLUDED */ diff --git a/sql/item.cc b/sql/item.cc index 9a685c80c18..24b8e0d5401 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -17,7 +17,8 @@ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" // REQUIRED: for other includes #include #include #include "my_dir.h" @@ -25,6 +26,19 @@ #include "sp_head.h" #include "sql_trigger.h" #include "sql_select.h" +#include "sql_show.h" // append_identifier +#include "sql_view.h" // VIEW_ANY_SQL +#include "sql_time.h" // str_to_datetime_with_warn, + // make_truncated_value_warning +#include "sql_acl.h" // get_column_grant, + // SELECT_ACL, UPDATE_ACL, + // INSERT_ACL, + // check_grant_column +#include "sql_base.h" // enum_resolution_type, + // REPORT_EXCEPT_NOT_FOUND, + // find_item_in_list, + // RESOLVED_AGAINST_ALIAS, ... +#include "log_event.h" // append_query_string const String my_null_string("NULL", 4, default_charset_info); diff --git a/sql/item.h b/sql/item.h index 5d811b50bbc..4241074c659 100644 --- a/sql/item.h +++ b/sql/item.h @@ -21,10 +21,18 @@ #pragma interface /* gcc class implementation */ #endif +#include "sql_priv.h" /* STRING_BUFFER_USUAL_SIZE */ +#include "unireg.h" +#include "sql_const.h" /* RAND_TABLE_BIT, MAX_FIELD_NAME */ +#include "unireg.h" // REQUIRED: for other includes +#include "thr_malloc.h" /* sql_calloc */ +#include "field.h" /* Derivation */ + class Protocol; struct TABLE_LIST; void item_init(void); /* Init item functions */ class Item_field; +class user_var_entry; /* "Declared Type Collation" @@ -2689,6 +2697,7 @@ public: #include "item_timefunc.h" #include "item_subselect.h" #include "item_xmlfunc.h" +#include "item_create.h" #endif /** @@ -3021,18 +3030,6 @@ public: }; -/* - We need this two enums here instead of sql_lex.h because - at least one of them is used by Item_trigger_field interface. - - Time when trigger is invoked (i.e. before or after row actually - inserted/updated/deleted). -*/ -enum trg_action_time_type -{ - TRG_ACTION_BEFORE= 0, TRG_ACTION_AFTER= 1, TRG_ACTION_MAX -}; - class Table_triggers_list; /* @@ -3418,4 +3415,7 @@ extern Cached_item *new_Cached_item(THD *thd, Item *item); extern Item_result item_cmp_type(Item_result a,Item_result b); extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item); extern int stored_field_cmp_to_item(THD *thd, Field *field, Item *item); + +extern const String my_null_string; + #endif /* ITEM_INCLUDED */ diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 2f45d0a17c2..a1bbd95c2c6 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -21,7 +21,14 @@ Buffers to save and compare item values */ -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // THD +#include "set_var.h" // Cached_item, Cached_item_field, ... /** Create right type of Cached_item for an item. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 36d05a2d0f4..19e8385539f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -25,9 +25,11 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" #include #include "sql_select.h" +#include "sql_parse.h" // check_stack_overrun +#include "sql_time.h" // make_truncated_value_warning static bool convert_constant_item(THD *, Item_field *, Item **); static longlong diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 767bc0a2b0f..afd25688e79 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -23,6 +23,9 @@ #pragma interface /* gcc class implementation */ #endif +#include "thr_malloc.h" /* sql_calloc */ +#include "item_func.h" /* Item_int_func, Item_bool_func */ + extern Item_result item_cmp_type(Item_result a,Item_result b); class Item_bool_func2; class Arg_comparator; @@ -1760,8 +1763,26 @@ inline Item *and_conds(Item *a, Item *b) return new Item_cond_and(a, b); } + Item *and_expressions(Item *a, Item *b, Item **org_item); +longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, + Item *warn_item, bool *is_null); + + bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type, const char *warn_name, MYSQL_TIME *l_time); + +/* + These need definitions from this file but the variables are defined + in mysqld.h. The variables really belong in this component, but for + the time being we leave them in mysqld.cc to avoid merge problems. +*/ +extern Eq_creator eq_creator; +extern Ne_creator ne_creator; +extern Gt_creator gt_creator; +extern Lt_creator lt_creator; +extern Ge_creator ge_creator; +extern Le_creator le_creator; + #endif /* ITEM_CMPFUNC_INCLUDED */ diff --git a/sql/item_create.cc b/sql/item_create.cc index 89a7fbd696d..beb7b40dc18 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -20,8 +20,14 @@ Functions to create an item. Used by sql_yac.yy */ -#include "mysql_priv.h" -#include "item_create.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // set_var.h: THD +#include "set_var.h" #include "sp_head.h" #include "sp.h" diff --git a/sql/item_create.h b/sql/item_create.h index d84c764a3d9..fc21e0a4d33 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -18,6 +18,8 @@ #ifndef ITEM_CREATE_H #define ITEM_CREATE_H +typedef struct st_udf_func udf_func; + /** Public function builder interface. The parser (sql/sql_yacc.yy) uses a factory / builder pattern to @@ -163,5 +165,9 @@ Item * create_func_cast(THD *thd, Item *a, Cast_target cast_type, const char *len, const char *dec, CHARSET_INFO *cs); + +int item_create_init(); +void item_create_cleanup(); + #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index 2c0d90642b4..63af030a027 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -25,8 +25,20 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // set_var.h: THD +#include "set_var.h" #include "slave.h" // for wait_for_master_pos +#include "sql_show.h" // append_identifier +#include "strfunc.h" // find_type +#include "sql_parse.h" // is_update_query +#include "sql_acl.h" // EXECUTE_ACL +#include "mysqld.h" // LOCK_uuid_generator #include "rpl_mi.h" #include #include diff --git a/sql/item_func.h b/sql/item_func.h index 38253a73265..c3f8b254f28 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1797,4 +1797,14 @@ public: bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; +Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, + LEX_STRING component); +extern bool check_reserved_words(LEX_STRING *name); +extern enum_field_types agg_field_type(Item **items, uint nitems); +double my_double_round(double value, longlong dec, bool dec_unsigned, + bool truncate); +bool eval_const_cond(COND *cond); + +extern bool volatile mqh_used; + #endif /* ITEM_FUNC_INCLUDED */ diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index c5554265fbe..e046087b16a 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -25,7 +25,14 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // THD, set_var.h: THD +#include "set_var.h" #ifdef HAVE_SPATIAL #include diff --git a/sql/item_row.cc b/sql/item_row.cc index 7535c1fa80b..2fbf0c12499 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -13,7 +13,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // THD, set_var.h: THD +#include "set_var.h" /** Row items used for comparing rows and IN operations on rows: diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dab29bb58c4..9ae15322265 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -29,7 +29,22 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "my_global.h" // HAVE_* + + +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // set_var.h: THD +#include "set_var.h" +#include "mysqld.h" // LOCK_uuid_generator +#include "sql_acl.h" // SUPER_ACL +#include "des_key_file.h" // st_des_keyschedule, st_des_keyblock +#include "password.h" // my_make_scrambled_password, + // my_make_scrambled_password_323 #include #include "my_md5.h" #include "sha1.h" diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index c9d62ac1052..e3008a5daab 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -23,6 +23,8 @@ #pragma interface /* gcc class implementation */ #endif +class MY_LOCALE; + class Item_str_func :public Item_func { public: @@ -877,4 +879,6 @@ public: String *val_str(String *); }; +extern String my_empty_string; + #endif /* ITEM_STRFUNC_INCLUDED */ diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 83e1f9b0625..c341dd97460 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -28,8 +28,16 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // set_var.h: THD +#include "set_var.h" #include "sql_select.h" +#include "sql_parse.h" // check_stack_overrun inline Item * and_items(Item* cond, Item *item) { diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 3503d42edc0..04daab19adc 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -28,6 +28,15 @@ class JOIN; class select_subselect; class subselect_engine; class Item_bool_func2; +class Comp_creator; + +typedef class st_select_lex SELECT_LEX; + +/** + Convenience typedef used in this file, and further used by any files + including this file. +*/ +typedef Comp_creator* (*chooser_compare_func_creator)(bool invert); /* base class for subselects */ @@ -572,6 +581,15 @@ public: virtual void print (String *str, enum_query_type query_type); }; +/* + This function is actually defined in sql_parse.cc, but it depends on + chooser_compare_func_creator defined in this file. + */ +Item * all_any_subquery_creator(Item *left_expr, + chooser_compare_func_creator cmp, + bool all, + SELECT_LEX *select_lex); + inline bool Item_subselect::is_evaluated() const { diff --git a/sql/item_sum.cc b/sql/item_sum.cc index ce39fd245be..4746a6057c6 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -25,7 +25,7 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" #include "sql_select.h" /** diff --git a/sql/item_sum.h b/sql/item_sum.h index 65f64520156..5f2c4f166e6 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -24,6 +24,7 @@ #endif #include +#include "sql_udf.h" /* udf_handler */ class Item_sum; class Aggregator_distinct; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 49d31bf1252..feff03e704a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -28,7 +28,28 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // set_var.h: THD +#include "set_var.h" +#include "sql_locale.h" // MY_LOCALE my_locale_en_US +#include "strfunc.h" // check_word +#include "sql_time.h" // make_truncated_value_warning, + // make_time, get_date_from_daynr, + // calc_weekday, calc_week, + // convert_month_to_period, + // convert_period_to_month, + // TIME_to_timestamp, make_date, + // calc_time_diff, + // calc_time_from_sec, + // known_date_time_format, + // get_date_time_format_str +#include "tztime.h" // struct Time_zone +#include "sql_class.h" // THD #include #include diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 20e4d6488d6..2c08853fda4 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -23,6 +23,8 @@ #pragma interface /* gcc class implementation */ #endif +class MY_LOCALE; + enum date_time_format_types { TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND @@ -1066,4 +1068,10 @@ public: } }; + +/* Function prototypes */ + +bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, + timestamp_type type, String *str); + #endif /* ITEM_TIMEFUNC_INCLUDED */ diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 3621733f456..f124c37f0eb 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -17,9 +17,17 @@ #pragma implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +/* + It is necessary to include set_var.h instead of item.h because there + are dependencies on include order for set_var.h and item.h. This + will be resolved later. +*/ +#include "sql_class.h" // set_var.h: THD +#include "set_var.h" #include "my_xml.h" #include "sp_pcontext.h" +#include "sql_class.h" // THD /* TODO: future development directions: diff --git a/sql/key.cc b/sql/key.cc index 93197ec4ff5..d593850ca10 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -16,7 +16,10 @@ /* Functions to handle keys and fields in forms */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" // REQUIRED: by includes later +#include "key.h" // key_rec_cmp +#include "field.h" // Field /* Search after a key that starts with 'field' diff --git a/sql/key.h b/sql/key.h new file mode 100644 index 00000000000..8b416da5846 --- /dev/null +++ b/sql/key.h @@ -0,0 +1,39 @@ +/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef KEY_INCLUDED +#define KEY_INCLUDED + +#include "my_global.h" /* uchar */ + +class Field; +class String; +struct TABLE; +typedef struct st_bitmap MY_BITMAP; +typedef struct st_key KEY; +typedef struct st_key_part_info KEY_PART_INFO; + +int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field, + uint *key_length, uint *keypart); +void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, uint key_length); +void key_restore(uchar *to_record, uchar *from_key, KEY *key_info, + uint key_length); +bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length); +void key_unpack(String *to,TABLE *form,uint index); +bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields); +int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length); +extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b); + +#endif /* KEY_INCLUDED */ diff --git a/sql/keycaches.h b/sql/keycaches.h index 542a4d14c3d..66d24b59465 100644 --- a/sql/keycaches.h +++ b/sql/keycaches.h @@ -1,3 +1,6 @@ +#ifndef KEYCACHES_INCLUDED +#define KEYCACHES_INCLUDED + /* Copyright (C) 2002-2006 MySQL AB, 2009 Sun Microsystems, Inc. This program is free software; you can redistribute it and/or modify @@ -39,3 +42,4 @@ KEY_CACHE *get_or_create_key_cache(const char *name, uint length); void free_key_cache(const char *name, KEY_CACHE *key_cache); bool process_key_caches(process_key_cache_t func); +#endif /* KEYCACHES_INCLUDED */ diff --git a/sql/lex_hash.h b/sql/lex_hash.h new file mode 100644 index 00000000000..60b54ef118f --- /dev/null +++ b/sql/lex_hash.h @@ -0,0 +1,6383 @@ +/* + + Do not edit this file directly! + +*/ +/* Copyright 2001-2008 MySQL AB, 2008 Sun Microsystems, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston + MA 02110-1301 USA. */ + +/* Do not edit this file! This is generated by gen_lex_hash.cc +that seeks for a perfect hash function */ + +#include "lex.h" + +static uchar sql_functions_map[12988]= { +'<', '>', 29, 0, +'!', '|', 32, 0, +'<', 'X', 150, 0, +'B', 'Y', 46, 1, +'A', 'W', 211, 2, +'A', 'V', 68, 4, +'A', 'W', 169, 5, +'C', 'Z', 100, 7, +'A', 'V', 31, 9, +'A', 'Y', 205, 9, +'C', 'U', 169, 10, +'C', 'V', 17, 11, +'D', 'U', 174, 11, +'A', 'U', 206, 11, +'A', 'S', 19, 12, +'H', 'U', 82, 12, +'C', 'S', 96, 12, +'C', 'S', 140, 12, +0, 0, 211, 1, +'M', 'M', 157, 12, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 29, 1, +0, 0, 31, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 27, 1, +0, 0, 1, 0, +0, 0, 5, 0, +0, 0, 6, 0, +0, 0, 4, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 0, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'<', '>', 124, 0, +0, 0, 61, 2, +'=', '>', 127, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'T', 129, 0, +0, 0, 47, 0, +0, 0, 61, 2, +0, 0, 134, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'F', 'S', 131, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 71, 1, +'N', 'R', 145, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 2, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 55, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 60, 2, +0, 0, 8, 0, +0, 0, 2, 0, +0, 0, 3, 0, +0, 0, 7, 0, +0, 0, 9, 0, +0, 0, 23, 0, +0, 0, 27, 0, +0, 0, 205, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 209, 0, +0, 0, 229, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 232, 0, +0, 0, 82, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 90, 1, +0, 0, 10, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'V', 179, 0, +0, 0, 40, 0, +0, 0, 93, 0, +'A', 'I', 220, 0, +0, 0, 146, 0, +0, 0, 177, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'P', 229, 0, +0, 0, 61, 2, +0, 0, 238, 0, +0, 0, 61, 2, +'A', 'O', 232, 0, +'D', 'O', 2, 1, +'N', 'U', 18, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 167, 1, +'E', 'U', 26, 1, +0, 0, 61, 2, +0, 0, 27, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'M', 'O', 43, 1, +0, 0, 13, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 17, 0, +0, 0, 61, 2, +'D', 'Y', 198, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 24, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 31, 0, +0, 0, 21, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 22, 0, +0, 0, 109, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 115, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 133, 0, +0, 0, 220, 0, +0, 0, 61, 2, +0, 0, 231, 0, +0, 0, 243, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'N', 247, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 52, 1, +0, 0, 242, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 241, 255, +0, 0, 66, 1, +0, 0, 69, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'T', 'W', 14, 1, +0, 0, 75, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 240, 255, +0, 0, 83, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 92, 1, +0, 0, 186, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 204, 1, +0, 0, 61, 2, +0, 0, 223, 1, +0, 0, 237, 255, +0, 0, 230, 255, +0, 0, 56, 2, +0, 0, 61, 2, +0, 0, 54, 2, +'L', 'Y', 70, 1, +'A', 'U', 90, 1, +'A', 'U', 135, 1, +'A', 'X', 162, 1, +'A', 'U', 204, 1, +0, 0, 61, 2, +'A', 'O', 225, 1, +'N', 'N', 243, 1, +0, 0, 237, 0, +'E', 'I', 20, 2, +'A', 'O', 25, 2, +0, 0, 53, 1, +'A', 'U', 78, 2, +0, 0, 85, 1, +'A', 'R', 99, 2, +0, 0, 61, 2, +'E', 'O', 117, 2, +'H', 'T', 138, 2, +'E', 'Y', 151, 2, +'N', 'S', 190, 2, +0, 0, 48, 2, +'A', 'O', 196, 2, +0, 0, 53, 2, +0, 0, 57, 2, +0, 0, 41, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'T', 84, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 48, 0, +0, 0, 43, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 45, 0, +'L', 'S', 111, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 58, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 68, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 96, 0, +0, 0, 50, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'T', 119, 1, +0, 0, 53, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 251, 255, +'T', 'T', 156, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 123, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 130, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 136, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 137, 0, +'A', 'E', 157, 1, +0, 0, 103, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 107, 0, +0, 0, 141, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 142, 0, +0, 0, 61, 2, +'D', 'U', 186, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 160, 0, +0, 0, 147, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 150, 0, +0, 0, 166, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 170, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 181, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 182, 0, +0, 0, 194, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 196, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'U', 240, 1, +0, 0, 198, 0, +0, 0, 61, 2, +0, 0, 200, 0, +'T', 'T', 244, 1, +'1', 'O', 245, 1, +0, 0, 221, 0, +0, 0, 222, 0, +0, 0, 223, 0, +0, 0, 224, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 225, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 228, 0, +0, 0, 239, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 241, 0, +0, 0, 243, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'F', 'S', 40, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'K', 'S', 54, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'O', 63, 2, +0, 0, 247, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 248, 0, +0, 0, 250, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 255, 0, +0, 0, 0, 1, +0, 0, 61, 2, +0, 0, 4, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 7, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 8, 1, +0, 0, 11, 1, +0, 0, 62, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 70, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 74, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 77, 1, +0, 0, 98, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 109, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 113, 1, +'A', 'A', 128, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 168, 1, +'D', 'L', 129, 2, +0, 0, 126, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 130, 1, +0, 0, 188, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 194, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 198, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 228, 1, +0, 0, 248, 1, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'E', 172, 2, +0, 0, 251, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'U', 177, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 9, 2, +0, 0, 249, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 250, 1, +0, 0, 227, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 7, 2, +0, 0, 15, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 28, 2, +0, 0, 42, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 44, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 45, 2, +0, 0, 49, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 50, 2, +'F', 'S', 234, 2, +'E', 'T', 248, 2, +'A', 'R', 8, 3, +0, 0, 61, 2, +'R', 'V', 31, 3, +'A', 'O', 42, 3, +'R', 'R', 75, 3, +0, 0, 199, 0, +'N', 'N', 91, 3, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 104, 3, +'A', 'U', 151, 3, +'A', 'C', 172, 3, +'R', 'W', 175, 3, +'H', 'U', 181, 3, +'U', 'U', 195, 3, +'A', 'T', 201, 3, +'H', 'W', 240, 3, +'A', 'Y', 0, 4, +'N', 'S', 25, 4, +0, 0, 35, 2, +'H', 'R', 52, 4, +0, 0, 14, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 19, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 25, 0, +0, 0, 35, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 42, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 46, 0, +0, 0, 49, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'E', 26, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 66, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 250, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 95, 0, +0, 0, 55, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 0, +0, 0, 151, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'E', 36, 3, +'N', 'R', 37, 3, +0, 0, 155, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 157, 0, +0, 0, 165, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 168, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'X', 57, 3, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'U', 64, 3, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'U', 71, 3, +0, 0, 171, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 172, 0, +0, 0, 173, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 176, 0, +0, 0, 178, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 180, 0, +'A', 'O', 76, 3, +0, 0, 190, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 192, 0, +'D', 'O', 92, 3, +0, 0, 210, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 214, 0, +0, 0, 215, 0, +'A', 'V', 115, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'M', 'N', 137, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'C', 139, 3, +0, 0, 245, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 249, 0, +0, 0, 251, 0, +0, 0, 253, 0, +'A', 'K', 140, 3, +0, 0, 1, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 5, 1, +0, 0, 30, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 43, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 56, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 60, 1, +0, 0, 63, 1, +0, 0, 61, 2, +0, 0, 68, 1, +0, 0, 91, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 93, 1, +0, 0, 61, 2, +0, 0, 95, 1, +0, 0, 104, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 107, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 121, 1, +'E', 'I', 196, 3, +0, 0, 123, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 124, 1, +0, 0, 125, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'S', 221, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 162, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 163, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 170, 1, +0, 0, 129, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 138, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 154, 1, +0, 0, 187, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 193, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 224, 1, +0, 0, 236, 1, +0, 0, 61, 2, +0, 0, 238, 1, +0, 0, 240, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 10, 2, +'I', 'T', 31, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'I', 43, 4, +0, 0, 17, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 23, 2, +0, 0, 26, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 31, 2, +'E', 'I', 63, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 52, 2, +0, 0, 46, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 47, 2, +0, 0, 12, 0, +'A', 'I', 90, 4, +'H', 'U', 125, 4, +'E', 'O', 141, 4, +'L', 'X', 152, 4, +'A', 'L', 172, 4, +'L', 'R', 192, 4, +0, 0, 195, 0, +'G', 'S', 199, 4, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'I', 226, 4, +'A', 'O', 231, 4, +0, 0, 61, 2, +'F', 'P', 0, 5, +'A', 'L', 11, 5, +0, 0, 61, 2, +'E', 'O', 23, 5, +'C', 'U', 55, 5, +0, 0, 242, 1, +'N', 'P', 162, 5, +0, 0, 36, 2, +0, 0, 33, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 34, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'G', 'T', 99, 4, +0, 0, 37, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'L', 113, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 253, 255, +0, 0, 38, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 39, 0, +0, 0, 56, 0, +0, 0, 63, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 65, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'M', 139, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 94, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 101, 0, +0, 0, 71, 0, +0, 0, 75, 0, +0, 0, 122, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 135, 0, +0, 0, 143, 0, +0, 0, 61, 2, +'A', 'G', 165, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 152, 0, +0, 0, 153, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 156, 0, +0, 0, 61, 2, +0, 0, 159, 0, +0, 0, 144, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 148, 0, +0, 0, 167, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 169, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'O', 184, 4, +'A', 'A', 185, 4, +'T', 'T', 186, 4, +'4', '8', 187, 4, +0, 0, 174, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 175, 0, +0, 0, 189, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 191, 0, +0, 0, 206, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 208, 0, +'F', 'S', 212, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 234, 0, +0, 0, 212, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 217, 0, +0, 0, 246, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 252, 0, +0, 0, 13, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'M', 246, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 48, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 55, 1, +0, 0, 38, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 42, 1, +0, 0, 80, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 88, 1, +0, 0, 97, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 105, 1, +'G', 'V', 34, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 165, 1, +0, 0, 137, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 144, 1, +0, 0, 145, 1, +0, 0, 146, 1, +0, 0, 61, 2, +'A', 'E', 50, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 158, 1, +0, 0, 159, 1, +0, 0, 61, 2, +0, 0, 161, 1, +0, 0, 148, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 152, 1, +0, 0, 173, 1, +0, 0, 61, 2, +'C', 'R', 74, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'G', 'M', 104, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'U', 117, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'R', 141, 5, +0, 0, 232, 255, +0, 0, 176, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 179, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'V', 90, 5, +0, 0, 182, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 185, 1, +'N', 'N', 111, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 192, 1, +'A', 'E', 112, 5, +0, 0, 190, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 191, 1, +0, 0, 197, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 199, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'R', 136, 5, +0, 0, 200, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 201, 1, +'R', 'T', 159, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 236, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 231, 1, +0, 0, 226, 1, +0, 0, 61, 2, +0, 0, 227, 1, +'I', 'L', 165, 5, +0, 0, 61, 2, +0, 0, 24, 2, +0, 0, 18, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 20, 2, +'D', 'U', 192, 5, +'E', 'O', 210, 5, +'A', 'U', 247, 5, +'E', 'Y', 56, 6, +'N', 'X', 104, 6, +0, 0, 179, 0, +0, 0, 185, 0, +0, 0, 193, 0, +'N', 'T', 131, 6, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 157, 6, +0, 0, 47, 1, +'A', 'U', 168, 6, +'P', 'U', 189, 6, +'A', 'R', 195, 6, +0, 0, 122, 1, +'E', 'O', 228, 6, +'C', 'Y', 2, 7, +'I', 'R', 50, 7, +'N', 'S', 60, 7, +'A', 'A', 69, 7, +0, 0, 51, 2, +0, 0, 255, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 15, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 20, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 28, 0, +0, 0, 36, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'T', 'T', 221, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 44, 0, +'_', '_', 222, 5, +'A', 'X', 223, 5, +0, 0, 254, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 252, 255, +0, 0, 51, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'A', 12, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'N', 18, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'R', 38, 6, +'N', 'R', 13, 6, +0, 0, 57, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 60, 0, +'L', 'U', 21, 6, +'M', 'P', 31, 6, +'T', 'V', 35, 6, +0, 0, 69, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 73, 0, +0, 0, 74, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 77, 0, +0, 0, 89, 0, +0, 0, 61, 2, +0, 0, 92, 0, +'D', 'T', 39, 6, +0, 0, 249, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 248, 255, +'C', 'L', 77, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'S', 100, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 140, 0, +'I', 'L', 87, 6, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'I', 91, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 120, 0, +0, 0, 116, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 117, 0, +0, 0, 118, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 119, 0, +'A', 'C', 101, 6, +0, 0, 128, 0, +0, 0, 61, 2, +0, 0, 129, 0, +0, 0, 149, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 154, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'T', 115, 6, +0, 0, 158, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 162, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 245, 255, +'D', 'V', 138, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 235, 0, +0, 0, 211, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 219, 0, +0, 0, 226, 0, +0, 0, 61, 2, +0, 0, 236, 0, +0, 0, 244, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 6, 1, +0, 0, 65, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 72, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 78, 1, +0, 0, 87, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 94, 1, +0, 0, 99, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 106, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 108, 1, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 213, 6, +0, 0, 111, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 114, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'F', 224, 6, +0, 0, 117, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 119, 1, +'B', 'T', 239, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 166, 1, +0, 0, 131, 1, +0, 0, 132, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 143, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 150, 1, +0, 0, 153, 1, +0, 0, 61, 2, +0, 0, 156, 1, +0, 0, 160, 1, +0, 0, 175, 1, +0, 0, 61, 2, +0, 0, 184, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 202, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 229, 1, +'B', 'S', 25, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 229, 255, +'D', 'J', 43, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 237, 1, +0, 0, 233, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 233, 1, +0, 0, 0, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 5, 2, +'I', 'K', 66, 7, +0, 0, 61, 2, +0, 0, 25, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 30, 2, +0, 0, 16, 2, +0, 0, 61, 2, +0, 0, 19, 2, +'R', 'R', 70, 7, +'C', '_', 71, 7, +0, 0, 38, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 41, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 225, 255, +'A', 'O', 124, 7, +'A', 'U', 163, 7, +'N', 'X', 231, 7, +'U', 'U', 242, 7, +0, 0, 186, 0, +0, 0, 61, 2, +0, 0, 227, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'O', 246, 7, +'A', 'O', 26, 8, +'A', 'V', 54, 8, +'N', 'P', 76, 8, +'A', 'R', 79, 8, +0, 0, 61, 2, +'E', 'O', 108, 8, +'C', 'W', 147, 8, +'I', 'R', 168, 8, +'N', 'T', 220, 8, +'A', 'A', 6, 9, +0, 0, 43, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 59, 2, +0, 0, 52, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 62, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'N', 139, 7, +0, 0, 67, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'T', 'T', 153, 7, +'A', 'I', 154, 7, +0, 0, 88, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 90, 0, +'T', 'Y', 184, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 124, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 131, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 138, 0, +'A', 'E', 190, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 110, 0, +'B', 'F', 195, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'T', '_', 200, 7, +0, 0, 104, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 106, 0, +0, 0, 108, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'S', 212, 7, +0, 0, 247, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 246, 255, +0, 0, 145, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 163, 0, +'L', 'N', 243, 7, +0, 0, 183, 0, +0, 0, 61, 2, +0, 0, 184, 0, +0, 0, 242, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'N', 5, 8, +'G', 'G', 6, 8, +'B', 'T', 7, 8, +0, 0, 9, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 10, 1, +'X', 'X', 41, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 51, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 54, 1, +'V', '_', 42, 8, +0, 0, 37, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'S', 52, 8, +0, 0, 33, 1, +0, 0, 34, 1, +0, 0, 64, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 79, 1, +0, 0, 84, 1, +0, 0, 61, 2, +0, 0, 86, 1, +0, 0, 103, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 239, 255, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 97, 8, +0, 0, 112, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 120, 1, +'D', 'S', 119, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 164, 1, +0, 0, 134, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 139, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'T', 135, 8, +0, 0, 155, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 157, 1, +0, 0, 172, 1, +0, 0, 61, 2, +0, 0, 178, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 189, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 196, 1, +0, 0, 195, 1, +0, 0, 61, 2, +0, 0, 203, 1, +0, 0, 206, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 225, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 239, 1, +'N', 'N', 178, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'U', 199, 8, +'Y', 'Y', 179, 8, +'B', 'T', 180, 8, +0, 0, 255, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 1, 2, +0, 0, 3, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 6, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 8, 2, +'D', 'S', 227, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'C', 243, 8, +0, 0, 14, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 22, 2, +'_', '_', 244, 8, +'D', 'T', 245, 8, +0, 0, 32, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 33, 2, +'R', 'R', 7, 9, +'I', '_', 8, 9, +0, 0, 226, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 224, 255, +'G', 'L', 53, 9, +0, 0, 61, 2, +'H', 'O', 59, 9, +'A', 'U', 70, 9, +0, 0, 161, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'S', 91, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 2, 1, +'E', 'I', 96, 9, +0, 0, 73, 1, +0, 0, 61, 2, +'A', 'R', 101, 9, +0, 0, 61, 2, +'E', 'E', 146, 9, +'A', 'U', 151, 9, +'E', 'I', 175, 9, +'N', 'N', 188, 9, +'A', 'A', 195, 9, +0, 0, 16, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 18, 0, +0, 0, 59, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'N', 67, 9, +0, 0, 70, 0, +0, 0, 76, 0, +0, 0, 81, 0, +0, 0, 105, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 127, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 139, 0, +0, 0, 230, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 233, 0, +0, 0, 40, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 46, 1, +'C', 'R', 119, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 135, 9, +0, 0, 96, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 100, 1, +0, 0, 110, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 116, 1, +'A', 'D', 147, 9, +0, 0, 127, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 135, 1, +0, 0, 171, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'P', 172, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 210, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 231, 255, +0, 0, 180, 1, +0, 0, 61, 2, +0, 0, 181, 1, +'M', 'M', 180, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 252, 1, +'P', 'P', 181, 9, +'O', 'T', 182, 9, +0, 0, 245, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 246, 1, +'D', 'I', 189, 9, +0, 0, 12, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 21, 2, +'R', 'R', 196, 9, +'B', 'I', 197, 9, +0, 0, 37, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 40, 2, +'C', 'S', 230, 9, +0, 0, 61, 2, +'O', 'O', 247, 9, +'A', 'E', 31, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 188, 0, +0, 0, 61, 2, +0, 0, 204, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 254, 0, +'A', 'U', 45, 10, +0, 0, 67, 1, +0, 0, 89, 1, +'A', 'R', 89, 10, +0, 0, 61, 2, +'E', 'O', 107, 10, +'Q', 'T', 134, 10, +'A', 'E', 148, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 58, 2, +0, 0, 11, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 26, 0, +'M', 'N', 248, 9, +'P', 'P', 250, 9, +'C', 'S', 2, 10, +'L', 'R', 251, 9, +0, 0, 78, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 79, 0, +0, 0, 80, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 82, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'T', 19, 10, +0, 0, 83, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 84, 0, +'Y', 'Y', 36, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 114, 0, +'_', '_', 37, 10, +'M', 'S', 38, 10, +0, 0, 112, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 113, 0, +0, 0, 21, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'D', 66, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 58, 1, +'I', 'I', 67, 10, +'U', 'U', 68, 10, +'M', 'M', 69, 10, +'B', 'T', 70, 10, +0, 0, 39, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 41, 1, +0, 0, 102, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 115, 1, +'A', 'P', 118, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 169, 1, +0, 0, 128, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 136, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 147, 1, +0, 0, 149, 1, +'L', 'L', 138, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 235, 255, +'W', '_', 139, 10, +0, 0, 207, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 214, 1, +'B', 'B', 153, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 247, 1, +'L', 'L', 154, 10, +'E', 'E', 155, 10, +'S', '_', 156, 10, +0, 0, 243, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 241, 1, +'O', 'U', 188, 10, +0, 0, 132, 0, +0, 0, 164, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'O', 195, 10, +0, 0, 216, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'Y', 206, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 118, 1, +0, 0, 61, 2, +0, 0, 151, 1, +'C', 'Y', 250, 10, +0, 0, 4, 2, +0, 0, 11, 2, +0, 0, 72, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 102, 0, +'U', 'U', 196, 10, +'R', 'R', 197, 10, +'_', '_', 198, 10, +'M', 'S', 199, 10, +0, 0, 202, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 203, 0, +'S', 'S', 231, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 45, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 1, +'T', 'T', 232, 10, +'E', 'E', 233, 10, +'R', 'R', 234, 10, +'_', '_', 235, 10, +'H', 'U', 236, 10, +0, 0, 15, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 19, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 28, 1, +0, 0, 174, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 218, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 234, 255, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 228, 255, +'A', 'U', 37, 11, +0, 0, 125, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 244, 255, +0, 0, 61, 2, +0, 0, 213, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 12, 1, +'E', 'U', 82, 11, +0, 0, 61, 2, +0, 0, 81, 1, +0, 0, 101, 1, +0, 0, 61, 2, +0, 0, 142, 1, +'E', 'U', 99, 11, +0, 0, 253, 1, +0, 0, 61, 2, +0, 0, 39, 2, +0, 0, 54, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 64, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 91, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'R', 58, 11, +'R', 'R', 59, 11, +'E', 'E', 60, 11, +'N', 'N', 61, 11, +'T', 'T', 62, 11, +'_', '_', 63, 11, +'D', 'U', 64, 11, +0, 0, 97, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 98, 0, +0, 0, 100, 0, +0, 0, 44, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 59, 1, +'R', 'S', 116, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'L', 118, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 234, 1, +0, 0, 183, 1, +0, 0, 238, 255, +'E', '_', 119, 11, +0, 0, 205, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'T', 146, 11, +0, 0, 212, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'S', 153, 11, +'I', 'I', 154, 11, +'_', '_', 155, 11, +'H', 'Y', 156, 11, +0, 0, 217, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 219, 1, +0, 0, 61, 2, +0, 0, 222, 1, +0, 0, 126, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 197, 0, +0, 0, 218, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'I', 192, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 141, 1, +'Q', 'U', 201, 11, +0, 0, 254, 1, +0, 0, 34, 2, +0, 0, 22, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 50, 1, +0, 0, 220, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 230, 1, +0, 0, 235, 1, +'U', 'V', 227, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 240, 0, +0, 0, 3, 1, +'A', 'A', 229, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 140, 1, +'Q', 'Q', 243, 11, +0, 0, 244, 1, +0, 0, 29, 2, +0, 0, 29, 0, +0, 0, 32, 0, +'S', 'S', 230, 11, +'T', 'T', 231, 11, +'E', 'E', 232, 11, +'R', 'R', 233, 11, +'_', '_', 234, 11, +'L', 'S', 235, 11, +0, 0, 17, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 26, 1, +'L', 'L', 244, 11, +'_', '_', 245, 11, +'B', 'T', 246, 11, +0, 0, 208, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'S', 9, 12, +'I', 'I', 10, 12, +'_', '_', 11, 12, +'M', 'S', 12, 12, +0, 0, 216, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 215, 1, +0, 0, 30, 0, +0, 0, 61, 2, +0, 0, 86, 0, +'A', 'E', 38, 12, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'U', 43, 12, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'Q', 'U', 77, 12, +0, 0, 111, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 121, 0, +'S', 'S', 64, 12, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 57, 1, +'T', 'T', 65, 12, +'E', 'E', 66, 12, +'R', 'R', 67, 12, +'_', '_', 68, 12, +'L', 'S', 69, 12, +0, 0, 16, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 18, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 24, 1, +0, 0, 221, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 232, 1, +0, 0, 201, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 20, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 133, 1, +0, 0, 213, 1, +0, 0, 61, 2, +0, 0, 13, 2, +'O', 'U', 113, 12, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 207, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'A', 120, 12, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 209, 1, +0, 0, 87, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 99, 0, +'S', 'S', 121, 12, +'T', 'T', 122, 12, +'E', 'E', 123, 12, +'R', 'R', 124, 12, +'_', '_', 125, 12, +'S', 'S', 126, 12, +'S', 'S', 127, 12, +'L', 'L', 128, 12, +'_', '_', 129, 12, +'C', 'C', 130, 12, +'A', 'I', 131, 12, +0, 0, 23, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 25, 1, +0, 0, 85, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 187, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 49, 1, +0, 0, 76, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 177, 1, +'A', 'A', 158, 12, +'S', 'X', 159, 12, +0, 0, 14, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'_', '_', 165, 12, +'Q', 'U', 166, 12, +0, 0, 32, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'P', 'S', 171, 12, +0, 0, 35, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 36, 1, +}; + +static uchar symbols_map[12128]= { +'<', '>', 29, 0, +'!', '|', 32, 0, +'<', 'X', 150, 0, +'B', 'Y', 14, 1, +'A', 'W', 150, 2, +'A', 'V', 7, 4, +'A', 'W', 101, 5, +'C', 'Z', 214, 6, +'A', 'V', 89, 8, +'A', 'Y', 3, 9, +'C', 'U', 220, 9, +'C', 'V', 60, 10, +'D', 'U', 215, 10, +'A', 'U', 247, 10, +'A', 'S', 60, 11, +'H', 'U', 123, 11, +'C', 'S', 137, 11, +'C', 'S', 181, 11, +0, 0, 211, 1, +'M', 'M', 198, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 29, 1, +0, 0, 31, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 27, 1, +0, 0, 1, 0, +0, 0, 5, 0, +0, 0, 6, 0, +0, 0, 4, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 0, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'<', '>', 124, 0, +0, 0, 61, 2, +'=', '>', 127, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'T', 129, 0, +0, 0, 47, 0, +0, 0, 61, 2, +0, 0, 134, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'F', 'S', 131, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 71, 1, +'N', 'R', 145, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 2, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 55, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 60, 2, +0, 0, 8, 0, +0, 0, 2, 0, +0, 0, 3, 0, +0, 0, 7, 0, +0, 0, 9, 0, +0, 0, 23, 0, +0, 0, 27, 0, +0, 0, 205, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 209, 0, +0, 0, 229, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 232, 0, +0, 0, 82, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 90, 1, +0, 0, 10, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'V', 179, 0, +0, 0, 40, 0, +0, 0, 93, 0, +'A', 'I', 220, 0, +0, 0, 146, 0, +0, 0, 177, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'P', 229, 0, +0, 0, 61, 2, +0, 0, 238, 0, +0, 0, 61, 2, +0, 0, 52, 1, +'D', 'O', 232, 0, +'N', 'U', 244, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 167, 1, +'E', 'S', 252, 0, +0, 0, 61, 2, +0, 0, 27, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'M', 'O', 11, 1, +0, 0, 13, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 17, 0, +0, 0, 61, 2, +'D', 'Y', 198, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 24, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 31, 0, +0, 0, 21, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 22, 0, +0, 0, 109, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 115, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 133, 0, +0, 0, 220, 0, +0, 0, 61, 2, +0, 0, 231, 0, +0, 0, 66, 1, +0, 0, 69, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 75, 1, +0, 0, 83, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 92, 1, +0, 0, 186, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 204, 1, +0, 0, 61, 2, +0, 0, 223, 1, +0, 0, 56, 2, +0, 0, 61, 2, +0, 0, 54, 2, +'L', 'Y', 38, 1, +'A', 'U', 58, 1, +'A', 'U', 87, 1, +'A', 'X', 114, 1, +'A', 'U', 156, 1, +0, 0, 61, 2, +'A', 'O', 177, 1, +'N', 'N', 195, 1, +0, 0, 237, 0, +'E', 'I', 228, 1, +'A', 'O', 233, 1, +0, 0, 53, 1, +'A', 'U', 30, 2, +0, 0, 85, 1, +'A', 'R', 51, 2, +0, 0, 61, 2, +'E', 'O', 69, 2, +'H', 'T', 90, 2, +'E', 'Y', 103, 2, +'N', 'S', 129, 2, +0, 0, 48, 2, +'A', 'O', 135, 2, +0, 0, 53, 2, +0, 0, 57, 2, +0, 0, 41, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'T', 52, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 48, 0, +0, 0, 43, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 45, 0, +'L', 'S', 79, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 58, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 68, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 96, 0, +0, 0, 50, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 53, 0, +'T', 'T', 108, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 123, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 130, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 136, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 137, 0, +'A', 'E', 109, 1, +0, 0, 103, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 107, 0, +0, 0, 141, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 142, 0, +0, 0, 61, 2, +'D', 'U', 138, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 160, 0, +0, 0, 147, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 150, 0, +0, 0, 166, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 170, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 181, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 182, 0, +0, 0, 194, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 196, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'U', 192, 1, +0, 0, 198, 0, +0, 0, 61, 2, +0, 0, 200, 0, +'T', 'T', 196, 1, +'1', 'O', 197, 1, +0, 0, 221, 0, +0, 0, 222, 0, +0, 0, 223, 0, +0, 0, 224, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 225, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 228, 0, +0, 0, 239, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 241, 0, +0, 0, 243, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'F', 'S', 248, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'K', 'S', 6, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'O', 15, 2, +0, 0, 247, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 248, 0, +0, 0, 250, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 255, 0, +0, 0, 0, 1, +0, 0, 61, 2, +0, 0, 4, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 7, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 8, 1, +0, 0, 11, 1, +0, 0, 62, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 70, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 74, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 77, 1, +0, 0, 98, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 109, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 113, 1, +'A', 'A', 80, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 168, 1, +'D', 'L', 81, 2, +0, 0, 126, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 130, 1, +0, 0, 188, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 194, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 198, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 228, 1, +0, 0, 248, 1, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'E', 124, 2, +0, 0, 251, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 7, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 9, 2, +0, 0, 249, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 250, 1, +0, 0, 15, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 28, 2, +0, 0, 42, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 44, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 45, 2, +0, 0, 49, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 50, 2, +'F', 'S', 173, 2, +'E', 'T', 187, 2, +'A', 'R', 203, 2, +0, 0, 61, 2, +'R', 'V', 226, 2, +'A', 'O', 237, 2, +'R', 'R', 14, 3, +0, 0, 199, 0, +'N', 'N', 30, 3, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 43, 3, +'A', 'U', 90, 3, +'A', 'C', 111, 3, +'R', 'W', 114, 3, +'H', 'U', 120, 3, +'U', 'U', 134, 3, +'A', 'T', 140, 3, +'H', 'W', 179, 3, +'A', 'Y', 195, 3, +'N', 'S', 220, 3, +0, 0, 35, 2, +'H', 'R', 247, 3, +0, 0, 14, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 19, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 25, 0, +0, 0, 35, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 42, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 46, 0, +0, 0, 49, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'E', 221, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 66, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 95, 0, +0, 0, 55, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 0, +0, 0, 151, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'E', 231, 2, +'N', 'R', 232, 2, +0, 0, 155, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 157, 0, +0, 0, 165, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 168, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'X', 252, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'U', 3, 3, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'U', 10, 3, +0, 0, 171, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 172, 0, +0, 0, 173, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 176, 0, +0, 0, 178, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 180, 0, +'A', 'O', 15, 3, +0, 0, 190, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 192, 0, +'D', 'O', 31, 3, +0, 0, 210, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 214, 0, +0, 0, 215, 0, +'A', 'V', 54, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'M', 'N', 76, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'C', 78, 3, +0, 0, 245, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 249, 0, +0, 0, 251, 0, +0, 0, 253, 0, +'A', 'K', 79, 3, +0, 0, 1, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 5, 1, +0, 0, 30, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 43, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 56, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 60, 1, +0, 0, 63, 1, +0, 0, 61, 2, +0, 0, 68, 1, +0, 0, 91, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 93, 1, +0, 0, 61, 2, +0, 0, 95, 1, +0, 0, 104, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 107, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 121, 1, +'E', 'I', 135, 3, +0, 0, 123, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 124, 1, +0, 0, 125, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'S', 160, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 162, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 163, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 170, 1, +0, 0, 129, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 138, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 154, 1, +0, 0, 187, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 193, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 224, 1, +0, 0, 236, 1, +0, 0, 61, 2, +0, 0, 238, 1, +0, 0, 240, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 10, 2, +'I', 'T', 226, 3, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'I', 238, 3, +0, 0, 17, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 23, 2, +0, 0, 26, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 31, 2, +'E', 'I', 2, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 52, 2, +0, 0, 46, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 47, 2, +0, 0, 12, 0, +'A', 'I', 29, 4, +'H', 'U', 58, 4, +'E', 'O', 74, 4, +'L', 'X', 85, 4, +'A', 'L', 105, 4, +'L', 'R', 125, 4, +0, 0, 195, 0, +'G', 'S', 132, 4, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'I', 159, 4, +'A', 'O', 164, 4, +0, 0, 61, 2, +'F', 'P', 189, 4, +'A', 'L', 200, 4, +0, 0, 61, 2, +'E', 'O', 212, 4, +'C', 'T', 244, 4, +0, 0, 242, 1, +'N', 'P', 94, 5, +0, 0, 36, 2, +0, 0, 33, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 34, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'G', 'N', 38, 4, +0, 0, 37, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'L', 46, 4, +0, 0, 38, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 39, 0, +0, 0, 56, 0, +0, 0, 63, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 65, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'M', 72, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 94, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 101, 0, +0, 0, 71, 0, +0, 0, 75, 0, +0, 0, 122, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 135, 0, +0, 0, 143, 0, +0, 0, 61, 2, +'A', 'G', 98, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 152, 0, +0, 0, 153, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 156, 0, +0, 0, 61, 2, +0, 0, 159, 0, +0, 0, 144, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 148, 0, +0, 0, 167, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 169, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'O', 117, 4, +'A', 'A', 118, 4, +'T', 'T', 119, 4, +'4', '8', 120, 4, +0, 0, 174, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 175, 0, +0, 0, 189, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 191, 0, +0, 0, 206, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 208, 0, +'F', 'S', 145, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 234, 0, +0, 0, 212, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 217, 0, +0, 0, 246, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 252, 0, +0, 0, 13, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'M', 179, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 48, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 55, 1, +0, 0, 38, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 42, 1, +0, 0, 80, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 88, 1, +0, 0, 97, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 105, 1, +'G', 'V', 223, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 165, 1, +0, 0, 137, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 144, 1, +0, 0, 145, 1, +0, 0, 146, 1, +0, 0, 61, 2, +'A', 'E', 239, 4, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 158, 1, +0, 0, 159, 1, +0, 0, 61, 2, +0, 0, 161, 1, +0, 0, 148, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 152, 1, +0, 0, 173, 1, +0, 0, 61, 2, +'C', 'R', 6, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'G', 'M', 36, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'U', 49, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'R', 73, 5, +0, 0, 176, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 179, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'V', 22, 5, +0, 0, 182, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 185, 1, +'N', 'N', 43, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 192, 1, +'A', 'E', 44, 5, +0, 0, 190, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 191, 1, +0, 0, 197, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 199, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'R', 68, 5, +0, 0, 200, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 201, 1, +'R', 'T', 91, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 231, 1, +0, 0, 226, 1, +0, 0, 61, 2, +0, 0, 227, 1, +'I', 'L', 97, 5, +0, 0, 61, 2, +0, 0, 24, 2, +0, 0, 18, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 20, 2, +'G', 'U', 124, 5, +'E', 'O', 139, 5, +'A', 'O', 150, 5, +'E', 'Y', 191, 5, +'N', 'X', 239, 5, +0, 0, 179, 0, +0, 0, 185, 0, +0, 0, 193, 0, +'N', 'T', 6, 6, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 32, 6, +0, 0, 47, 1, +'A', 'U', 43, 6, +'P', 'U', 64, 6, +'A', 'R', 70, 6, +0, 0, 122, 1, +'E', 'O', 103, 6, +'C', 'U', 133, 6, +'I', 'R', 170, 6, +'N', 'S', 180, 6, +'A', 'A', 189, 6, +0, 0, 51, 2, +0, 0, 15, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 20, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 28, 0, +0, 0, 36, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 44, 0, +0, 0, 51, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'A', 165, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'N', 171, 5, +'N', 'R', 166, 5, +0, 0, 57, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 60, 0, +'L', 'U', 174, 5, +'M', 'P', 184, 5, +'T', 'V', 188, 5, +0, 0, 69, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 73, 0, +0, 0, 74, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 77, 0, +0, 0, 89, 0, +0, 0, 61, 2, +0, 0, 92, 0, +'C', 'L', 212, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'S', 235, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 140, 0, +'I', 'L', 222, 5, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'I', 226, 5, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 120, 0, +0, 0, 116, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 117, 0, +0, 0, 118, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 119, 0, +'A', 'C', 236, 5, +0, 0, 128, 0, +0, 0, 61, 2, +0, 0, 129, 0, +0, 0, 149, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 154, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'P', 250, 5, +0, 0, 158, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 162, 0, +'D', 'V', 13, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 235, 0, +0, 0, 211, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 219, 0, +0, 0, 226, 0, +0, 0, 61, 2, +0, 0, 236, 0, +0, 0, 244, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 6, 1, +0, 0, 65, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 72, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 78, 1, +0, 0, 87, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 94, 1, +0, 0, 99, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 106, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 108, 1, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 88, 6, +0, 0, 111, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 114, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'F', 99, 6, +0, 0, 117, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 119, 1, +'B', 'T', 114, 6, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 166, 1, +0, 0, 131, 1, +0, 0, 132, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 143, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 150, 1, +0, 0, 153, 1, +0, 0, 61, 2, +0, 0, 156, 1, +0, 0, 160, 1, +0, 0, 175, 1, +0, 0, 61, 2, +0, 0, 184, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 202, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 229, 1, +'B', 'S', 152, 6, +0, 0, 233, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 237, 1, +0, 0, 0, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 5, 2, +'I', 'K', 186, 6, +0, 0, 61, 2, +0, 0, 25, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 30, 2, +0, 0, 16, 2, +0, 0, 61, 2, +0, 0, 19, 2, +'R', 'R', 190, 6, +'C', 'Y', 191, 6, +0, 0, 38, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 41, 2, +'A', 'O', 238, 6, +'A', 'U', 21, 7, +'N', 'X', 58, 7, +'U', 'U', 69, 7, +0, 0, 186, 0, +0, 0, 61, 2, +0, 0, 227, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'O', 73, 7, +'A', 'O', 109, 7, +'A', 'V', 137, 7, +'N', 'P', 159, 7, +'A', 'R', 162, 7, +0, 0, 61, 2, +'E', 'O', 191, 7, +'C', 'W', 230, 7, +'I', 'R', 251, 7, +'N', 'T', 47, 8, +0, 0, 61, 2, +0, 0, 43, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 59, 2, +0, 0, 52, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 62, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'N', 253, 6, +0, 0, 67, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'T', 'T', 11, 7, +'A', 'I', 12, 7, +0, 0, 88, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 90, 0, +'T', 'Y', 42, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 124, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 131, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 138, 0, +'A', 'E', 48, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 110, 0, +'B', 'F', 53, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 108, 0, +0, 0, 104, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 106, 0, +0, 0, 145, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 163, 0, +'L', 'N', 70, 7, +0, 0, 183, 0, +0, 0, 61, 2, +0, 0, 184, 0, +0, 0, 242, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'N', 88, 7, +'G', 'G', 89, 7, +'B', 'T', 90, 7, +0, 0, 9, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 10, 1, +'X', 'X', 124, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 51, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 54, 1, +'V', '_', 125, 7, +0, 0, 37, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'S', 135, 7, +0, 0, 33, 1, +0, 0, 34, 1, +0, 0, 64, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 79, 1, +0, 0, 84, 1, +0, 0, 61, 2, +0, 0, 86, 1, +0, 0, 103, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 180, 7, +0, 0, 112, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 120, 1, +'D', 'S', 202, 7, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 164, 1, +0, 0, 134, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 139, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'T', 218, 7, +0, 0, 155, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 157, 1, +0, 0, 172, 1, +0, 0, 61, 2, +0, 0, 178, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 189, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 196, 1, +0, 0, 195, 1, +0, 0, 61, 2, +0, 0, 203, 1, +0, 0, 206, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 225, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 239, 1, +'N', 'N', 5, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'U', 26, 8, +'Y', 'Y', 6, 8, +'B', 'T', 7, 8, +0, 0, 255, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 1, 2, +0, 0, 3, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 6, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 8, 2, +'D', 'S', 54, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'C', 'C', 70, 8, +0, 0, 14, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 22, 2, +'_', '_', 71, 8, +'D', 'T', 72, 8, +0, 0, 32, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 33, 2, +'G', 'L', 111, 8, +0, 0, 61, 2, +'H', 'O', 117, 8, +'A', 'U', 128, 8, +0, 0, 161, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'S', 149, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 2, 1, +'E', 'I', 154, 8, +0, 0, 73, 1, +0, 0, 61, 2, +'A', 'R', 159, 8, +0, 0, 61, 2, +'E', 'E', 204, 8, +'A', 'Q', 209, 8, +'E', 'I', 229, 8, +'N', 'N', 242, 8, +'A', 'A', 249, 8, +0, 0, 16, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 18, 0, +0, 0, 59, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'N', 125, 8, +0, 0, 70, 0, +0, 0, 76, 0, +0, 0, 81, 0, +0, 0, 105, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 127, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 139, 0, +0, 0, 230, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 233, 0, +0, 0, 40, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 46, 1, +'C', 'R', 177, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'E', 'O', 193, 8, +0, 0, 96, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 100, 1, +0, 0, 110, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 116, 1, +'A', 'D', 205, 8, +0, 0, 127, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 135, 1, +0, 0, 171, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'P', 226, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 210, 1, +0, 0, 180, 1, +0, 0, 61, 2, +0, 0, 181, 1, +'M', 'M', 234, 8, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 252, 1, +'P', 'P', 235, 8, +'O', 'T', 236, 8, +0, 0, 245, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 246, 1, +'D', 'I', 243, 8, +0, 0, 12, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 21, 2, +'R', 'R', 250, 8, +'B', 'I', 251, 8, +0, 0, 37, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 40, 2, +'C', 'S', 28, 9, +0, 0, 61, 2, +'O', 'O', 45, 9, +'A', 'E', 85, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 188, 0, +0, 0, 61, 2, +0, 0, 204, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 254, 0, +'A', 'U', 99, 9, +0, 0, 67, 1, +0, 0, 89, 1, +'A', 'R', 143, 9, +0, 0, 61, 2, +'E', 'O', 161, 9, +'Q', 'Q', 188, 9, +'A', 'E', 199, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 58, 2, +0, 0, 11, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 26, 0, +'M', 'N', 46, 9, +'P', 'P', 48, 9, +'C', 'S', 56, 9, +'L', 'R', 49, 9, +0, 0, 78, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 79, 0, +0, 0, 80, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 82, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'I', 'T', 73, 9, +0, 0, 83, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 84, 0, +'Y', 'Y', 90, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 114, 0, +'_', '_', 91, 9, +'M', 'S', 92, 9, +0, 0, 112, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 113, 0, +0, 0, 21, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'D', 'D', 120, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 58, 1, +'I', 'I', 121, 9, +'U', 'U', 122, 9, +'M', 'M', 123, 9, +'B', 'T', 124, 9, +0, 0, 39, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 41, 1, +0, 0, 102, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 115, 1, +'A', 'P', 172, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 169, 1, +0, 0, 128, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 136, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 147, 1, +0, 0, 149, 1, +'L', 'L', 189, 9, +'W', '_', 190, 9, +0, 0, 207, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 214, 1, +'B', 'B', 204, 9, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 247, 1, +'L', 'L', 205, 9, +'E', 'E', 206, 9, +'S', '_', 207, 9, +0, 0, 243, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 241, 1, +'O', 'U', 239, 9, +0, 0, 132, 0, +0, 0, 164, 0, +0, 0, 61, 2, +0, 0, 61, 2, +'O', 'O', 246, 9, +0, 0, 216, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'Y', 1, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 118, 1, +0, 0, 61, 2, +0, 0, 151, 1, +'C', 'Q', 45, 10, +0, 0, 4, 2, +0, 0, 11, 2, +0, 0, 72, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 102, 0, +'U', 'U', 247, 9, +'R', 'R', 248, 9, +'_', '_', 249, 9, +'M', 'S', 250, 9, +0, 0, 202, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 203, 0, +'S', 'S', 26, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 45, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 1, +'T', 'T', 27, 10, +'E', 'E', 28, 10, +'R', 'R', 29, 10, +'_', '_', 30, 10, +'H', 'U', 31, 10, +0, 0, 15, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 19, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 28, 1, +0, 0, 174, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 218, 1, +'A', 'U', 80, 10, +0, 0, 125, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 213, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 12, 1, +'E', 'U', 125, 10, +0, 0, 61, 2, +0, 0, 81, 1, +0, 0, 101, 1, +0, 0, 61, 2, +0, 0, 142, 1, +'E', 'U', 142, 10, +0, 0, 253, 1, +0, 0, 61, 2, +0, 0, 39, 2, +0, 0, 54, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 64, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 91, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'R', 'R', 101, 10, +'R', 'R', 102, 10, +'E', 'E', 103, 10, +'N', 'N', 104, 10, +'T', 'T', 105, 10, +'_', '_', 106, 10, +'D', 'U', 107, 10, +0, 0, 97, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 98, 0, +0, 0, 100, 0, +0, 0, 44, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 59, 1, +0, 0, 183, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'L', 'L', 159, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 234, 1, +'E', '_', 160, 10, +0, 0, 205, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'N', 'T', 187, 10, +0, 0, 212, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'S', 194, 10, +'I', 'I', 195, 10, +'_', '_', 196, 10, +'H', 'Y', 197, 10, +0, 0, 217, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 219, 1, +0, 0, 61, 2, +0, 0, 222, 1, +0, 0, 126, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 197, 0, +0, 0, 218, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'I', 233, 10, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 141, 1, +'Q', 'U', 242, 10, +0, 0, 254, 1, +0, 0, 34, 2, +0, 0, 22, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 50, 1, +0, 0, 220, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 230, 1, +0, 0, 235, 1, +'U', 'V', 12, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 240, 0, +0, 0, 3, 1, +'A', 'A', 14, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 140, 1, +'Q', 'Q', 28, 11, +0, 0, 244, 1, +0, 0, 29, 2, +0, 0, 29, 0, +0, 0, 32, 0, +'S', 'S', 15, 11, +'T', 'T', 16, 11, +'E', 'E', 17, 11, +'R', 'R', 18, 11, +'_', '_', 19, 11, +'L', 'S', 20, 11, +0, 0, 17, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 26, 1, +'L', 'L', 29, 11, +'_', '_', 30, 11, +'B', 'T', 31, 11, +0, 0, 208, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'S', 'S', 50, 11, +'I', 'I', 51, 11, +'_', '_', 52, 11, +'M', 'S', 53, 11, +0, 0, 216, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 215, 1, +0, 0, 30, 0, +0, 0, 61, 2, +0, 0, 86, 0, +'A', 'E', 79, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'U', 84, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'Q', 'U', 118, 11, +0, 0, 111, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 121, 0, +'S', 'S', 105, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 57, 1, +'T', 'T', 106, 11, +'E', 'E', 107, 11, +'R', 'R', 108, 11, +'_', '_', 109, 11, +'L', 'S', 110, 11, +0, 0, 16, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 18, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 24, 1, +0, 0, 221, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 232, 1, +0, 0, 201, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 20, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 133, 1, +0, 0, 213, 1, +0, 0, 61, 2, +0, 0, 13, 2, +'O', 'U', 154, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 207, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'A', 'A', 161, 11, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 209, 1, +0, 0, 87, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 99, 0, +'S', 'S', 162, 11, +'T', 'T', 163, 11, +'E', 'E', 164, 11, +'R', 'R', 165, 11, +'_', '_', 166, 11, +'S', 'S', 167, 11, +'S', 'S', 168, 11, +'L', 'L', 169, 11, +'_', '_', 170, 11, +'C', 'C', 171, 11, +'A', 'I', 172, 11, +0, 0, 23, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 25, 1, +0, 0, 85, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 187, 0, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 49, 1, +0, 0, 76, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 177, 1, +'A', 'A', 199, 11, +'S', 'X', 200, 11, +0, 0, 14, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'_', '_', 206, 11, +'Q', 'U', 207, 11, +0, 0, 32, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 61, 2, +'P', 'S', 212, 11, +0, 0, 35, 1, +0, 0, 61, 2, +0, 0, 61, 2, +0, 0, 36, 1, +}; + +static unsigned int sql_functions_max_len=29; + +static unsigned int symbols_max_len=29; + +static SYMBOL *get_hash_symbol(const char *s, + unsigned int len,bool function) +{ + register uchar *hash_map; + register const char *cur_str= s; + + if (len == 0) { + DBUG_PRINT("warning", ("get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.")); return(NULL); + } + if (function){ + if (len>sql_functions_max_len) return 0; + hash_map= sql_functions_map; + register uint32 cur_struct= uint4korr(hash_map+((len-1)*4)); + + for (;;){ + register uchar first_char= (uchar)cur_struct; + + if (first_char == 0) + { + register int16 ires= (int16)(cur_struct>>16); + if (ires==array_elements(symbols)) return 0; + register SYMBOL *res; + if (ires>=0) + res= symbols+ires; + else + res= sql_functions-ires-1; + register uint count= (uint) (cur_str - s); + return lex_casecmp(cur_str,res->name+count,len-count) ? 0 : res; + } + + register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str]; + if (cur_char>=8; + if (cur_char>(uchar)cur_struct) return 0; + + cur_struct>>=8; + cur_struct= uint4korr(hash_map+ + (((uint16)cur_struct + cur_char - first_char)*4)); + cur_str++; + } + }else{ + if (len>symbols_max_len) return 0; + hash_map= symbols_map; + register uint32 cur_struct= uint4korr(hash_map+((len-1)*4)); + + for (;;){ + register uchar first_char= (uchar)cur_struct; + + if (first_char==0){ + register int16 ires= (int16)(cur_struct>>16); + if (ires==array_elements(symbols)) return 0; + register SYMBOL *res= symbols+ires; + register uint count= (uint) (cur_str - s); + return lex_casecmp(cur_str,res->name+count,len-count)!=0 ? 0 : res; + } + + register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str]; + if (cur_char>=8; + if (cur_char>(uchar)cur_struct) return 0; + + cur_struct>>=8; + cur_struct= uint4korr(hash_map+ + (((uint16)cur_struct + cur_char - first_char)*4)); + cur_str++; + } + } +} diff --git a/sql/lock.cc b/sql/lock.cc index 7937878073e..758ea6cf914 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -73,8 +73,13 @@ we are forced to use mysql_lock_merge. */ -#include "mysql_priv.h" +#include "sql_priv.h" #include "debug_sync.h" +#include "unireg.h" // REQUIRED: for other includes +#include "lock.h" +#include "sql_base.h" // close_tables_for_reopen +#include "sql_parse.h" // is_log_table_write_query +#include "sql_acl.h" // SUPER_ACL #include #include diff --git a/sql/lock.h b/sql/lock.h new file mode 100644 index 00000000000..803bac960b3 --- /dev/null +++ b/sql/lock.h @@ -0,0 +1,104 @@ +#ifndef LOCK_INCLUDED +#define LOCK_INCLUDED + +#include "thr_lock.h" /* thr_lock_type */ + +// Forward declarations +class TABLE; +class TABLE_LIST; +class THD; +typedef struct st_mysql_lock MYSQL_LOCK; + +/* mysql_lock_tables() and open_table() flags bits */ +#define MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK 0x0001 +#define MYSQL_OPEN_IGNORE_FLUSH 0x0002 +#define MYSQL_OPEN_TEMPORARY_ONLY 0x0004 +#define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0008 +#define MYSQL_LOCK_LOG_TABLE 0x0010 +#define MYSQL_OPEN_TAKE_UPGRADABLE_MDL 0x0020 +/** + Do not try to acquire a metadata lock on the table: we + already have one. +*/ +#define MYSQL_OPEN_HAS_MDL_LOCK 0x0040 +/** + If in locked tables mode, ignore the locked tables and get + a new instance of the table. +*/ +#define MYSQL_OPEN_GET_NEW_TABLE 0x0080 +/** Don't look up the table in the list of temporary tables. */ +#define MYSQL_OPEN_SKIP_TEMPORARY 0x0100 +/** Fail instead of waiting when conficting metadata lock is discovered. */ +#define MYSQL_OPEN_FAIL_ON_MDL_CONFLICT 0x0200 +/** Open tables using MDL_SHARED lock instead of one specified in parser. */ +#define MYSQL_OPEN_FORCE_SHARED_MDL 0x0400 +/** + Open tables using MDL_SHARED_HIGH_PRIO lock instead of one specified + in parser. +*/ +#define MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL 0x0800 +/** + When opening or locking the table, use the maximum timeout + (LONG_TIMEOUT = 1 year) rather than the user-supplied timeout value. +*/ +#define MYSQL_LOCK_IGNORE_TIMEOUT 0x1000 + +/** Please refer to the internals manual. */ +#define MYSQL_OPEN_REOPEN (MYSQL_OPEN_IGNORE_FLUSH |\ + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |\ + MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |\ + MYSQL_LOCK_IGNORE_TIMEOUT |\ + MYSQL_OPEN_GET_NEW_TABLE |\ + MYSQL_OPEN_SKIP_TEMPORARY |\ + MYSQL_OPEN_HAS_MDL_LOCK) + + +#include "thr_lock.h" /* thr_lock_type */ + +class TABLE_LIST; +class THD; +struct TABLE; +typedef struct st_mysql_lock MYSQL_LOCK; + +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags); +void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); +void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); +void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count); +void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table); +void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock); +void mysql_lock_downgrade_write(THD *thd, TABLE *table, + thr_lock_type new_lock_type); +bool mysql_lock_abort_for_thread(THD *thd, TABLE *table); +MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b); +TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle, + TABLE_LIST *haystack); +bool lock_global_read_lock(THD *thd); +void unlock_global_read_lock(THD *thd); +bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, + bool is_not_commit); +void start_waiting_global_read_lock(THD *thd); +bool make_global_read_lock_block_commit(THD *thd); +bool set_protect_against_global_read_lock(void); +void unset_protect_against_global_read_lock(void); +/* Lock based on stored routine name */ +bool lock_routine_name(THD *thd, bool is_function, const char *db, + const char *name); +void broadcast_refresh(void); + +/* Lock based on name */ +int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list); +int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use); +void unlock_table_name(THD *thd, TABLE_LIST *table_list); +bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list); +bool lock_table_names(THD *thd, TABLE_LIST *table_list); +void unlock_table_names(THD *thd); +bool lock_table_names_exclusively(THD *thd, TABLE_LIST *table_list); +bool is_table_name_exclusively_locked_by_this_thread(THD *thd, + TABLE_LIST *table_list); +bool is_table_name_exclusively_locked_by_this_thread(THD *thd, uchar *key, + int key_length); +void broadcast_refresh(void); + + + +#endif /* LOCK_INCLUDED */ diff --git a/sql/log.cc b/sql/log.cc index 225fc51ffc6..a3b9a8f835f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -24,8 +24,16 @@ Abort logging when we get an error in reading or writing log files */ -#include "mysql_priv.h" +#include "sql_priv.h" +#include "log.h" +#include "sql_base.h" // close_thread_tables #include "sql_repl.h" +#include "sql_delete.h" // mysql_truncate +#include "sql_parse.h" // command_name +#include "sql_time.h" // calc_time_from_sec, my_time_compare +#include "tztime.h" // my_tz_OFFSET0, struct Time_zone +#include "sql_acl.h" // SUPER_ACL +#include "log_event.h" // Query_log_event #include "rpl_filter.h" #include "rpl_rli.h" #include "sql_audit.h" @@ -38,7 +46,7 @@ #include "message.h" #endif -#include +#include "sql_plugin.h" #include "rpl_handler.h" /* max size of the log message */ diff --git a/sql/log.h b/sql/log.h index e9429067a34..71c27f50f78 100644 --- a/sql/log.h +++ b/sql/log.h @@ -16,6 +16,9 @@ #ifndef LOG_H #define LOG_H +#include "unireg.h" // REQUIRED: for other includes +#include "handler.h" /* my_xid */ + class Relay_log_info; class Format_description_log_event; @@ -644,4 +647,36 @@ extern TYPELIB binlog_format_typelib; int query_error_code(THD *thd, bool not_killed); uint purge_log_get_error_code(int res); +int vprint_msg_to_log(enum loglevel level, const char *format, va_list args); +void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void sql_print_information(const char *format, ...) + ATTRIBUTE_FORMAT(printf, 1, 2); +typedef void (*sql_print_message_func)(const char *format, ...) + ATTRIBUTE_FORMAT(printf, 1, 2); +extern sql_print_message_func sql_print_message_handlers[]; + +int error_log_print(enum loglevel level, const char *format, + va_list args); + +bool slow_log_print(THD *thd, const char *query, uint query_length, + ulonglong current_utime); + +bool general_log_print(THD *thd, enum enum_server_command command, + const char *format,...); + +bool general_log_write(THD *thd, enum enum_server_command command, + const char *query, uint query_length); + +void sql_perror(const char *message); +bool flush_error_log(); + +File open_binlog(IO_CACHE *log, const char *log_file_name, + const char **errmsg); + +char *make_log_name(char *buff, const char *name, const char* log_ext); + +extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; +extern LOGGER logger; + #endif /* LOG_H */ diff --git a/sql/log_event.cc b/sql/log_event.cc index fe86e78f7e3..a1f8a791c49 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -16,7 +16,7 @@ #ifdef MYSQL_CLIENT -#include "mysql_priv.h" +#include "sql_priv.h" #else @@ -24,7 +24,19 @@ #pragma implementation // gcc: Class implementation #endif -#include "mysql_priv.h" +#include "sql_priv.h" +#include "unireg.h" +#include "my_global.h" // REQUIRED by log_event.h > m_string.h > my_bitmap.h +#include "log_event.h" +#include "sql_base.h" // close_thread_tables +#include "sql_cache.h" // QUERY_CACHE_FLAGS_SIZE +#include "sql_locale.h" // MY_LOCALE, my_locale_by_number, my_locale_en_US +#include "key.h" // key_copy +#include "lock.h" // mysql_unlock_tables +#include "sql_parse.h" // mysql_test_parse_for_slave +#include "tztime.h" // struct Time_zone +#include "sql_load.h" // mysql_load +#include "sql_db.h" // load_db_opt_by_name #include "slave.h" #include "rpl_rli.h" #include "rpl_mi.h" diff --git a/sql/log_event.h b/sql/log_event.h index 81669e24708..36397c427e5 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -28,7 +28,7 @@ #ifndef _log_event_h #define _log_event_h -#if defined(USE_PRAGMA_INTERFACE) && !defined(MYSQL_CLIENT) +#if defined(USE_PRAGMA_INTERFACE) && defined(MYSQL_SERVER) #pragma interface /* gcc class implementation */ #endif @@ -36,17 +36,22 @@ #include "rpl_constants.h" #ifdef MYSQL_CLIENT +#include "sql_const.h" #include "rpl_utility.h" #include "hash.h" #include "rpl_tblmap.h" #include "rpl_tblmap.cc" #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER #include "rpl_record.h" #include "rpl_reporting.h" +#include "sql_class.h" /* THD */ #endif +/* Forward declarations */ +class String; + #define PREFIX_SQL_LOAD "SQL_LOAD-" /** @@ -607,7 +612,7 @@ enum Int_event_type }; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER class String; class MYSQL_BIN_LOG; class THD; @@ -685,11 +690,9 @@ typedef struct st_print_event_info uint8 common_header_len; char delimiter[16]; -#ifdef MYSQL_CLIENT uint verbose; table_mapping m_table_map; table_mapping m_table_map_ignored; -#endif /* These two caches are used by the row-based replication events to @@ -963,7 +966,7 @@ public: */ ulong slave_exec_mode; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER THD* thd; Log_event(); @@ -1035,7 +1038,7 @@ public: static void *operator new(size_t, void* ptr) { return ptr; } static void operator delete(void*, void*) { } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write_header(IO_CACHE* file, ulong data_length); virtual bool write(IO_CACHE* file) { @@ -1109,7 +1112,7 @@ public: /* Return start of query time or current time */ -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) public: /** @@ -1413,7 +1416,7 @@ protected: Q_SQL_MODE_CODE == 1 8 byte bitfield The @c sql_mode variable. See the section "SQL Modes" in the - MySQL manual, and see mysql_priv.h for a list of the possible + MySQL manual, and see sql_priv.h for a list of the possible flags. Currently (2007-10-04), the following flags are available:
     MODE_REAL_AS_FLOAT==0x1
@@ -1697,7 +1700,7 @@ public:
   */
   uint32 master_data_written;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
 
   Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
                   bool using_trans, bool direct, bool suppress_use, int error);
@@ -1720,7 +1723,7 @@ public:
       my_free((uchar*) data_buf, MYF(0));
   }
   Log_event_type get_type_code() { return QUERY_EVENT; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
   virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
 #endif
@@ -1734,7 +1737,7 @@ public:
   /* Writes derived event-specific part of post header. */
 
 public:        /* !!! Public in this patch to allow old usage */
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
@@ -1809,7 +1812,7 @@ public:
   int master_log_len;
   uint16 master_port;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Slave_log_event(THD* thd_arg, Relay_log_info* rli);
   void pack_info(Protocol* protocol);
 #else
@@ -1821,12 +1824,12 @@ public:
   int get_data_size();
   bool is_valid() const { return master_host != 0; }
   Log_event_type get_type_code() { return SLAVE_EVENT; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const* rli);
 #endif
 };
@@ -2080,7 +2083,7 @@ public:
     return local_fname;
   }
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   String field_lens_buf;
   String fields_buf;
 
@@ -2113,7 +2116,7 @@ public:
   {
     return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
   }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write_data_header(IO_CACHE* file);
   bool write_data_body(IO_CACHE* file);
 #endif
@@ -2126,7 +2129,7 @@ public:
   }
 
 public:        /* !!! Public in this patch to allow old usage */
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const* rli)
   {
     return do_apply_event(thd->slave_net,rli,0);
@@ -2188,7 +2191,7 @@ public:
   */
   bool dont_set_created;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Start_log_event_v3();
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
@@ -2202,7 +2205,7 @@ public:
                      const Format_description_log_event* description_event);
   ~Start_log_event_v3() {}
   Log_event_type get_type_code() { return START_EVENT_V3;}
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
   bool is_valid() const { return 1; }
@@ -2212,7 +2215,7 @@ public:
   }
 
 protected:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info*)
   {
@@ -2264,7 +2267,7 @@ public:
     my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
   }
   Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
   bool is_valid() const
@@ -2286,7 +2289,7 @@ public:
   void calc_server_version_split();
 
 protected:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
@@ -2338,7 +2341,7 @@ public:
   ulonglong val;
   uchar type;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
     :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
   {}
@@ -2355,13 +2358,13 @@ public:
   Log_event_type get_type_code() { return INTVAR_EVENT;}
   const char* get_var_type_name();
   int get_data_size() { return  9; /* sizeof(type) + sizeof(val) */;}
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
   bool is_valid() const { return 1; }
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
@@ -2414,7 +2417,7 @@ class Rand_log_event: public Log_event
   ulonglong seed1;
   ulonglong seed2;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
     :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
   {}
@@ -2430,13 +2433,13 @@ class Rand_log_event: public Log_event
   ~Rand_log_event() {}
   Log_event_type get_type_code() { return RAND_EVENT;}
   int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
   bool is_valid() const { return 1; }
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
@@ -2460,7 +2463,7 @@ class Xid_log_event: public Log_event
  public:
    my_xid xid;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
@@ -2474,13 +2477,13 @@ class Xid_log_event: public Log_event
   ~Xid_log_event() {}
   Log_event_type get_type_code() { return XID_EVENT;}
   int get_data_size() { return sizeof(xid); }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
   bool is_valid() const { return 1; }
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   enum_skip_reason do_shall_skip(Relay_log_info *rli);
 #endif
@@ -2510,7 +2513,7 @@ public:
   uint charset_number;
   bool is_null;
   uchar flags;
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
                      char *val_arg, ulong val_len_arg, Item_result type_arg,
 		     uint charset_number_arg, uchar flags_arg)
@@ -2527,13 +2530,13 @@ public:
                      const Format_description_log_event *description_event);
   ~User_var_log_event() {}
   Log_event_type get_type_code() { return USER_VAR_EVENT;}
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
   bool is_valid() const { return 1; }
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
@@ -2552,7 +2555,7 @@ private:
 class Stop_log_event: public Log_event
 {
 public:
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Stop_log_event() :Log_event()
   {}
 #else
@@ -2568,7 +2571,7 @@ public:
   bool is_valid() const { return 1; }
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli)
   {
@@ -2644,7 +2647,7 @@ public:
   ulonglong pos;
   uint ident_len;
   uint flags;
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Rotate_log_event(const char* new_log_ident_arg,
 		   uint ident_len_arg,
 		   ulonglong pos_arg, uint flags);
@@ -2665,12 +2668,12 @@ public:
   Log_event_type get_type_code() { return ROTATE_EVENT;}
   int get_data_size() { return  ident_len + ROTATE_HEADER_LEN;}
   bool is_valid() const { return new_log_ident != 0; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 #endif
@@ -2701,7 +2704,7 @@ public:
   uint file_id;
   bool inited_from_old;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
 			const char* table_name_arg,
 			List& fields_arg,
@@ -2735,7 +2738,7 @@ public:
 	    4 + 1 + block_len);
   }
   bool is_valid() const { return inited_from_old || block != 0; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write_data_header(IO_CACHE* file);
   bool write_data_body(IO_CACHE* file);
   /*
@@ -2746,7 +2749,7 @@ public:
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
 #endif
 };
@@ -2777,7 +2780,7 @@ public:
   */
   const char* db;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
 			 uint block_len_arg, bool using_trans);
 #ifdef HAVE_REPLICATION
@@ -2795,13 +2798,13 @@ public:
   Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
   int get_data_size() { return  block_len + APPEND_BLOCK_HEADER_LEN ;}
   bool is_valid() const { return block != 0; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
   const char* get_db() { return db; }
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
 #endif
 };
@@ -2819,7 +2822,7 @@ public:
   uint file_id;
   const char* db; /* see comment in Append_block_log_event */
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
@@ -2836,13 +2839,13 @@ public:
   Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
   int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
   bool is_valid() const { return file_id != 0; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
   const char* get_db() { return db; }
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
 #endif
 };
@@ -2860,7 +2863,7 @@ public:
   uint file_id;
   const char* db; /* see comment in Append_block_log_event */
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
@@ -2876,13 +2879,13 @@ public:
   Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
   int get_data_size() { return  EXEC_LOAD_HEADER_LEN ;}
   bool is_valid() const { return file_id != 0; }
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
   const char* get_db() { return db; }
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
 #endif
 };
@@ -2900,7 +2903,7 @@ private:
 class Begin_load_query_log_event: public Append_block_log_event
 {
 public:
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
                              uchar* block_arg, uint block_len_arg,
                              bool using_trans);
@@ -2915,7 +2918,7 @@ public:
   ~Begin_load_query_log_event() {}
   Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 #endif
 };
@@ -2951,7 +2954,7 @@ public:
   */
   enum_load_dup_handling dup_handling;
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Execute_load_query_log_event(THD* thd, const char* query_arg,
                                ulong query_length, uint fn_pos_start_arg,
                                uint fn_pos_end_arg,
@@ -2976,12 +2979,12 @@ public:
   bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
 
   ulong get_post_header_size_for_derived();
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   bool write_post_header_for_derived(IO_CACHE* file);
 #endif
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
 #endif
 };
@@ -3371,7 +3374,7 @@ public:
 
   flag_set get_flags(flag_set flag) const { return m_flags & flag; }
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, bool is_transactional);
 #endif
 #ifdef HAVE_REPLICATION
@@ -3396,14 +3399,14 @@ public:
   virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
 
   virtual int get_data_size() { return (uint) m_data_size; } 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   virtual int save_field_metadata();
   virtual bool write_data_header(IO_CACHE *file);
   virtual bool write_data_body(IO_CACHE *file);
   virtual const char *get_db() { return m_dbnam; }
 #endif
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual void pack_info(Protocol *protocol);
 #endif
 
@@ -3413,13 +3416,13 @@ public:
 
 
 private:
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 #endif
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   TABLE         *m_table;
 #endif
   char const    *m_dbnam;
@@ -3515,7 +3518,7 @@ public:
   void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
   flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual void pack_info(Protocol *protocol);
 #endif
 
@@ -3530,7 +3533,7 @@ public:
                                const uchar *ptr, const uchar *prefix);
 #endif
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   int add_row_data(uchar *data, size_t length)
   {
     return do_add_row_data(data,length); 
@@ -3544,7 +3547,7 @@ public:
   size_t get_width() const          { return m_width; }
   ulong get_table_id() const        { return m_table_id; }
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   virtual bool write_data_header(IO_CACHE *file);
   virtual bool write_data_body(IO_CACHE *file);
   virtual const char *get_db() { return m_table->s->db.str; }
@@ -3567,7 +3570,7 @@ protected:
      The constructors are protected since you're supposed to inherit
      this class, not create instances of this class.
   */
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Rows_log_event(THD*, TABLE*, ulong table_id, 
 		 MY_BITMAP const *cols, bool is_transactional);
 #endif
@@ -3579,11 +3582,11 @@ protected:
   void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name);
 #endif
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   virtual int do_add_row_data(uchar *data, size_t length);
 #endif
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   TABLE *m_table;		/* The table the rows belong to */
 #endif
   ulong       m_table_id;	/* Table ID */
@@ -3612,7 +3615,7 @@ protected:
 
   /* helper functions */
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   const uchar *m_curr_row;     /* Start of the row being processed */
   const uchar *m_curr_row_end; /* One-after the end of the current row */
   uchar    *m_key;      /* Buffer to keep key value during searches */
@@ -3640,7 +3643,7 @@ protected:
 
 private:
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
   virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
@@ -3695,7 +3698,7 @@ private:
       
   */
   virtual int do_exec_row(const Relay_log_info *const rli) = 0;
-#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
+#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */
 
   friend class Old_rows_log_event;
 };
@@ -3718,7 +3721,7 @@ public:
     TYPE_CODE = WRITE_ROWS_EVENT
   };
 
-#if !defined(MYSQL_CLIENT)
+#if defined(MYSQL_SERVER)
   Write_rows_log_event(THD*, TABLE*, ulong table_id, 
 		       MY_BITMAP const *cols, bool is_transactional);
 #endif
@@ -3726,7 +3729,7 @@ public:
   Write_rows_log_event(const char *buf, uint event_len, 
                        const Format_description_log_event *description_event);
 #endif
-#if !defined(MYSQL_CLIENT) 
+#if defined(MYSQL_SERVER) 
   static bool binlog_row_logging_function(THD *thd, TABLE *table,
                                           bool is_transactional,
                                           MY_BITMAP *cols,
@@ -3747,7 +3750,7 @@ private:
   void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 #endif
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_before_row_operations(const Slave_reporting_capability *const);
   virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
   virtual int do_exec_row(const Relay_log_info *const);
@@ -3776,7 +3779,7 @@ public:
     TYPE_CODE = UPDATE_ROWS_EVENT
   };
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Update_rows_log_event(THD*, TABLE*, ulong table_id,
 			MY_BITMAP const *cols_bi,
 			MY_BITMAP const *cols_ai,
@@ -3796,7 +3799,7 @@ public:
 			const Format_description_log_event *description_event);
 #endif
 
-#if !defined(MYSQL_CLIENT) 
+#ifdef MYSQL_SERVER
   static bool binlog_row_logging_function(THD *thd, TABLE *table,
                                           bool is_transactional,
                                           MY_BITMAP *cols,
@@ -3821,11 +3824,11 @@ protected:
   void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 #endif
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_before_row_operations(const Slave_reporting_capability *const);
   virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
   virtual int do_exec_row(const Relay_log_info *const);
-#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
+#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */
 };
 
 /**
@@ -3857,7 +3860,7 @@ public:
     TYPE_CODE = DELETE_ROWS_EVENT
   };
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Delete_rows_log_event(THD*, TABLE*, ulong, 
 			MY_BITMAP const *cols, bool is_transactional);
 #endif
@@ -3865,7 +3868,7 @@ public:
   Delete_rows_log_event(const char *buf, uint event_len, 
 			const Format_description_log_event *description_event);
 #endif
-#if !defined(MYSQL_CLIENT) 
+#ifdef MYSQL_SERVER
   static bool binlog_row_logging_function(THD *thd, TABLE *table,
                                           bool is_transactional,
                                           MY_BITMAP *cols,
@@ -3886,7 +3889,7 @@ protected:
   void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 #endif
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_before_row_operations(const Slave_reporting_capability *const);
   virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
   virtual int do_exec_row(const Relay_log_info *const);
@@ -3934,7 +3937,7 @@ protected:
 */
 class Incident_log_event : public Log_event {
 public:
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   Incident_log_event(THD *thd_arg, Incident incident)
     : Log_event(thd_arg, 0, FALSE), m_incident(incident)
   {
@@ -3957,7 +3960,7 @@ public:
   }
 #endif
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
   void pack_info(Protocol*);
 #endif
 
@@ -3970,7 +3973,7 @@ public:
   virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 #endif
 
-#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
 #endif
 
@@ -4002,7 +4005,7 @@ static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
     reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
 }
 
-#ifndef MYSQL_CLIENT
+#ifdef MYSQL_SERVER
 /*****************************************************************************
 
   Heartbeat Log Event class
@@ -4038,6 +4041,9 @@ private:
 };
 #endif
 
+int append_query_string(CHARSET_INFO *csinfo,
+                        String const *from, String *to);
+
 /**
   @} (end of group Replication)
 */
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index c55aaa2b0fb..a80e8f4b1a2 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1,6 +1,16 @@
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #ifndef MYSQL_CLIENT
+#include "unireg.h"
+#endif
+#include "my_global.h" // REQUIRED by log_event.h > m_string.h > my_bitmap.h
+#include "log_event.h"
+#ifndef MYSQL_CLIENT
+#include "sql_cache.h"                       // QUERY_CACHE_FLAGS_SIZE
+#include "sql_base.h"                       // close_tables_for_reopen
+#include "key.h"                            // key_copy
+#include "lock.h"                           // mysql_unlock_tables
+#include "sql_parse.h"             // mysql_reset_thd_for_next_command
 #include "rpl_rli.h"
 #include "rpl_utility.h"
 #endif
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index 8c2d16c40b0..d20d93ff0b9 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -32,7 +32,8 @@
   flush_io_cache().  
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_class.h"                          // THD
 #ifdef HAVE_REPLICATION
 
 extern "C" {
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 234a0a98782..68f9b582dd2 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -13,9 +13,12 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include 
 
+#ifndef MYSQL_CLIENT
+#include "sql_class.h"                          // THD
+#endif
 
 #ifndef MYSQL_CLIENT
 /**
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index 21669e82c44..abf4b178422 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -28,10 +28,17 @@
 #ifndef my_decimal_h
 #define my_decimal_h
 
+#if defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY)
+#include "sql_string.h"                         /* String */
+#endif
+
 C_MODE_START
 #include 
 C_MODE_END
 
+class String;
+typedef struct st_mysql_time MYSQL_TIME;
+
 #define DECIMAL_LONGLONG_DIGITS 22
 #define DECIMAL_LONG_DIGITS 10
 #define DECIMAL_LONG3_DIGITS 8
@@ -133,6 +140,12 @@ const char *dbug_decimal_as_string(char *buff, const my_decimal *val);
 #define dbug_decimal_as_string(A) NULL
 #endif
 
+bool str_set_decimal(uint mask, const my_decimal *val, uint fixed_prec,
+                     uint fixed_dec, char filler, String *str,
+                     CHARSET_INFO *cs);
+
+extern my_decimal decimal_zero;
+
 #ifndef MYSQL_CLIENT
 int decimal_operation_results(int result);
 #else
@@ -289,7 +302,14 @@ int my_decimal_ceiling(uint mask, const my_decimal *from, my_decimal *to)
 }
 
 
+inline bool str_set_decimal(const my_decimal *val, String *str,
+                            CHARSET_INFO *cs)
+{
+  return str_set_decimal(E_DEC_FATAL_ERROR, val, 0, 0, 0, str, cs);
+}
+
 #ifndef MYSQL_CLIENT
+class String;
 int my_decimal2string(uint mask, const my_decimal *d, uint fixed_prec,
 		      uint fixed_dec, char filler, String *str);
 #endif
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
deleted file mode 100644
index 6b77c95c76f..00000000000
--- a/sql/mysql_priv.h
+++ /dev/null
@@ -1,2750 +0,0 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; version 2 of the License.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/**
-  @file
-
-  @details
-  Mostly this file is used in the server. But a little part of it is used in
-  mysqlbinlog too (definition of SELECT_DISTINCT and others).
-  The consequence is that 90% of the file is wrapped in \#ifndef MYSQL_CLIENT,
-  except the part which must be in the server and in the client.
-*/
-
-#ifndef MYSQL_PRIV_H
-#define MYSQL_PRIV_H
-
-#ifndef MYSQL_CLIENT
-
-/*
-  the following #define adds server-only members to enum_mysql_show_type,
-  that is defined in mysql/plugin.h
-  it has to be before mysql/plugin.h is included.
-*/
-#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
-            SHOW_KEY_CACHE_LONGLONG, SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
-            SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
-            SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS, SHOW_LEX_STRING
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 			/* Needed by field.h */
-#include 
-#include "sql_bitmap.h"
-#include "sql_array.h"
-#include "sql_plugin.h"
-#include "scheduler.h"
-#include 
-#include 
-#ifndef __WIN__
-#include 
-#endif
-
-class Parser_state;
-
-/**
-  Query type constants.
-
-  QT_ORDINARY -- ordinary SQL query.
-  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
-  character set introducers).
-*/
-enum enum_query_type
-{
-  QT_ORDINARY,
-  QT_IS
-};
-
-/* TODO convert all these three maps to Bitmap classes */
-typedef ulonglong table_map;          /* Used for table bits in join */
-#if MAX_INDEXES <= 64
-typedef Bitmap<64>  key_map;          /* Used for finding keys */
-#else
-typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
-#endif
-typedef ulong nesting_map;  /* Used for flags of nesting constructs */
-/*
-  Used to identify NESTED_JOIN structures within a join (applicable only to
-  structures that have not been simplified away and embed more the one
-  element)
-*/
-typedef ulonglong nested_join_map;
-
-/* query_id */
-typedef int64 query_id_t;
-extern query_id_t global_query_id;
-extern int32 thread_running;
-extern my_atomic_rwlock_t global_query_id_lock;
-extern my_atomic_rwlock_t thread_running_lock;
-
-/* increment query_id and return it.  */
-inline query_id_t next_query_id()
-{
-  query_id_t id;
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
-  id= my_atomic_add64(&global_query_id, 1);
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
-  return (id+1);
-}
-
-inline query_id_t get_query_id()
-{
-  query_id_t id;
-  my_atomic_rwlock_wrlock(&global_query_id_lock);
-  id= my_atomic_load64(&global_query_id);
-  my_atomic_rwlock_wrunlock(&global_query_id_lock);
-  return id;
-}
-
-inline int32
-inc_thread_running()
-{
-  int32 num_thread_running;
-  my_atomic_rwlock_wrlock(&thread_running_lock);
-  num_thread_running= my_atomic_add32(&thread_running, 1);
-  my_atomic_rwlock_wrunlock(&thread_running_lock);
-  return (num_thread_running+1);
-}
-
-inline int32
-dec_thread_running()
-{
-  int32 num_thread_running;
-  my_atomic_rwlock_wrlock(&thread_running_lock);
-  num_thread_running= my_atomic_add32(&thread_running, -1);
-  my_atomic_rwlock_wrunlock(&thread_running_lock);
-  return (num_thread_running-1);
-}
-
-inline int32
-get_thread_running()
-{
-  int32 num_thread_running;
-  my_atomic_rwlock_wrlock(&thread_running_lock);
-  num_thread_running= my_atomic_load32(&thread_running);
-  my_atomic_rwlock_wrunlock(&thread_running_lock);
-  return num_thread_running;
-}
-
-/* useful constants */
-extern MYSQL_PLUGIN_IMPORT const key_map key_map_empty;
-extern MYSQL_PLUGIN_IMPORT key_map key_map_full;          /* Should be threaded as const */
-extern MYSQL_PLUGIN_IMPORT const char *primary_key_name;
-
-#include "mysql_com.h"
-#include 
-#include "unireg.h"
-
-void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size);
-void *sql_alloc(size_t);
-void *sql_calloc(size_t);
-char *sql_strdup(const char *str);
-char *sql_strmake(const char *str, size_t len);
-void *sql_memdup(const void * ptr, size_t size);
-void sql_element_free(void *ptr);
-char *sql_strmake_with_convert(const char *str, size_t arg_length,
-			       CHARSET_INFO *from_cs,
-			       size_t max_res_length,
-			       CHARSET_INFO *to_cs, size_t *result_length);
-uint kill_one_thread(THD *thd, ulong id, bool only_kill_query);
-void sql_kill(THD *thd, ulong id, bool only_kill_query);
-bool net_request_file(NET* net, const char* fname);
-char* query_table_status(THD *thd,const char *db,const char *table_name);
-
-#define x_free(A)	{ my_free((uchar*) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); }
-#define safeFree(x)	{ if(x) { my_free((uchar*) x,MYF(0)); x = NULL; } }
-#define PREV_BITS(type,A)	((type) (((type) 1 << (A)) -1))
-#define all_bits_set(A,B) ((A) & (B) != (B))
-
-/*
-  Generates a warning that a feature is deprecated. After a specified
-  version asserts that the feature is removed.
-
-  Using it as
-
-  WARN_DEPRECATED(thd, 6,2, "BAD", "'GOOD'");
-
-  Will result in a warning
- 
-  "The syntax 'BAD' is deprecated and will be removed in MySQL 6.2. Please
-   use 'GOOD' instead"
-
-   Note that in macro arguments BAD is not quoted, while 'GOOD' is.
-   Note that the version is TWO numbers, separated with a comma
-   (two macro arguments, that is)
-*/
-#define WARN_DEPRECATED(Thd,VerHi,VerLo,Old,New)                            \
-  do {                                                                      \
-    compile_time_assert(MYSQL_VERSION_ID < VerHi * 10000 + VerLo * 100);    \
-    if (((THD *) Thd) != NULL)                                              \
-      push_warning_printf(((THD *) Thd), MYSQL_ERROR::WARN_LEVEL_WARN,      \
-                        ER_WARN_DEPRECATED_SYNTAX,                          \
-                        ER(ER_WARN_DEPRECATED_SYNTAX),                      \
-                        (Old), (New));                                      \
-    else                                                                    \
-      sql_print_warning("The syntax '%s' is deprecated and will be removed " \
-                        "in a future release. Please use %s instead.",      \
-                        (Old), (New));                                      \
-  } while(0)
-
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ;
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info;
-extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset;
-
-/**
-  Character set of the buildin error messages loaded from errmsg.sys.
-*/
-extern CHARSET_INFO *error_message_charset_info;
-
-enum Derivation
-{
-  DERIVATION_IGNORABLE= 6,
-  DERIVATION_NUMERIC= 5,
-  DERIVATION_COERCIBLE= 4,
-  DERIVATION_SYSCONST= 3,
-  DERIVATION_IMPLICIT= 2,
-  DERIVATION_NONE= 1,
-  DERIVATION_EXPLICIT= 0
-};
-
-#define my_charset_numeric      my_charset_latin1
-#define MY_REPERTOIRE_NUMERIC   MY_REPERTOIRE_ASCII
-
-typedef struct my_locale_errmsgs
-{
-  const char *language;
-  const char **errmsgs;
-} MY_LOCALE_ERRMSGS;
-
-extern char err_shared_dir[];
-
-/** @note Keep this a POD-type because we use offsetof() on it */
-typedef struct my_locale_st
-{
-  uint  number;
-  const char *name;
-  const char *description;
-  const bool is_ascii;
-  TYPELIB *month_names;
-  TYPELIB *ab_month_names;
-  TYPELIB *day_names;
-  TYPELIB *ab_day_names;
-  uint max_month_name_length;
-  uint max_day_name_length;
-  uint decimal_point;
-  uint thousand_sep;
-  const char *grouping;
-  MY_LOCALE_ERRMSGS *errmsgs;
-#ifdef __cplusplus 
-  my_locale_st(uint number_par,
-               const char *name_par, const char *descr_par, bool is_ascii_par,
-               TYPELIB *month_names_par, TYPELIB *ab_month_names_par,
-               TYPELIB *day_names_par, TYPELIB *ab_day_names_par,
-               uint max_month_name_length_par, uint max_day_name_length_par,
-               uint decimal_point_par, uint thousand_sep_par,
-               const char *grouping_par, MY_LOCALE_ERRMSGS *errmsgs_par) :
-    number(number_par),
-    name(name_par), description(descr_par), is_ascii(is_ascii_par),
-    month_names(month_names_par), ab_month_names(ab_month_names_par),
-    day_names(day_names_par), ab_day_names(ab_day_names_par),
-    max_month_name_length(max_month_name_length_par),
-    max_day_name_length(max_day_name_length_par),
-    decimal_point(decimal_point_par),
-    thousand_sep(thousand_sep_par),
-    grouping(grouping_par),
-    errmsgs(errmsgs_par)
-  {}
-#endif
-} MY_LOCALE;
-
-extern MY_LOCALE my_locale_en_US;
-extern MY_LOCALE *my_locales[];
-extern MY_LOCALE *my_default_lc_messages;
-extern MY_LOCALE *my_default_lc_time_names;
-
-MY_LOCALE *my_locale_by_name(const char *name);
-MY_LOCALE *my_locale_by_number(uint number);
-
-void cleanup_errmsgs(void);
-
-/*************************************************************************/
-
-/**
- Object_creation_ctx -- interface for creation context of database objects
- (views, stored routines, events, triggers). Creation context -- is a set
- of attributes, that should be fixed at the creation time and then be used
- each time the object is parsed or executed.
-*/
-
-class Object_creation_ctx
-{
-public:
-  Object_creation_ctx *set_n_backup(THD *thd);
-
-  void restore_env(THD *thd, Object_creation_ctx *backup_ctx);
-
-protected:
-  Object_creation_ctx() {}
-  virtual Object_creation_ctx *create_backup_ctx(THD *thd) const = 0;
-
-  virtual void change_env(THD *thd) const = 0;
-
-public:
-  virtual ~Object_creation_ctx()
-  { }
-};
-
-/*************************************************************************/
-
-/**
- Default_object_creation_ctx -- default implementation of
- Object_creation_ctx.
-*/
-
-class Default_object_creation_ctx : public Object_creation_ctx
-{
-public:
-  CHARSET_INFO *get_client_cs()
-  {
-    return m_client_cs;
-  }
-
-  CHARSET_INFO *get_connection_cl()
-  {
-    return m_connection_cl;
-  }
-
-protected:
-  Default_object_creation_ctx(THD *thd);
-
-  Default_object_creation_ctx(CHARSET_INFO *client_cs,
-                              CHARSET_INFO *connection_cl);
-
-protected:
-  virtual Object_creation_ctx *create_backup_ctx(THD *thd) const;
-
-  virtual void change_env(THD *thd) const;
-
-protected:
-  /**
-    client_cs stores the value of character_set_client session variable.
-    The only character set attribute is used.
-
-    Client character set is included into query context, because we save
-    query in the original character set, which is client character set. So,
-    in order to parse the query properly we have to switch client character
-    set on parsing.
-  */
-  CHARSET_INFO *m_client_cs;
-
-  /**
-    connection_cl stores the value of collation_connection session
-    variable. Both character set and collation attributes are used.
-
-    Connection collation is included into query context, becase it defines
-    the character set and collation of text literals in internal
-    representation of query (item-objects).
-  */
-  CHARSET_INFO *m_connection_cl;
-};
-
-/***************************************************************************
-  Configuration parameters
-****************************************************************************/
-
-#define ACL_CACHE_SIZE		256
-#define MAX_PASSWORD_LENGTH	32
-#define HOST_CACHE_SIZE		128
-#define MAX_ACCEPT_RETRY	10	// Test accept this many times
-#define MAX_FIELDS_BEFORE_HASH	32
-#define USER_VARS_HASH_SIZE     16
-#define TABLE_OPEN_CACHE_MIN    400
-#define TABLE_OPEN_CACHE_DEFAULT 400
-#define TABLE_DEF_CACHE_DEFAULT 400
-/**
-  We must have room for at least 400 table definitions in the table
-  cache, since otherwise there is no chance prepared
-  statements that use these many tables can work.
-  Prepared statements use table definition cache ids (table_map_id)
-  as table version identifiers. If the table definition
-  cache size is less than the number of tables used in a statement,
-  the contents of the table definition cache is guaranteed to rotate
-  between a prepare and execute. This leads to stable validation
-  errors. In future we shall use more stable version identifiers,
-  for now the only solution is to ensure that the table definition
-  cache can contain at least all tables of a given statement.
-*/
-#define TABLE_DEF_CACHE_MIN     400
-
-/*
-  Stack reservation.
-  Feel free to raise this by the smallest amount you can to get the
-  "execution_constants" test to pass.
-*/
-#define STACK_MIN_SIZE          16000   // Abort if less stack during eval.
-
-#define STACK_MIN_SIZE_FOR_OPEN 1024*80
-#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
-#ifndef MYSQLD_NET_RETRY_COUNT
-#define MYSQLD_NET_RETRY_COUNT  10	///< Abort read after this many int.
-#endif
-#define TEMP_POOL_SIZE          128
-
-#define QUERY_ALLOC_BLOCK_SIZE		8192
-#define QUERY_ALLOC_PREALLOC_SIZE   	8192
-#define TRANS_ALLOC_BLOCK_SIZE		4096
-#define TRANS_ALLOC_PREALLOC_SIZE	4096
-#define RANGE_ALLOC_BLOCK_SIZE		4096
-#define ACL_ALLOC_BLOCK_SIZE		1024
-#define UDF_ALLOC_BLOCK_SIZE		1024
-#define TABLE_ALLOC_BLOCK_SIZE		1024
-#define BDB_LOG_ALLOC_BLOCK_SIZE	1024
-#define WARN_ALLOC_BLOCK_SIZE		2048
-#define WARN_ALLOC_PREALLOC_SIZE	1024
-#define PROFILE_ALLOC_BLOCK_SIZE  2048
-#define PROFILE_ALLOC_PREALLOC_SIZE 1024
-
-/*
-  The following parameters is to decide when to use an extra cache to
-  optimise seeks when reading a big table in sorted order
-*/
-#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
-#define MIN_ROWS_TO_USE_TABLE_CACHE	 100
-#define MIN_ROWS_TO_USE_BULK_INSERT	 100
-
-/**
-  The following is used to decide if MySQL should use table scanning
-  instead of reading with keys.  The number says how many evaluation of the
-  WHERE clause is comparable to reading one extra row from a table.
-*/
-#define TIME_FOR_COMPARE   5	// 5 compares == one read
-
-/**
-  Number of comparisons of table rowids equivalent to reading one row from a 
-  table.
-*/
-#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
-
-/*
-  For sequential disk seeks the cost formula is:
-    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
-  
-  The cost of average seek 
-    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
-*/
-#define DISK_SEEK_BASE_COST ((double)0.5)
-
-#define BLOCKS_IN_AVG_SEEK  128
-
-#define DISK_SEEK_PROP_COST ((double)0.5/BLOCKS_IN_AVG_SEEK)
-
-
-/**
-  Number of rows in a reference table when refereed through a not unique key.
-  This value is only used when we don't know anything about the key
-  distribution.
-*/
-#define MATCHING_ROWS_IN_OTHER_TABLE 10
-
-/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
-#define KEY_DEFAULT_PACK_LENGTH 8
-
-/** Characters shown for the command in 'show processlist'. */
-#define PROCESS_LIST_WIDTH 100
-/* Characters shown for the command in 'information_schema.processlist' */
-#define PROCESS_LIST_INFO_WIDTH 65535
-
-#define PRECISION_FOR_DOUBLE 53
-#define PRECISION_FOR_FLOAT  24
-
-/* -[digits].E+## */
-#define MAX_FLOAT_STR_LENGTH (FLT_DIG + 6)
-/* -[digits].E+### */
-#define MAX_DOUBLE_STR_LENGTH (DBL_DIG + 7)
-
-/*
-  Default time to wait before aborting a new client connection
-  that does not respond to "initial server greeting" timely
-*/
-#define CONNECT_TIMEOUT		10
-
-/* The following can also be changed from the command line */
-#define DEFAULT_CONCURRENCY	10
-#define DELAYED_LIMIT		100		/**< pause after xxx inserts */
-#define DELAYED_QUEUE_SIZE	1000
-#define DELAYED_WAIT_TIMEOUT	5*60		/**< Wait for delayed insert */
-#define FLUSH_TIME		0		/**< Don't flush tables */
-#define MAX_CONNECT_ERRORS	10		///< errors before disabling host
-
-#if defined(__WIN__)
-#undef	FLUSH_TIME
-#define FLUSH_TIME	1800			/**< Flush every half hour */
-#endif /* __WIN__ */
-
-	/* Bits from testflag */
-#define TEST_PRINT_CACHED_TABLES 1
-#define TEST_NO_KEY_GROUP	 2
-#define TEST_MIT_THREAD		4
-#define TEST_BLOCKING		8
-#define TEST_KEEP_TMP_TABLES	16
-#define TEST_READCHECK		64	/**< Force use of readcheck */
-#define TEST_NO_EXTRA		128
-#define TEST_CORE_ON_SIGNAL	256	/**< Give core if signal */
-#define TEST_NO_STACKTRACE	512
-#define TEST_SIGINT		1024	/**< Allow sigint on threads */
-#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in
-                                           some places */
-#endif
-
-/*
-   This is included in the server and in the client.
-   Options for select set by the yacc parser (stored in lex->options).
-
-   NOTE
-   log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
-   options list are written into binlog. These options can NOT change their
-   values, or it will break replication between version.
-
-   context is encoded as following:
-   SELECT - SELECT_LEX_NODE::options
-   THD    - THD::options
-   intern - neither. used only as
-            func(..., select_node->options | thd->options | OPTION_XXX, ...)
-
-   TODO: separate three contexts above, move them to separate bitfields.
-*/
-
-#define SELECT_DISTINCT         (1ULL << 0)     // SELECT, user
-#define SELECT_STRAIGHT_JOIN    (1ULL << 1)     // SELECT, user
-#define SELECT_DESCRIBE         (1ULL << 2)     // SELECT, user
-#define SELECT_SMALL_RESULT     (1ULL << 3)     // SELECT, user
-#define SELECT_BIG_RESULT       (1ULL << 4)     // SELECT, user
-#define OPTION_FOUND_ROWS       (1ULL << 5)     // SELECT, user
-#define OPTION_TO_QUERY_CACHE   (1ULL << 6)     // SELECT, user
-#define SELECT_NO_JOIN_CACHE    (1ULL << 7)     // intern
-/** always the opposite of OPTION_NOT_AUTOCOMMIT except when in fix_autocommit() */
-#define OPTION_AUTOCOMMIT       (1ULL << 8)    // THD, user
-#define OPTION_BIG_SELECTS      (1ULL << 9)     // THD, user
-#define OPTION_LOG_OFF          (1ULL << 10)    // THD, user
-#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11)   // THD, user, unused
-#define TMP_TABLE_ALL_COLUMNS   (1ULL << 12)    // SELECT, intern
-#define OPTION_WARNINGS         (1ULL << 13)    // THD, user
-#define OPTION_AUTO_IS_NULL     (1ULL << 14)    // THD, user, binlog
-#define OPTION_FOUND_COMMENT    (1ULL << 15)    // SELECT, intern, parser
-#define OPTION_SAFE_UPDATES     (1ULL << 16)    // THD, user
-#define OPTION_BUFFER_RESULT    (1ULL << 17)    // SELECT, user
-#define OPTION_BIN_LOG          (1ULL << 18)    // THD, user
-#define OPTION_NOT_AUTOCOMMIT   (1ULL << 19)    // THD, user
-#define OPTION_BEGIN            (1ULL << 20)    // THD, intern
-#define OPTION_TABLE_LOCK       (1ULL << 21)    // THD, intern
-#define OPTION_QUICK            (1ULL << 22)    // SELECT (for DELETE)
-#define OPTION_KEEP_LOG         (1ULL << 23)    // THD, user
-
-/* The following is used to detect a conflict with DISTINCT */
-#define SELECT_ALL              (1ULL << 24)    // SELECT, user, parser
-/** The following can be set when importing tables in a 'wrong order'
-   to suppress foreign key checks */
-#define OPTION_NO_FOREIGN_KEY_CHECKS    (1ULL << 26) // THD, user, binlog
-/** The following speeds up inserts to InnoDB tables by suppressing unique
-   key checks in some cases */
-#define OPTION_RELAXED_UNIQUE_CHECKS    (1ULL << 27) // THD, user, binlog
-#define SELECT_NO_UNLOCK                (1ULL << 28) // SELECT, intern
-#define OPTION_SCHEMA_TABLE             (1ULL << 29) // SELECT, intern
-/** Flag set if setup_tables already done */
-#define OPTION_SETUP_TABLES_DONE        (1ULL << 30) // intern
-/** If not set then the thread will ignore all warnings with level notes. */
-#define OPTION_SQL_NOTES                (1ULL << 31) // THD, user
-/**
-  Force the used temporary table to be a MyISAM table (because we will use
-  fulltext functions when reading from it.
-*/
-#define TMP_TABLE_FORCE_MYISAM          (1ULL << 32)
-#define OPTION_PROFILING                (1ULL << 33)
-
-
-/**
-  Maximum length of time zone name that we support
-  (Time zone name is char(64) in db). mysqlbinlog needs it.
-*/
-#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
-
-/* The rest of the file is included in the server only */
-#ifndef MYSQL_CLIENT
-
-/* Bits for different SQL modes modes (including ANSI mode) */
-#define MODE_REAL_AS_FLOAT              1
-#define MODE_PIPES_AS_CONCAT            2
-#define MODE_ANSI_QUOTES                4
-#define MODE_IGNORE_SPACE		8
-#define MODE_NOT_USED			16
-#define MODE_ONLY_FULL_GROUP_BY		32
-#define MODE_NO_UNSIGNED_SUBTRACTION	64
-#define MODE_NO_DIR_IN_CREATE		128
-#define MODE_POSTGRESQL			256
-#define MODE_ORACLE			512
-#define MODE_MSSQL			1024
-#define MODE_DB2			2048
-#define MODE_MAXDB			4096
-#define MODE_NO_KEY_OPTIONS             8192
-#define MODE_NO_TABLE_OPTIONS           16384
-#define MODE_NO_FIELD_OPTIONS           32768
-#define MODE_MYSQL323                   65536L
-#define MODE_MYSQL40                    (MODE_MYSQL323*2)
-#define MODE_ANSI	                (MODE_MYSQL40*2)
-#define MODE_NO_AUTO_VALUE_ON_ZERO      (MODE_ANSI*2)
-#define MODE_NO_BACKSLASH_ESCAPES       (MODE_NO_AUTO_VALUE_ON_ZERO*2)
-#define MODE_STRICT_TRANS_TABLES	(MODE_NO_BACKSLASH_ESCAPES*2)
-#define MODE_STRICT_ALL_TABLES		(MODE_STRICT_TRANS_TABLES*2)
-#define MODE_NO_ZERO_IN_DATE		(MODE_STRICT_ALL_TABLES*2)
-#define MODE_NO_ZERO_DATE		(MODE_NO_ZERO_IN_DATE*2)
-#define MODE_INVALID_DATES		(MODE_NO_ZERO_DATE*2)
-#define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
-#define MODE_TRADITIONAL		(MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
-#define MODE_NO_AUTO_CREATE_USER	(MODE_TRADITIONAL*2)
-#define MODE_HIGH_NOT_PRECEDENCE	(MODE_NO_AUTO_CREATE_USER*2)
-#define MODE_NO_ENGINE_SUBSTITUTION     (MODE_HIGH_NOT_PRECEDENCE*2)
-#define MODE_PAD_CHAR_TO_FULL_LENGTH    (ULL(1) << 31)
-
-/* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */
-#define OPTIMIZER_SWITCH_INDEX_MERGE               (1ULL << 0)
-#define OPTIMIZER_SWITCH_INDEX_MERGE_UNION         (1ULL << 1)
-#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION    (1ULL << 2)
-#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT     (1ULL << 3)
-#define OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN (1ULL << 4)
-#define OPTIMIZER_SWITCH_LAST                      (1ULL << 5)
-
-/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
-#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
-                                  OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
-                                  OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
-                                  OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
-                                  OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN)
-
-
-/*
-  Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
-  use strictly more than 64 bits by adding one more define above, you should
-  contact the replication team because the replication code should then be
-  updated (to store more bytes on disk).
-
-  NOTE: When adding new SQL_MODE types, make sure to also add them to
-  the scripts used for creating the MySQL system tables
-  in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
-
-*/
-
-#define RAID_BLOCK_SIZE 1024
-
-#define MY_CHARSET_BIN_MB_MAXLEN 1
-
-// uncachable cause
-#define UNCACHEABLE_DEPENDENT   1
-#define UNCACHEABLE_RAND        2
-#define UNCACHEABLE_SIDEEFFECT	4
-/// forcing to save JOIN for explain
-#define UNCACHEABLE_EXPLAIN     8
-/** Don't evaluate subqueries in prepare even if they're not correlated */
-#define UNCACHEABLE_PREPARE    16
-/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
-#define UNCACHEABLE_UNITED     32
-#define UNCACHEABLE_CHECKOPTION   64
-
-/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
-#define UNDEF_POS (-1)
-
-/* BINLOG_DUMP options */
-
-#define BINLOG_DUMP_NON_BLOCK   1
-
-/* sql_show.cc:show_log_files() */
-#define SHOW_LOG_STATUS_FREE "FREE"
-#define SHOW_LOG_STATUS_INUSE "IN USE"
-
-struct TABLE_LIST;
-class String;
-void view_store_options(THD *thd, TABLE_LIST *table, String *buff);
-
-/* Options to add_table_to_list() */
-#define TL_OPTION_UPDATING	1
-#define TL_OPTION_FORCE_INDEX	2
-#define TL_OPTION_IGNORE_LEAVES 4
-#define TL_OPTION_ALIAS         8
-
-/* Some portable defines */
-
-#define portable_sizeof_char_ptr 8
-
-#define tmp_file_prefix "#sql"			/**< Prefix for tmp tables */
-#define tmp_file_prefix_length 4
-
-/* Flags for calc_week() function.  */
-#define WEEK_MONDAY_FIRST    1
-#define WEEK_YEAR            2
-#define WEEK_FIRST_WEEKDAY   4
-
-#define STRING_BUFFER_USUAL_SIZE 80
-
-/*
-  Some defines for exit codes for ::is_equal class functions.
-*/
-#define IS_EQUAL_NO 0
-#define IS_EQUAL_YES 1
-#define IS_EQUAL_PACK_LENGTH 2
-
-enum enum_parsing_place
-{
-  NO_MATTER,
-  IN_HAVING,
-  SELECT_LIST,
-  IN_WHERE,
-  IN_ON
-};
-
-
-#define thd_proc_info(thd, msg)  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
-class THD;
-
-enum enum_check_fields
-{
-  CHECK_FIELD_IGNORE,
-  CHECK_FIELD_WARN,
-  CHECK_FIELD_ERROR_FOR_NULL
-};
-
-                                  
-/** Struct to handle simple linked lists. */
-typedef struct st_sql_list {
-  uint elements;
-  uchar *first;
-  uchar **next;
-
-  st_sql_list() {}                              /* Remove gcc warning */
-  inline void empty()
-  {
-    elements=0;
-    first=0;
-    next= &first;
-  }
-  inline void link_in_list(uchar *element,uchar **next_ptr)
-  {
-    elements++;
-    (*next)=element;
-    next= next_ptr;
-    *next=0;
-  }
-  inline void save_and_clear(struct st_sql_list *save)
-  {
-    *save= *this;
-    empty();
-  }
-  inline void push_front(struct st_sql_list *save)
-  {
-    *save->next= first;				/* link current list last */
-    first= save->first;
-    elements+= save->elements;
-  }
-  inline void push_back(struct st_sql_list *save)
-  {
-    if (save->first)
-    {
-      *next= save->first;
-      next= save->next;
-      elements+= save->elements;
-    }
-  }
-} SQL_LIST;
-
-#if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32)
-extern "C" THD *_current_thd_noinline();
-#define _current_thd() _current_thd_noinline()
-#else
-extern pthread_key(THD*, THR_THD);
-inline THD *_current_thd(void)
-{
-  return my_pthread_getspecific_ptr(THD*,THR_THD);
-}
-#endif
-#define current_thd _current_thd()
-
-
-/** 
-  The meat of thd_proc_info(THD*, char*), a macro that packs the last
-  three calling-info parameters. 
-*/
-extern "C"
-const char *set_thd_proc_info(THD *thd, const char *info, 
-                              const char *calling_func, 
-                              const char *calling_file, 
-                              const unsigned int calling_line);
-
-/**
-  Enumerate possible types of a table from re-execution
-  standpoint.
-  TABLE_LIST class has a member of this type.
-  At prepared statement prepare, this member is assigned a value
-  as of the current state of the database. Before (re-)execution
-  of a prepared statement, we check that the value recorded at
-  prepare matches the type of the object we obtained from the
-  table definition cache.
-
-  @sa check_and_update_table_version()
-  @sa Execute_observer
-  @sa Prepared_statement::reprepare()
-*/
-
-enum enum_table_ref_type
-{
-  /** Initial value set by the parser */
-  TABLE_REF_NULL= 0,
-  TABLE_REF_VIEW,
-  TABLE_REF_BASE_TABLE,
-  TABLE_REF_I_S_TABLE,
-  TABLE_REF_TMP_TABLE
-};
-
-/*
-  External variables
-*/
-extern ulong server_id, concurrency;
-
-
-typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
-                                      uint key_length,
-                                      ulonglong *engine_data);
-#include "sql_string.h"
-#include "sql_list.h"
-#include "sql_map.h"
-#include "my_decimal.h"
-#include "handler.h"
-#include "parse_file.h"
-#include "table.h"
-#include "sql_error.h"
-#include "field.h"				/* Field definitions */
-#include "protocol.h"
-#include "sql_udf.h"
-#include "sql_profile.h"
-#include "sql_partition.h"
-
-class user_var_entry;
-class Security_context;
-enum enum_var_type
-{
-  OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
-};
-class sys_var;
-#ifdef MYSQL_SERVER
-class Comp_creator;
-typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
-#endif
-#include "item.h"
-extern my_decimal decimal_zero;
-
-/* my_decimal.cc */
-bool str_set_decimal(uint mask, const my_decimal *val, uint fixed_prec,
-                     uint fixed_dec, char filler, String *str,
-                     CHARSET_INFO *cs);
-inline bool str_set_decimal(const my_decimal *val, String *str,
-                            CHARSET_INFO *cs)
-{
-  return str_set_decimal(E_DEC_FATAL_ERROR, val, 0, 0, 0, str, cs);
-}
-
-/* sql_parse.cc */
-void free_items(Item *item);
-void cleanup_items(Item *item);
-class THD;
-void close_thread_tables(THD *thd);
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
-bool check_single_table_access(THD *thd, ulong privilege,
-			   TABLE_LIST *tables, bool no_errors);
-bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
-			  bool is_proc, bool no_errors);
-bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
-bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
-#else
-inline bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables)
-{ return false; }
-inline bool check_single_table_access(THD *thd, ulong privilege,
-			   TABLE_LIST *tables, bool no_errors)
-{ return false; }
-inline bool check_routine_access(THD *thd,ulong want_access,char *db,
-                                 char *name, bool is_proc, bool no_errors)
-{ return false; }
-inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
-{
-  table->grant.privilege= want_access;
-  return false;
-}
-inline bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
-{ return false; }
-inline bool check_some_routine_access(THD *thd, const char *db,
-                                      const char *name, bool is_proc)
-{ return false; }
-#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
-
-bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
-bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
-int mysql_multi_update_prepare(THD *thd);
-int mysql_multi_delete_prepare(THD *thd);
-bool mysql_insert_select_prepare(THD *thd);
-bool update_precheck(THD *thd, TABLE_LIST *tables);
-bool delete_precheck(THD *thd, TABLE_LIST *tables);
-bool insert_precheck(THD *thd, TABLE_LIST *tables);
-bool create_table_precheck(THD *thd, TABLE_LIST *tables,
-                           TABLE_LIST *create_table);
-int append_query_string(CHARSET_INFO *csinfo,
-                        String const *from, String *to);
-
-void get_default_definer(THD *thd, LEX_USER *definer);
-LEX_USER *create_default_definer(THD *thd);
-LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name);
-LEX_USER *get_current_user(THD *thd, LEX_USER *user);
-bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
-                              uint max_byte_length);
-bool check_string_char_length(LEX_STRING *str, const char *err_msg,
-                              uint max_char_length, CHARSET_INFO *cs,
-                              bool no_error);
-bool check_host_name(LEX_STRING *str);
-
-CHARSET_INFO *merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl);
-
-bool parse_sql(THD *thd,
-               Parser_state *parser_state,
-               Object_creation_ctx *creation_ctx);
-
-Item *negate_expression(THD *thd, Item *expr);
-
-/* log.cc */
-int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
-void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
-void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
-void sql_print_information(const char *format, ...)
-  ATTRIBUTE_FORMAT(printf, 1, 2);
-typedef void (*sql_print_message_func)(const char *format, ...)
-  ATTRIBUTE_FORMAT(printf, 1, 2);
-extern sql_print_message_func sql_print_message_handlers[];
-
-int error_log_print(enum loglevel level, const char *format,
-                    va_list args);
-
-bool slow_log_print(THD *thd, const char *query, uint query_length,
-                    ulonglong current_utime);
-
-bool general_log_print(THD *thd, enum enum_server_command command,
-                       const char *format,...);
-
-bool general_log_write(THD *thd, enum enum_server_command command,
-                       const char *query, uint query_length);
-
-#include "sql_class.h"
-#include "sql_acl.h"
-#include "tztime.h"
-#ifdef MYSQL_SERVER
-#include "sql_servers.h"
-#include "records.h"
-#include "opt_range.h"
-
-#ifdef HAVE_QUERY_CACHE
-struct Query_cache_query_flags
-{
-  unsigned int client_long_flag:1;
-  unsigned int client_protocol_41:1;
-  unsigned int protocol_type:2;
-  unsigned int more_results_exists:1;
-  unsigned int in_trans:1;
-  unsigned int autocommit:1;
-  unsigned int pkt_nr;
-  uint character_set_client_num;
-  uint character_set_results_num;
-  uint collation_connection_num;
-  ha_rows limit;
-  Time_zone *time_zone;
-  ulong sql_mode;
-  ulong max_sort_length;
-  ulong group_concat_max_len;
-  ulong default_week_format;
-  ulong div_precision_increment;
-  MY_LOCALE *lc_time_names;
-};
-#define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags)
-#include "sql_cache.h"
-#define query_cache_abort(A) query_cache.abort(A)
-#define query_cache_end_of_result(A) query_cache.end_of_result(A)
-#define query_cache_store_query(A, B) query_cache.store_query(A, B)
-#define query_cache_destroy() query_cache.destroy()
-#define query_cache_result_size_limit(A) query_cache.result_size_limit(A)
-#define query_cache_init() query_cache.init()
-#define query_cache_resize(A) query_cache.resize(A)
-#define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A)
-#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
-#define query_cache_invalidate1(A) query_cache.invalidate(A)
-#define query_cache_send_result_to_client(A, B, C) \
-  query_cache.send_result_to_client(A, B, C)
-#define query_cache_invalidate_by_MyISAM_filename_ref \
-  &query_cache_invalidate_by_MyISAM_filename
-/* note the "maybe": it's a read without mutex */
-#define query_cache_maybe_disabled(T)                                 \
-  (T->variables.query_cache_type == 0 || query_cache.query_cache_size == 0)
-#define query_cache_is_cacheable_query(L) \
-  (((L)->sql_command == SQLCOM_SELECT) && (L)->safe_to_cache_query)
-#else
-#define QUERY_CACHE_FLAGS_SIZE 0
-#define query_cache_store_query(A, B)
-#define query_cache_destroy()
-#define query_cache_result_size_limit(A)
-#define query_cache_init()
-#define query_cache_resize(A)
-#define query_cache_set_min_res_unit(A)
-#define query_cache_invalidate3(A, B, C)
-#define query_cache_invalidate1(A)
-#define query_cache_send_result_to_client(A, B, C) 0
-#define query_cache_invalidate_by_MyISAM_filename_ref NULL
-
-#define query_cache_abort(A)
-#define query_cache_end_of_result(A)
-#define query_cache_invalidate_by_MyISAM_filename_ref NULL
-#define query_cache_maybe_disabled(T) 1
-#define query_cache_is_cacheable_query(L) 0
-#endif /*HAVE_QUERY_CACHE*/
-
-int write_bin_log(THD *thd, bool clear_error,
-                  char const *query, ulong query_length,
-                  bool is_trans= FALSE);
-
-/* sql_connect.cc */
-int check_user(THD *thd, enum enum_server_command command, 
-	       const char *passwd, uint passwd_len, const char *db,
-	       bool check_count);
-pthread_handler_t handle_one_connection(void *arg);
-void do_handle_one_connection(THD *thd_arg);
-bool init_new_connection_handler_thread();
-void reset_mqh(LEX_USER *lu, bool get_them);
-bool check_mqh(THD *thd, uint check_command);
-void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
-void decrease_user_connections(USER_CONN *uc);
-void thd_init_client_charset(THD *thd, uint cs_number);
-bool setup_connection_thread_globals(THD *thd);
-
-int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
-bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
-bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
-bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db);
-void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
-void mysql_client_binlog_statement(THD *thd);
-bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
-                    my_bool drop_temporary);
-int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
-                         bool drop_temporary, bool drop_view, bool log_query);
-bool quick_rm_table(handlerton *base,const char *db,
-                    const char *table_name, uint flags);
-bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
-bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
-                      char *new_table_name, char *new_table_alias,
-                      bool skip_error);
-
-bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
-                     bool force_switch);
-
-bool mysql_opt_change_db(THD *thd,
-                         const LEX_STRING *new_db_name,
-                         LEX_STRING *saved_db_name,
-                         bool force_switch,
-                         bool *cur_db_changed);
-
-void mysql_parse(THD *thd, const char *inBuf, uint length,
-                 const char ** semicolon);
-
-bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
-bool is_update_query(enum enum_sql_command command);
-bool is_log_table_write_query(enum enum_sql_command command);
-bool alloc_query(THD *thd, const char *packet, uint packet_length);
-void mysql_init_select(LEX *lex);
-void mysql_reset_thd_for_next_command(THD *thd);
-bool mysql_new_select(LEX *lex, bool move_down);
-void create_select_for_variable(const char *var_name);
-void mysql_init_multi_delete(LEX *lex);
-bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
-void create_table_set_open_action_and_adjust_tables(LEX *lex);
-void init_max_user_conn(void);
-void init_update_queries(void);
-void free_max_user_conn(void);
-pthread_handler_t handle_bootstrap(void *arg);
-void do_handle_bootstrap(THD *thd);
-int mysql_execute_command(THD *thd);
-bool do_command(THD *thd);
-bool dispatch_command(enum enum_server_command command, THD *thd,
-		      char* packet, uint packet_length);
-void log_slow_statement(THD *thd);
-bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
-bool compare_record(TABLE *table);
-bool append_file_to_dir(THD *thd, const char **filename_ptr, 
-                        const char *table_name);
-bool table_def_init(void);
-void table_def_start_shutdown(void);
-void table_def_free(void);
-void assign_new_table_id(TABLE_SHARE *share);
-uint cached_open_tables(void);
-uint cached_table_definitions(void);
-void kill_mysql(void);
-void close_connection(THD *thd, uint errcode, bool lock);
-bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, 
-                          bool *write_to_binlog);
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-bool check_access(THD *thd, ulong access, const char *db, ulong *save_priv,
-                  GRANT_INTERNAL_INFO *grant_internal_info,
-                  bool no_grant, bool no_errors);
-bool check_table_access(THD *thd, ulong requirements, TABLE_LIST *tables,
-                        bool any_combination_of_privileges_will_do,
-                        uint number,
-                        bool no_errors);
-#else
-inline bool check_access(THD *thd, ulong access, const char *db,
-                         ulong *save_priv,
-                         GRANT_INTERNAL_INFO *grant_internal_info,
-                         bool no_grant, bool no_errors)
-{
-  if (save_priv)
-    *save_priv= GLOBAL_ACLS;
-  return false;
-}
-inline bool check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
-                               bool any_combination_of_privileges_will_do,
-                               uint number,
-                               bool no_errors)
-{ return false; }
-#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
-
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-bool check_global_access(THD *thd, ulong want_access);
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-
-/*
-  Support routine for SQL parser on partitioning syntax
-*/
-my_bool is_partition_management(LEX *lex);
-/*
-  General routine to change field->ptr of a NULL-terminated array of Field
-  objects. Useful when needed to call val_int, val_str or similar and the
-  field data is not in table->record[0] but in some other structure.
-  set_key_field_ptr changes all fields of an index using a key_info object.
-  All methods presume that there is at least one field to change.
-*/
-
-void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
-void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
-                       const uchar *old_buf);
-
-bool mysql_backup_table(THD* thd, TABLE_LIST* table_list);
-bool mysql_restore_table(THD* thd, TABLE_LIST* table_list);
-
-bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list,
-                          HA_CHECK_OPT* check_opt);
-bool mysql_check_table(THD* thd, TABLE_LIST* table_list,
-                       HA_CHECK_OPT* check_opt);
-bool mysql_repair_table(THD* thd, TABLE_LIST* table_list,
-                        HA_CHECK_OPT* check_opt);
-bool mysql_analyze_table(THD* thd, TABLE_LIST* table_list,
-                         HA_CHECK_OPT* check_opt);
-bool mysql_optimize_table(THD* thd, TABLE_LIST* table_list,
-                          HA_CHECK_OPT* check_opt);
-bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
-                              LEX_STRING *key_cache_name);
-bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
-int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
-                             KEY_CACHE *dst_cache);
-TABLE *create_virtual_tmp_table(THD *thd, List &field_list);
-
-bool mysql_xa_recover(THD *thd);
-
-bool check_simple_select();
-int mysql_alter_tablespace(THD* thd, st_alter_tablespace *ts_info);
-
-SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length,
-                                  SORT_FIELD *sortorder);
-int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
-		List &fields, List  &all_fields, ORDER *order);
-int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
-		List &fields, List &all_fields, ORDER *order,
-		bool *hidden_group_fields);
-bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select,
-                   Item **ref_pointer_array, ORDER *group_list= NULL);
-
-bool handle_select(THD *thd, LEX *lex, select_result *result,
-                   ulong setup_tables_done_option);
-bool mysql_select(THD *thd, Item ***rref_pointer_array,
-                  TABLE_LIST *tables, uint wild_num,  List &list,
-                  COND *conds, uint og_num, ORDER *order, ORDER *group,
-                  Item *having, ORDER *proc_param, ulonglong select_type, 
-                  select_result *result, SELECT_LEX_UNIT *unit, 
-                  SELECT_LEX *select_lex);
-void free_underlaid_joins(THD *thd, SELECT_LEX *select);
-bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
-                         select_result *result);
-int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type,
-			 select_result *result);
-bool mysql_union(THD *thd, LEX *lex, select_result *result,
-                 SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
-bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
-                                                      LEX *lex,
-                                                      TABLE_LIST *table));
-bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
-bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
-Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
-			Item ***copy_func, Field **from_field,
-                        Field **def_field,
-			bool group, bool modify_item,
-			bool table_cant_handle_bit_fields,
-                        bool make_copy_field,
-                        uint convert_blob_length);
-void sp_prepare_create_field(THD *thd, Create_field *sql_field);
-int prepare_create_field(Create_field *sql_field, 
-			 uint *blob_columns, 
-			 int *timestamps, int *timestamps_with_niladic,
-			 longlong table_flags);
-CHARSET_INFO* get_sql_field_charset(Create_field *sql_field,
-                                    HA_CREATE_INFO *create_info);
-bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
-                        HA_CREATE_INFO *create_info,
-                        Alter_info *alter_info);
-bool mysql_create_table_no_lock(THD *thd, const char *db,
-                                const char *table_name,
-                                HA_CREATE_INFO *create_info,
-                                Alter_info *alter_info,
-                                bool tmp_table, uint select_field_count);
-
-bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
-                       HA_CREATE_INFO *create_info,
-                       TABLE_LIST *table_list,
-                       Alter_info *alter_info,
-                       uint order_num, ORDER *order, bool ignore);
-bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
-bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
-                             TABLE_LIST *src_table,
-                             HA_CREATE_INFO *create_info);
-bool mysql_rename_table(handlerton *base, const char *old_db,
-                        const char * old_name, const char *new_db,
-                        const char * new_name, uint flags);
-bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
-                          Item **conds, uint order_num, ORDER *order);
-int mysql_update(THD *thd,TABLE_LIST *tables,List &fields,
-		 List &values,COND *conds,
-		 uint order_num, ORDER *order, ha_rows limit,
-		 enum enum_duplicates handle_duplicates, bool ignore,
-                 ha_rows *found_return, ha_rows *updated_return);
-bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
-                        List *fields, List *values,
-                        COND *conds, ulonglong options,
-                        enum enum_duplicates handle_duplicates, bool ignore,
-                        SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex,
-                        multi_update **result);
-bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
-                          List &fields, List_item *values,
-                          List &update_fields,
-                          List &update_values, enum_duplicates duplic,
-                          COND **where, bool select_insert,
-                          bool check_fields, bool abort_on_warning);
-bool mysql_insert(THD *thd,TABLE_LIST *table,List &fields,
-                  List &values, List &update_fields,
-                  List &update_values, enum_duplicates flag,
-                  bool ignore);
-int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
-                                           TABLE_LIST *table_list);
-void prepare_triggers_for_insert_stmt(TABLE *table);
-int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
-bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
-                  SQL_LIST *order, ha_rows rows, ulonglong options,
-                  bool reset_auto_increment);
-bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
-bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
-uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
-                          bool tmp_table);
-TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
-                             uint key_length, uint db_flags, int *error,
-                             my_hash_value_type hash_value);
-void release_table_share(TABLE_SHARE *share);
-TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
-TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
-                   uint lock_flags);
-bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
-                Open_table_context *backoff, uint flags);
-bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias,
-                   char *cache_key, uint cache_key_length,
-                   MEM_ROOT *mem_root, uint flags);
-TABLE *find_locked_table(TABLE *list, const char *db, const char *table_name);
-TABLE *find_table_for_mdl_upgrade(TABLE *list, const char *db,
-                                  const char *table_name,
-                                  bool no_error);
-thr_lock_type read_lock_type_for_table(THD *thd, TABLE *table);
-bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
-                  uint db_stat, uint prgflag,
-                  uint ha_open_flags, TABLE *outparam,
-                  TABLE_LIST *table_desc, MEM_ROOT *mem_root);
-void execute_init_command(THD *thd, LEX_STRING *init_command,
-                          mysql_rwlock_t *var_mutex);
-extern Field *not_found_field;
-extern Field *view_ref_found;
-
-enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
-				  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
-                                  IGNORE_EXCEPT_NON_UNIQUE};
-Field *
-find_field_in_tables(THD *thd, Item_ident *item,
-                     TABLE_LIST *first_table, TABLE_LIST *last_table,
-                     Item **ref, find_item_error_report_type report_error,
-                     bool check_privileges, bool register_tree_change);
-Field *
-find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
-                        const char *name, uint length,
-                        const char *item_name, const char *db_name,
-                        const char *table_name, Item **ref,
-                        bool check_privileges, bool allow_rowid,
-                        uint *cached_field_index_ptr,
-                        bool register_tree_change, TABLE_LIST **actual_table);
-Field *
-find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
-                    bool allow_rowid, uint *cached_field_index_ptr);
-Field *
-find_field_in_table_sef(TABLE *table, const char *name);
-
-#endif /* MYSQL_SERVER */
-
-#ifdef HAVE_OPENSSL
-#include 
-struct st_des_keyblock
-{
-  DES_cblock key1, key2, key3;
-};
-struct st_des_keyschedule
-{
-  DES_key_schedule ks1, ks2, ks3;
-};
-extern char *des_key_file;
-extern struct st_des_keyschedule des_keyschedule[10];
-extern uint des_default_key;
-extern mysql_mutex_t LOCK_des_key_file;
-bool load_des_key_file(const char *file_name);
-#endif /* HAVE_OPENSSL */
-
-#ifdef MYSQL_SERVER
-/* sql_do.cc */
-bool mysql_do(THD *thd, List &values);
-
-/* sql_analyse.h */
-bool append_escaped(String *to_str, String *from_str);
-
-/* sql_show.cc */
-bool mysqld_show_open_tables(THD *thd,const char *wild);
-bool mysqld_show_logs(THD *thd);
-void append_identifier(THD *thd, String *packet, const char *name,
-		       uint length);
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
-int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
-bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
-bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
-
-void mysqld_list_processes(THD *thd,const char *user,bool verbose);
-int mysqld_show_status(THD *thd);
-int mysqld_show_variables(THD *thd,const char *wild);
-bool mysqld_show_storage_engines(THD *thd);
-bool mysqld_show_authors(THD *thd);
-bool mysqld_show_contributors(THD *thd);
-bool mysqld_show_privileges(THD *thd);
-bool mysqld_show_column_types(THD *thd);
-bool mysqld_help (THD *thd, const char *text);
-void calc_sum_of_all_status(STATUS_VAR *to);
-
-void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
-                    const LEX_STRING *definer_host);
-
-int add_status_vars(SHOW_VAR *list);
-void remove_status_vars(SHOW_VAR *list);
-void init_status_vars();
-void free_status_vars();
-void reset_status_vars();
-/* information schema */
-extern LEX_STRING INFORMATION_SCHEMA_NAME;
-/* performance schema */
-extern LEX_STRING PERFORMANCE_SCHEMA_DB_NAME;
-/* log tables */
-extern LEX_STRING MYSQL_SCHEMA_NAME;
-extern LEX_STRING GENERAL_LOG_NAME;
-extern LEX_STRING SLOW_LOG_NAME;
-
-extern const LEX_STRING partition_keywords[];
-ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
-ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
-int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
-                         enum enum_schema_tables schema_table_idx);
-int make_schema_select(THD *thd,  SELECT_LEX *sel,
-                       enum enum_schema_tables schema_table_idx);
-int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list);
-int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
-int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
-int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
-int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
-bool get_schema_tables_result(JOIN *join,
-                              enum enum_schema_table_state executed_place);
-enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
-
-inline bool is_infoschema_db(const char *name, size_t len)
-{
-  return (INFORMATION_SCHEMA_NAME.length == len &&
-          !my_strcasecmp(system_charset_info,
-                         INFORMATION_SCHEMA_NAME.str, name));
-}
-
-inline bool is_infoschema_db(const char *name)
-{
-  return !my_strcasecmp(system_charset_info,
-                        INFORMATION_SCHEMA_NAME.str, name);
-}
-
-void initialize_information_schema_acl();
-
-/* sql_handler.cc */
-bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen);
-bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
-bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
-                   List *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
-void mysql_ha_flush(THD *thd);
-void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
-void mysql_ha_cleanup(THD *thd);
-void mysql_ha_move_tickets_after_trans_sentinel(THD *thd);
-
-/* sql_base.cc */
-#define TMP_TABLE_KEY_EXTRA 8
-void set_item_name(Item *item,char *pos,uint length);
-bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
-		       char *length, char *decimal,
-		       uint type_modifier,
-		       Item *default_value, Item *on_update_value,
-		       LEX_STRING *comment,
-		       char *change, List *interval_list,
-		       CHARSET_INFO *cs,
-		       uint uint_geom_type);
-Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
-				char *length, char *decimals,
-				uint type_modifier, 
-				Item *default_value, Item *on_update_value,
-				LEX_STRING *comment, char *change, 
-				List *interval_list, CHARSET_INFO *cs,
-				uint uint_geom_type);
-void store_position_for_column(const char *name);
-bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc);
-bool push_new_name_resolution_context(THD *thd,
-                                      TABLE_LIST *left_op,
-                                      TABLE_LIST *right_op);
-void add_join_on(TABLE_LIST *b,Item *expr);
-void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List *using_fields,
-                      SELECT_LEX *lex);
-bool add_proc_to_list(THD *thd, Item *item);
-bool wait_while_table_is_used(THD *thd, TABLE *table,
-                              enum ha_extra_function function);
-void drop_open_table(THD *thd, TABLE *table, const char *db_name,
-                     const char *table_name);
-void close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
-                               bool remove_from_locked_tables);
-void update_non_unique_table_error(TABLE_LIST *update,
-                                   const char *operation,
-                                   TABLE_LIST *duplicate);
-
-SQL_SELECT *make_select(TABLE *head, table_map const_tables,
-			table_map read_tables, COND *conds,
-                        bool allow_null_cond,  int *error);
-extern Item **not_found_item;
-
-/*
-  A set of constants used for checking non aggregated fields and sum
-  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
-*/
-#define NON_AGG_FIELD_USED  1
-#define SUM_FUNC_USED       2
-
-/*
-  This enumeration type is used only by the function find_item_in_list
-  to return the info on how an item has been resolved against a list
-  of possibly aliased items.
-  The item can be resolved: 
-   - against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
-   - against non-aliased field name of the list  (RESOLVED_WITH_NO_ALIAS)
-   - against an aliased field name of the list   (RESOLVED_BEHIND_ALIAS)
-   - ignoring the alias name in cases when SQL requires to ignore aliases
-     (e.g. when the resolved field reference contains a table name or
-     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)    
-*/
-enum enum_resolution_type {
-  NOT_RESOLVED=0,
-  RESOLVED_IGNORING_ALIAS,
-  RESOLVED_BEHIND_ALIAS,
-  RESOLVED_WITH_NO_ALIAS,
-  RESOLVED_AGAINST_ALIAS
-};
-Item ** find_item_in_list(Item *item, List &items, uint *counter,
-                          find_item_error_report_type report_error,
-                          enum_resolution_type *resolution);
-bool get_key_map_from_key_list(key_map *map, TABLE *table,
-                               List *index_list);
-bool insert_fields(THD *thd, Name_resolution_context *context,
-		   const char *db_name, const char *table_name,
-                   List_iterator *it, bool any_privileges);
-bool setup_tables(THD *thd, Name_resolution_context *context,
-                  List *from_clause, TABLE_LIST *tables,
-                  TABLE_LIST **leaves, bool select_insert);
-bool setup_tables_and_check_access(THD *thd, 
-                                   Name_resolution_context *context,
-                                   List *from_clause, 
-                                   TABLE_LIST *tables, 
-                                   TABLE_LIST **leaves, 
-                                   bool select_insert,
-                                   ulong want_access_first,
-                                   ulong want_access);
-int setup_wild(THD *thd, TABLE_LIST *tables, List &fields,
-	       List *sum_func_list, uint wild_num);
-bool setup_fields(THD *thd, Item** ref_pointer_array,
-                  List &item, enum_mark_columns mark_used_columns,
-                  List *sum_func_list, bool allow_sum_func);
-inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array,
-                                      List &item,
-                                      enum_mark_columns mark_used_columns,
-                                      List *sum_func_list,
-                                      bool allow_sum_func)
-{
-  bool res;
-  thd->lex->select_lex.no_wrap_view_item= TRUE;
-  res= setup_fields(thd, ref_pointer_array, item, mark_used_columns, sum_func_list,
-                    allow_sum_func);
-  thd->lex->select_lex.no_wrap_view_item= FALSE;
-  return res;
-}
-int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
-		COND **conds);
-int setup_ftfuncs(SELECT_LEX* select);
-int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
-void wait_for_condition(THD *thd, mysql_mutex_t *mutex,
-                        mysql_cond_t *cond);
-bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags,
-                Prelocking_strategy *prelocking_strategy);
-inline bool
-open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags)
-{
-  DML_prelocking_strategy prelocking_strategy;
-
-  return open_tables(thd, tables, counter, flags, &prelocking_strategy);
-}
-/* open_and_lock_tables with optional derived handling */
-bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
-                          bool derived, uint flags,
-                          Prelocking_strategy *prelocking_strategy);
-inline bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
-                                 bool derived, uint flags)
-{
-  DML_prelocking_strategy prelocking_strategy;
-
-  return open_and_lock_tables(thd, tables, derived, flags,
-                              &prelocking_strategy);
-}
-/* simple open_and_lock_tables without derived handling for single table */
-TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
-                                thr_lock_type lock_type, uint flags);
-bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
-bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags);
-TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
-			    const char *table_name, bool link_in_list);
-bool rm_temporary_table(handlerton *base, char *path);
-void free_io_cache(TABLE *entry);
-void intern_close_table(TABLE *entry);
-bool close_thread_table(THD *thd, TABLE **table_ptr);
-void close_temporary_tables(THD *thd);
-void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
-                             MDL_ticket *mdl_savepoint);
-TABLE_LIST *find_table_in_list(TABLE_LIST *table,
-                               TABLE_LIST *TABLE_LIST::*link,
-                               const char *db_name,
-                               const char *table_name);
-TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
-                         bool check_alias);
-TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name);
-TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list);
-int drop_temporary_table(THD *thd, TABLE_LIST *table_list);
-void close_temporary_table(THD *thd, TABLE *table, bool free_share,
-                           bool delete_table);
-void mark_tmp_table_for_reuse(TABLE *table);
-void close_temporary(TABLE *table, bool free_share, bool delete_table);
-bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
-			    const char *table_name);
-void flush_tables();
-bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
-char *make_log_name(char *buff, const char *name, const char* log_ext);
-extern char default_logfile_name[FN_REFLEN];
-
-#ifdef WITH_PARTITION_STORAGE_ENGINE
-uint fast_alter_partition_table(THD *thd, TABLE *table,
-                                Alter_info *alter_info,
-                                HA_CREATE_INFO *create_info,
-                                TABLE_LIST *table_list,
-                                char *db,
-                                const char *table_name,
-                                uint fast_alter_partition);
-uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
-                    enum partition_state part_state);
-uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
-                           HA_CREATE_INFO *create_info,
-                           handlerton *old_db_type,
-                           bool *partition_changed,
-                           uint *fast_alter_partition);
-char *generate_partition_syntax(partition_info *part_info,
-                                uint *buf_length, bool use_sql_alloc,
-                                bool show_partition_options,
-                                HA_CREATE_INFO *create_info,
-                                Alter_info *alter_info);
-#endif
-
-enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN,
-                                 TDC_RT_REMOVE_UNUSED};
-void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
-                      const char *db, const char *table_name);
-
-#define NORMAL_PART_NAME 0
-#define TEMP_PART_NAME 1
-#define RENAMED_PART_NAME 2
-void create_partition_name(char *out, const char *in1,
-                           const char *in2, uint name_variant,
-                           bool translate);
-void create_subpartition_name(char *out, const char *in1,
-                              const char *in2, const char *in3,
-                              uint name_variant);
-
-typedef struct st_lock_param_type
-{
-  TABLE_LIST *table_list;
-  ulonglong copied;
-  ulonglong deleted;
-  THD *thd;
-  HA_CREATE_INFO *create_info;
-  Alter_info *alter_info;
-  TABLE *table;
-  KEY *key_info_buffer;
-  const char *db;
-  const char *table_name;
-  uchar *pack_frm_data;
-  uint key_count;
-  uint db_options;
-  size_t pack_frm_len;
-  partition_info *part_info;
-} ALTER_PARTITION_PARAM_TYPE;
-
-void mem_alloc_error(size_t size);
-
-enum ddl_log_entry_code
-{
-  /*
-    DDL_LOG_EXECUTE_CODE:
-      This is a code that indicates that this is a log entry to
-      be executed, from this entry a linked list of log entries
-      can be found and executed.
-    DDL_LOG_ENTRY_CODE:
-      An entry to be executed in a linked list from an execute log
-      entry.
-    DDL_IGNORE_LOG_ENTRY_CODE:
-      An entry that is to be ignored
-  */
-  DDL_LOG_EXECUTE_CODE = 'e',
-  DDL_LOG_ENTRY_CODE = 'l',
-  DDL_IGNORE_LOG_ENTRY_CODE = 'i'
-};
-
-enum ddl_log_action_code
-{
-  /*
-    The type of action that a DDL_LOG_ENTRY_CODE entry is to
-    perform.
-    DDL_LOG_DELETE_ACTION:
-      Delete an entity
-    DDL_LOG_RENAME_ACTION:
-      Rename an entity
-    DDL_LOG_REPLACE_ACTION:
-      Rename an entity after removing the previous entry with the
-      new name, that is replace this entry.
-  */
-  DDL_LOG_DELETE_ACTION = 'd',
-  DDL_LOG_RENAME_ACTION = 'r',
-  DDL_LOG_REPLACE_ACTION = 's'
-};
-
-
-typedef struct st_ddl_log_entry
-{
-  const char *name;
-  const char *from_name;
-  const char *handler_name;
-  uint next_entry;
-  uint entry_pos;
-  enum ddl_log_entry_code entry_type;
-  enum ddl_log_action_code action_type;
-  /*
-    Most actions have only one phase. REPLACE does however have two
-    phases. The first phase removes the file with the new name if
-    there was one there before and the second phase renames the
-    old name to the new name.
-  */
-  char phase;
-} DDL_LOG_ENTRY;
-
-typedef struct st_ddl_log_memory_entry
-{
-  uint entry_pos;
-  struct st_ddl_log_memory_entry *next_log_entry;
-  struct st_ddl_log_memory_entry *prev_log_entry;
-  struct st_ddl_log_memory_entry *next_active_log_entry;
-} DDL_LOG_MEMORY_ENTRY;
-
-
-bool write_ddl_log_entry(DDL_LOG_ENTRY *ddl_log_entry,
-                           DDL_LOG_MEMORY_ENTRY **active_entry);
-bool write_execute_ddl_log_entry(uint first_entry,
-                                   bool complete,
-                                   DDL_LOG_MEMORY_ENTRY **active_entry);
-bool deactivate_ddl_log_entry(uint entry_no);
-void release_ddl_log_memory_entry(DDL_LOG_MEMORY_ENTRY *log_entry);
-bool sync_ddl_log();
-void release_ddl_log();
-void execute_ddl_log_recovery();
-bool execute_ddl_log_entry(THD *thd, uint first_entry);
-
-extern mysql_mutex_t LOCK_gdl;
-
-#define WFRM_WRITE_SHADOW 1
-#define WFRM_INSTALL_SHADOW 2
-#define WFRM_PACK_FRM 4
-#define WFRM_KEEP_SHARE 8
-bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags);
-int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt);
-void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt);
-
-/* Functions to work with system tables. */
-bool open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
-                                 Open_tables_backup *backup);
-void close_system_tables(THD *thd, Open_tables_backup *backup);
-TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
-
-TABLE *open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup);
-void close_log_table(THD *thd, Open_tables_backup *backup);
-
-bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
-                         bool wait_for_refresh);
-bool close_cached_connection_tables(THD *thd, bool wait_for_refresh,
-                                    LEX_STRING *connect_string,
-                                    bool have_lock = FALSE);
-void copy_field_from_tmp_record(Field *field,int offset);
-bool fill_record(THD *thd, Field **field, List &values,
-                 bool ignore_errors);
-bool fill_record_n_invoke_before_triggers(THD *thd, List &fields,
-                                          List &values,
-                                          bool ignore_errors,
-                                          Table_triggers_list *triggers,
-                                          enum trg_event_type event);
-bool fill_record_n_invoke_before_triggers(THD *thd, Field **field,
-                                          List &values,
-                                          bool ignore_errors,
-                                          Table_triggers_list *triggers,
-                                          enum trg_event_type event);
-OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild);
-
-inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
-                                             const char *db_name,
-                                             const char *table_name)
-{
-  return find_table_in_list(table, &TABLE_LIST::next_global,
-                            db_name, table_name);
-}
-
-inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table,
-                                            const char *db_name,
-                                            const char *table_name)
-{
-  return find_table_in_list(table, &TABLE_LIST::next_local,
-                            db_name, table_name);
-}
-
-
-/* sql_calc.cc */
-bool eval_const_cond(COND *cond);
-
-/* sql_load.cc */
-int mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list,
-	        List &fields_vars, List &set_fields,
-                List &set_values_list,
-                enum enum_duplicates handle_duplicates, bool ignore,
-                bool local_file);
-int write_record(THD *thd, TABLE *table, COPY_INFO *info);
-
-/* sql_manager.cc */
-extern bool volatile  mqh_used;
-void start_handle_manager();
-void stop_handle_manager();
-bool mysql_manager_submit(void (*action)());
-
-
-/* sql_test.cc */
-#ifndef DBUG_OFF
-void print_where(COND *cond,const char *info, enum_query_type query_type);
-void print_cached_tables(void);
-void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
-void print_plan(JOIN* join,uint idx, double record_count, double read_time,
-                double current_read_time, const char *info);
-#endif
-void mysql_print_status();
-/* key.cc */
-int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field,
-                 uint *key_length, uint *keypart);
-void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, uint key_length);
-void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
-                 uint key_length);
-bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length);
-void key_unpack(String *to,TABLE *form,uint index);
-bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields);
-int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length);
-extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b);
-
-bool init_errmessage(void);
-#endif /* MYSQL_SERVER */
-void sql_perror(const char *message);
-bool read_texts(const char *file_name, const char *language,
-                const char ***point, uint error_messages);
-
-bool fn_format_relative_to_data_home(char * to, const char *name,
-				     const char *dir, const char *extension);
-#ifdef MYSQL_SERVER
-File open_binlog(IO_CACHE *log, const char *log_file_name,
-                 const char **errmsg);
-
-/* mysqld.cc */
-extern void MYSQLerror(const char*);
-void refresh_status(THD *thd);
-my_bool mysql_rm_tmp_tables(void);
-void handle_connection_in_main_thread(THD *thd);
-void create_thread_to_handle_connection(THD *thd);
-void unlink_thd(THD *thd);
-bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
-void flush_thread_cache();
-
-/* item_func.cc */
-extern bool check_reserved_words(LEX_STRING *name);
-extern enum_field_types agg_field_type(Item **items, uint nitems);
-
-/* strfunc.cc */
-ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs,
-		   char **err_pos, uint *err_len, bool *set_warning);
-uint find_type(const TYPELIB *lib, const char *find, uint length,
-               bool part_match);
-uint find_type2(const TYPELIB *lib, const char *find, uint length,
-                CHARSET_INFO *cs);
-void unhex_type2(TYPELIB *lib);
-uint check_word(TYPELIB *lib, const char *val, const char *end,
-		const char **end_of_word);
-int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
-                         CHARSET_INFO * const cs);
-char *set_to_string(THD *thd, LEX_STRING *result, ulonglong set,
-                    const char *lib[]);
-char *flagset_to_string(THD *thd, LEX_STRING *result, ulonglong set,
-                        const char *lib[]);
-
-
-bool is_keyword(const char *name, uint len);
-
-#define MY_DB_OPT_FILE "db.opt"
-bool my_database_names_init(void);
-void my_database_names_free(void);
-bool check_db_dir_existence(const char *db_name);
-bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create);
-bool load_db_opt_by_name(THD *thd, const char *db_name,
-                         HA_CREATE_INFO *db_create_info);
-CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
-bool my_dbopt_init(void);
-void my_dbopt_cleanup(void);
-extern int creating_database; // How many database locks are made
-extern int creating_table;    // How many mysql_create_table() are running
-
-/*
-  External variables
-*/
-
-extern time_t server_start_time, flush_status_time;
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern uint mysql_data_home_len, mysql_real_data_home_len;
-extern const char *mysql_real_data_home_ptr;
-extern uint thread_handling;
-
-extern MYSQL_PLUGIN_IMPORT char  *mysql_data_home;
-extern char server_version[SERVER_VERSION_LENGTH];
-extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
-extern char mysql_unpacked_real_data_home[];
-
-extern CHARSET_INFO *character_set_filesystem;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
-extern int mysql_unpacked_real_data_home_len;
-#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
-extern MYSQL_PLUGIN_IMPORT MY_TMPDIR mysql_tmpdir_list;
-extern const LEX_STRING command_name[];
-
-extern LEX_STRING opt_init_connect, opt_init_slave;
-
-extern const char *first_keyword, *delayed_user, *binary_keyword;
-extern MYSQL_PLUGIN_IMPORT const char  *my_localhost;
-extern MYSQL_PLUGIN_IMPORT const char **errmesg;			/* Error messages */
-
-extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
-extern const char * const TRG_EXT;
-extern const char * const TRN_EXT;
-extern Eq_creator eq_creator;
-extern Ne_creator ne_creator;
-extern Gt_creator gt_creator;
-extern Lt_creator lt_creator;
-extern Ge_creator ge_creator;
-extern Le_creator le_creator;
-extern char lc_messages_dir[FN_REFLEN];
-extern char *lc_messages_dir_ptr, *log_error_file_ptr;
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern MYSQL_PLUGIN_IMPORT char reg_ext[FN_EXTLEN];
-extern MYSQL_PLUGIN_IMPORT uint reg_ext_length;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern char *mysql_home_ptr, *pidfile_name_ptr;
-extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
-extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
-extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
-extern const double log_10[309];
-extern ulonglong log_10_int[20];
-extern ulonglong keybuff_size;
-extern ulonglong thd_startup_options;
-extern ulong thread_id;
-extern ulong binlog_cache_use, binlog_cache_disk_use;
-extern ulong aborted_threads,aborted_connects;
-extern ulong delayed_insert_timeout;
-extern ulong delayed_insert_limit, delayed_queue_size;
-extern ulong delayed_insert_threads, delayed_insert_writes;
-extern ulong delayed_rows_in_use,delayed_insert_errors;
-extern ulong slave_open_temp_tables;
-extern ulong query_cache_size, query_cache_min_res_unit;
-extern ulong slow_launch_threads, slow_launch_time;
-extern ulong table_cache_size, table_def_size;
-extern MYSQL_PLUGIN_IMPORT ulong max_connections;
-extern ulong max_connect_errors, connect_timeout;
-extern ulong slave_trans_retries;
-extern uint  slave_net_timeout;
-extern ulong what_to_log,flush_time;
-extern ulong query_buff_size;
-extern ulong max_prepared_stmt_count, prepared_stmt_count;
-extern ulong binlog_cache_size, open_files_limit;
-extern ulonglong max_binlog_cache_size;
-extern ulong max_binlog_size, max_relay_log_size;
-extern ulong opt_binlog_rows_event_max_size;
-extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
-extern ulong back_log;
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern ulong MYSQL_PLUGIN_IMPORT specialflag;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern ulong current_pid;
-extern ulong expire_logs_days;
-extern uint sync_binlog_period, sync_relaylog_period, 
-            sync_relayloginfo_period, sync_masterinfo_period;
-extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
-extern ulong tc_log_page_waits;
-extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
-extern my_bool relay_log_recovery;
-extern uint test_flags,select_errors,ha_open_options;
-extern uint protocol_version, mysqld_port, dropping_tables;
-extern uint delay_key_write_options;
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern bool opt_endinfo, using_udf_functions;
-extern my_bool locked_in_memory;
-extern bool opt_using_transactions;
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern MYSQL_PLUGIN_IMPORT bool mysqld_embedded;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern bool opt_large_files, server_id_supplied;
-extern bool opt_bin_log, opt_error_log;
-extern my_bool opt_log, opt_slow_log;
-extern ulonglong log_output_options;
-extern my_bool opt_log_queries_not_using_indexes;
-extern bool opt_disable_networking, opt_skip_show_db;
-extern bool opt_ignore_builtin_innodb;
-extern my_bool opt_character_set_client_handshake;
-extern bool volatile abort_loop, shutdown_in_progress;
-extern bool in_bootstrap;
-extern uint volatile thread_count, global_read_lock;
-extern uint connection_count;
-extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
-extern my_bool opt_local_infile, opt_myisam_use_mmap;
-extern my_bool opt_slave_compressed_protocol, use_temp_pool;
-extern uint slave_exec_mode_options;
-extern ulonglong slave_type_conversions_options;
-extern my_bool opt_readonly, lower_case_file_system;
-extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
-extern my_bool opt_secure_auth;
-extern char* opt_secure_file_priv;
-extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
-extern my_bool sp_automatic_privileges, opt_noacl, disable_slaves;
-extern my_bool opt_old_style_user_limits, trust_function_creators;
-extern uint opt_crash_binlog_innodb;
-extern char *shared_memory_base_name, *mysqld_unix_port;
-extern my_bool opt_enable_shared_memory;
-extern char *default_tz_name;
-extern Time_zone *default_tz;
-extern char *default_storage_engine;
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern my_bool opt_large_pages;
-extern uint opt_large_page_size;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern char *opt_logname, *opt_slow_logname;
-extern const char *log_output_str;
-extern my_bool old_mode;
-
-extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log;
-extern LOGGER logger;
-extern TABLE_LIST general_log, slow_log;
-extern MYSQL_FILE *bootstrap_file;
-extern int bootstrap_error;
-extern FILE *stderror_file;
-extern pthread_key(MEM_ROOT**,THR_MALLOC);
-extern mysql_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
-       LOCK_mapped_file, LOCK_user_locks, LOCK_status,
-       LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
-       LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
-       LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
-       LOCK_global_system_variables, LOCK_user_conn,
-       LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
-extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count;
-#ifdef HAVE_OPENSSL
-extern mysql_mutex_t LOCK_des_key_file;
-#endif
-extern mysql_mutex_t LOCK_server_started;
-extern mysql_cond_t COND_server_started;
-extern int mysqld_server_started;
-extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
-extern mysql_rwlock_t LOCK_system_variables_hash;
-extern mysql_cond_t COND_thread_count;
-extern mysql_cond_t COND_refresh, COND_manager;
-extern mysql_cond_t COND_global_read_lock;
-extern pthread_attr_t connection_attrib;
-extern I_List threads;
-extern MY_BITMAP temp_pool;
-extern String my_empty_string;
-extern const String my_null_string;
-extern SHOW_VAR status_vars[];
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-extern struct system_variables max_system_variables;
-extern struct system_status_var global_status_var;
-extern struct rand_struct sql_rand;
-
-extern DATE_TIME_FORMAT global_date_format, global_datetime_format, global_time_format;
-extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
-
-extern String null_string;
-extern HASH table_def_cache, lock_db_cache;
-extern TABLE *unused_tables;
-extern uint  table_cache_count;
-extern const char* any_db;
-extern const LEX_STRING view_type;
-extern scheduler_functions thread_scheduler;
-extern TYPELIB thread_handling_typelib;
-extern uint sql_command_flags[];
-extern uint server_command_flags[];
-extern TYPELIB log_output_typelib;
-extern const char *log_output_names[];
-
-/* optional things, have_* variables */
-extern SHOW_COMP_OPTION have_csv, have_innodb;
-extern SHOW_COMP_OPTION have_ndbcluster, have_partitioning;
-extern SHOW_COMP_OPTION have_profiling;
-
-extern handlerton *partition_hton;
-extern handlerton *myisam_hton;
-extern handlerton *heap_hton;
-
-extern SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen;
-extern SHOW_COMP_OPTION have_query_cache;
-extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
-extern SHOW_COMP_OPTION have_crypt;
-extern SHOW_COMP_OPTION have_compress;
-
-extern int orig_argc;
-extern char **orig_argv;
-extern const char *load_default_groups[];
-
-#ifndef __WIN__
-extern pthread_t signal_thread;
-#endif
-
-extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
-            *opt_ssl_key;
-
-#ifdef HAVE_OPENSSL
-extern struct st_VioSSLFd * ssl_acceptor_fd;
-#endif /* HAVE_OPENSSL */
-
-MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags);
-/* mysql_lock_tables() and open_table() flags bits */
-#define MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK      0x0001
-#define MYSQL_OPEN_IGNORE_FLUSH                 0x0002
-#define MYSQL_OPEN_TEMPORARY_ONLY               0x0004
-#define MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY      0x0008
-#define MYSQL_LOCK_LOG_TABLE                    0x0010
-#define MYSQL_OPEN_TAKE_UPGRADABLE_MDL          0x0020
-/**
-  Do not try to acquire a metadata lock on the table: we
-  already have one.
-*/
-#define MYSQL_OPEN_HAS_MDL_LOCK                 0x0040
-/**
-  If in locked tables mode, ignore the locked tables and get
-  a new instance of the table.
-*/
-#define MYSQL_OPEN_GET_NEW_TABLE                0x0080
-/** Don't look up the table in the list of temporary tables. */
-#define MYSQL_OPEN_SKIP_TEMPORARY               0x0100
-/** Fail instead of waiting when conficting metadata lock is discovered. */
-#define MYSQL_OPEN_FAIL_ON_MDL_CONFLICT         0x0200
-/** Open tables using MDL_SHARED lock instead of one specified in parser. */
-#define MYSQL_OPEN_FORCE_SHARED_MDL             0x0400
-/**
-  Open tables using MDL_SHARED_HIGH_PRIO lock instead of one specified
-  in parser.
-*/
-#define MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL   0x0800
-/**
-  When opening or locking the table, use the maximum timeout
-  (LONG_TIMEOUT = 1 year) rather than the user-supplied timeout value.
-*/
-#define MYSQL_LOCK_IGNORE_TIMEOUT               0x1000
-
-/** Please refer to the internals manual. */
-#define MYSQL_OPEN_REOPEN  (MYSQL_OPEN_IGNORE_FLUSH |\
-                            MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK |\
-                            MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY |\
-                            MYSQL_LOCK_IGNORE_TIMEOUT |\
-                            MYSQL_OPEN_GET_NEW_TABLE |\
-                            MYSQL_OPEN_SKIP_TEMPORARY |\
-                            MYSQL_OPEN_HAS_MDL_LOCK)
-
-void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
-void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
-void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count);
-void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table);
-void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock);
-void mysql_lock_downgrade_write(THD *thd, TABLE *table,
-                                thr_lock_type new_lock_type);
-bool mysql_lock_abort_for_thread(THD *thd, TABLE *table);
-MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b);
-TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle,
-                                      TABLE_LIST *haystack);
-void broadcast_refresh(void);
-
-/* Lock based on name */
-bool lock_table_names(THD *thd, TABLE_LIST *table_list);
-void unlock_table_names(THD *thd);
-
-/* Lock based on stored routine name */
-bool lock_routine_name(THD *thd, bool is_function, const char *db,
-                       const char *name);
-
-/* old unireg functions */
-
-void unireg_init(ulong options);
-void unireg_end(void) __attribute__((noreturn));
-bool mysql_create_frm(THD *thd, const char *file_name,
-                      const char *db, const char *table,
-		      HA_CREATE_INFO *create_info,
-		      List &create_field,
-		      uint key_count,KEY *key_info,handler *db_type);
-int rea_create_table(THD *thd, const char *path,
-                     const char *db, const char *table_name,
-                     HA_CREATE_INFO *create_info,
-  		     List &create_field,
-                     uint key_count,KEY *key_info,
-                     handler *file);
-int format_number(uint inputflag,uint max_length,char * pos,uint length,
-		  char * *errpos);
-
-/* table.cc */
-TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
-                               uint key_length);
-void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
-                          uint key_length,
-                          const char *table_name, const char *path);
-void free_table_share(TABLE_SHARE *share);
-int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
-void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
-int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
-                          uint db_stat, uint prgflag, uint ha_open_flags,
-                          TABLE *outparam, bool is_create_table);
-int readfrm(const char *name, uchar **data, size_t *length);
-int writefrm(const char* name, const uchar* data, size_t len);
-int closefrm(TABLE *table, bool free_share);
-int read_string(File file, uchar* *to, size_t length);
-void free_blobs(TABLE *table);
-void free_field_buffers_larger_than(TABLE *table, uint32 size);
-int set_zone(int nr,int min_zone,int max_zone);
-ulong convert_period_to_month(ulong period);
-ulong convert_month_to_period(ulong month);
-void get_date_from_daynr(long daynr,uint *year, uint *month,
-			 uint *day);
-my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist);
-/* Character set-aware version of str_to_time() */
-bool str_to_time(CHARSET_INFO *cs, const char *str,uint length,
-                 MYSQL_TIME *l_time, int *warning);
-/* Character set-aware version of str_to_datetime() */
-timestamp_type str_to_datetime(CHARSET_INFO *cs,
-                               const char *str, uint length,
-                               MYSQL_TIME *l_time, uint flags, int *was_cut);
-bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str,uint length,
-                           MYSQL_TIME *l_time);
-timestamp_type str_to_datetime_with_warn(CHARSET_INFO *cs,
-                                         const char *str, uint length,
-                                         MYSQL_TIME *l_time, uint flags);
-void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
-void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
-
-void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
-                                  const char *str_val,
-				  uint str_length, timestamp_type time_type,
-                                  const char *field_name);
-
-bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
-bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
-                    longlong *seconds_out, long *microseconds_out);
-
-extern LEX_STRING interval_type_to_name[];
-
-
-bool parse_date_time_format(timestamp_type format_type, 
-                            const char *format, uint format_length,
-                            DATE_TIME_FORMAT *date_time_format);
-/* convenience wrapper */
-inline bool parse_date_time_format(timestamp_type format_type, 
-                                   DATE_TIME_FORMAT *date_time_format)
-{
-  return parse_date_time_format(format_type,
-                                date_time_format->format.str,
-                                date_time_format->format.length,
-                                date_time_format);
-}
-
-extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
-					       const char *format_str,
-					       uint format_length);
-extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
-					       DATE_TIME_FORMAT *format);
-const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
-				     timestamp_type type);
-extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
-			   timestamp_type type, String *str);
-void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
-                   String *str);
-void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
-               String *str);
-void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
-               String *str);
-int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
-longlong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
-                            Item *warn_item, bool *is_null);
-
-int test_if_number(char *str,int *res,bool allow_wildcards);
-void change_byte(uchar *,uint,char,char);
-ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
-		 uint s_length, SQL_SELECT *select,
-		 ha_rows max_rows, bool sort_positions,
-                 ha_rows *examined_rows);
-void filesort_free_buffers(TABLE *table, bool full);
-void change_double_for_sort(double nr,uchar *to);
-double my_double_round(double value, longlong dec, bool dec_unsigned,
-                       bool truncate);
-int get_quick_record(SQL_SELECT *select);
-
-int calc_weekday(long daynr,bool sunday_first_day_of_week);
-uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
-void find_date(char *pos,uint *vek,uint flag);
-TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
-TYPELIB *typelib(MEM_ROOT *mem_root, List &strings);
-ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
-ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
-		     const char *newname);
-ulong next_io_size(ulong pos);
-void append_unescaped(String *res, const char *pos, uint length);
-int create_frm(THD *thd, const char *name, const char *db, const char *table,
-               uint reclength, uchar *fileinfo,
-	       HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
-void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
-int rename_file_ext(const char * from,const char * to,const char * ext);
-bool check_db_name(LEX_STRING *db);
-bool check_column_name(const char *name);
-bool check_table_name(const char *name, uint length);
-char *get_field(MEM_ROOT *mem, Field *field);
-bool get_field(MEM_ROOT *mem, Field *field, class String *res);
-int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
-char *fn_rext(char *name);
-bool check_duplicate_warning(THD *thd, char *msg, ulong length);
-
-/* Conversion functions */
-#endif /* MYSQL_SERVER */
-#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
-uint strconvert(CHARSET_INFO *from_cs, const char *from,
-                CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
-/* depends on errmsg.txt Database `db`, Table `t` ... */
-#define EXPLAIN_FILENAME_MAX_EXTRA_LENGTH 63
-enum enum_explain_filename_mode
-{
-  EXPLAIN_ALL_VERBOSE= 0,
-  EXPLAIN_PARTITIONS_VERBOSE,
-  EXPLAIN_PARTITIONS_AS_COMMENT
-};
-uint explain_filename(THD* thd, const char *from, char *to, uint to_length,
-                      enum_explain_filename_mode explain_mode);
-uint filename_to_tablename(const char *from, char *to, uint to_length);
-uint tablename_to_filename(const char *from, char *to, uint to_length);
-uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length);
-#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
-#ifdef MYSQL_SERVER
-uint build_table_filename(char *buff, size_t bufflen, const char *db,
-                          const char *table, const char *ext, uint flags);
-const char *get_canonical_filename(handler *file, const char *path,
-                                   char *tmp_path);
-
-#define MYSQL50_TABLE_NAME_PREFIX         "#mysql50#"
-#define MYSQL50_TABLE_NAME_PREFIX_LENGTH  9
-
-uint build_table_shadow_filename(char *buff, size_t bufflen, 
-                                 ALTER_PARTITION_PARAM_TYPE *lpt);
-/* Flags for conversion functions. */
-#define FN_FROM_IS_TMP  (1 << 0)
-#define FN_TO_IS_TMP    (1 << 1)
-#define FN_IS_TMP       (FN_FROM_IS_TMP | FN_TO_IS_TMP)
-#define NO_FRM_RENAME   (1 << 2)
-#define FRM_ONLY        (1 << 3)
-
-/* from hostname.cc */
-bool ip_to_hostname(struct sockaddr_storage *ip_storage,
-                    const char *ip_string,
-                    char **hostname, uint *connect_errors);
-void inc_host_errors(const char *ip_string);
-void reset_host_errors(const char *ip_string);
-bool hostname_cache_init();
-void hostname_cache_free();
-void hostname_cache_refresh(void);
-
-/* sql_cache.cc */
-extern bool sql_cache_init();
-extern void sql_cache_free();
-extern int sql_cache_hit(THD *thd, char *inBuf, uint length);
-
-/* item_func.cc */
-Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name,
-		     LEX_STRING component);
-int get_var_with_binlog(THD *thd, enum_sql_command sql_command,
-                        LEX_STRING &name, user_var_entry **out_entry);
-/* log.cc */
-bool flush_error_log(void);
-
-/* sql_list.cc */
-void free_list(I_List  *list);
-void free_list(I_List  *list);
-
-/* sql_yacc.cc */
-#ifndef DBUG_OFF
-extern void turn_parser_debug_on();
-#endif
-
-/* frm_crypt.cc */
-#ifdef HAVE_CRYPTED_FRM
-SQL_CRYPT *get_crypt_for_frm(void);
-#endif
-
-/* password.c */
-extern "C" void my_make_scrambled_password_323(char *to, const char *password,
-                                               size_t pass_len);
-extern "C" void my_make_scrambled_password(char *to, const char *password,
-                                           size_t pass_len);
-
-#include "sql_view.h"
-
-/* Some inline functions for more speed */
-
-inline bool add_item_to_list(THD *thd, Item *item)
-{
-  return thd->lex->current_select->add_item_to_list(thd, item);
-}
-
-inline bool add_value_to_list(THD *thd, Item *value)
-{
-  return thd->lex->value_list.push_back(value);
-}
-
-inline bool add_order_to_list(THD *thd, Item *item, bool asc)
-{
-  return thd->lex->current_select->add_order_to_list(thd, item, asc);
-}
-
-inline bool add_group_to_list(THD *thd, Item *item, bool asc)
-{
-  return thd->lex->current_select->add_group_to_list(thd, item, asc);
-}
-
-inline void mark_as_null_row(TABLE *table)
-{
-  table->null_row=1;
-  table->status|=STATUS_NULL_ROW;
-  bfill(table->null_flags,table->s->null_bytes,255);
-}
-
-inline void table_case_convert(char * name, uint length)
-{
-  if (lower_case_table_names)
-    files_charset_info->cset->casedn(files_charset_info,
-                                     name, length, name, length);
-}
-
-inline const char *table_case_name(HA_CREATE_INFO *info, const char *name)
-{
-  return ((lower_case_table_names == 2 && info->alias) ? info->alias : name);
-}
-
-inline ulong sql_rnd_with_mutex()
-{
-  mysql_mutex_lock(&LOCK_thread_count);
-  ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
-  mysql_mutex_unlock(&LOCK_thread_count);
-  return tmp;
-}
-
-Comp_creator *comp_eq_creator(bool invert);
-Comp_creator *comp_ge_creator(bool invert);
-Comp_creator *comp_gt_creator(bool invert);
-Comp_creator *comp_le_creator(bool invert);
-Comp_creator *comp_lt_creator(bool invert);
-Comp_creator *comp_ne_creator(bool invert);
-
-Item * all_any_subquery_creator(Item *left_expr,
-				chooser_compare_func_creator cmp,
-				bool all,
-				SELECT_LEX *select_lex);
-
-/**
-  clean/setup table fields and map.
-
-  @param table        TABLE structure pointer (which should be setup)
-  @param table_list   TABLE_LIST structure pointer (owner of TABLE)
-  @param tablenr     table number
-*/
-
-
-inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
-{
-  table->used_fields= 0;
-  table->const_table= 0;
-  table->null_row= 0;
-  table->status= STATUS_NO_RECORD;
-  table->maybe_null= table_list->outer_join;
-  TABLE_LIST *embedding= table_list->embedding;
-  while (!table->maybe_null && embedding)
-  {
-    table->maybe_null= embedding->outer_join;
-    embedding= embedding->embedding;
-  }
-  table->tablenr= tablenr;
-  table->map= (table_map) 1 << tablenr;
-  table->force_index= table_list->force_index;
-  table->force_index_order= table->force_index_group= 0;
-  table->covering_keys= table->s->keys_for_keyread;
-  table->merge_keys.clear_all();
-}
-
-
-/**
-  convert a hex digit into number.
-*/
-
-inline int hexchar_to_int(char c)
-{
-  if (c <= '9' && c >= '0')
-    return c-'0';
-  c|=32;
-  if (c <= 'f' && c >= 'a')
-    return c-'a'+10;
-  return -1;
-}
-
-/**
-  return true if the table was created explicitly.
-*/
-inline bool is_user_table(TABLE * table)
-{
-  const char *name= table->s->table_name.str;
-  return strncmp(name, tmp_file_prefix, tmp_file_prefix_length);
-}
-
-/*
-  Some functions that are different in the embedded library and the normal
-  server
-*/
-
-#ifndef EMBEDDED_LIBRARY
-extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
-void kill_delayed_threads(void);
-#else
-extern "C" void unireg_clear(int exit_code);
-#define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0)
-inline void kill_delayed_threads(void) {}
-#endif
-
-bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
-
-/* This must match the path length limit in the ER_NOT_RW_DIR error msg. */
-#define ER_NOT_RW_DIR_PATHSIZE 200
-bool is_usable_directory(THD *thd, const char *varname,
-                         const char *path, const char *prefix);
-
-/* Used by handlers to store things in schema tables */
-#define IS_FILES_FILE_ID              0
-#define IS_FILES_FILE_NAME            1
-#define IS_FILES_FILE_TYPE            2
-#define IS_FILES_TABLESPACE_NAME      3
-#define IS_FILES_TABLE_CATALOG        4
-#define IS_FILES_TABLE_SCHEMA         5
-#define IS_FILES_TABLE_NAME           6
-#define IS_FILES_LOGFILE_GROUP_NAME   7
-#define IS_FILES_LOGFILE_GROUP_NUMBER 8
-#define IS_FILES_ENGINE               9
-#define IS_FILES_FULLTEXT_KEYS       10
-#define IS_FILES_DELETED_ROWS        11
-#define IS_FILES_UPDATE_COUNT        12
-#define IS_FILES_FREE_EXTENTS        13
-#define IS_FILES_TOTAL_EXTENTS       14
-#define IS_FILES_EXTENT_SIZE         15
-#define IS_FILES_INITIAL_SIZE        16
-#define IS_FILES_MAXIMUM_SIZE        17
-#define IS_FILES_AUTOEXTEND_SIZE     18
-#define IS_FILES_CREATION_TIME       19
-#define IS_FILES_LAST_UPDATE_TIME    20
-#define IS_FILES_LAST_ACCESS_TIME    21
-#define IS_FILES_RECOVER_TIME        22
-#define IS_FILES_TRANSACTION_COUNTER 23
-#define IS_FILES_VERSION             24
-#define IS_FILES_ROW_FORMAT          25
-#define IS_FILES_TABLE_ROWS          26
-#define IS_FILES_AVG_ROW_LENGTH      27
-#define IS_FILES_DATA_LENGTH         28
-#define IS_FILES_MAX_DATA_LENGTH     29
-#define IS_FILES_INDEX_LENGTH        30
-#define IS_FILES_DATA_FREE           31
-#define IS_FILES_CREATE_TIME         32
-#define IS_FILES_UPDATE_TIME         33
-#define IS_FILES_CHECK_TIME          34
-#define IS_FILES_CHECKSUM            35
-#define IS_FILES_STATUS              36
-#define IS_FILES_EXTRA               37
-
-#define IS_TABLESPACES_TABLESPACE_NAME    0
-#define IS_TABLESPACES_ENGINE             1
-#define IS_TABLESPACES_TABLESPACE_TYPE    2
-#define IS_TABLESPACES_LOGFILE_GROUP_NAME 3
-#define IS_TABLESPACES_EXTENT_SIZE        4
-#define IS_TABLESPACES_AUTOEXTEND_SIZE    5
-#define IS_TABLESPACES_MAXIMUM_SIZE       6
-#define IS_TABLESPACES_NODEGROUP_ID       7
-#define IS_TABLESPACES_TABLESPACE_COMMENT 8
-
-void init_fill_schema_files_row(TABLE* table);
-bool schema_table_store_record(THD *thd, TABLE *table);
-
-/* sql/item_create.cc */
-int item_create_init();
-void item_create_cleanup();
-
-bool show_create_trigger(THD *thd, const sp_name *trg_name);
-
-inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
-{
-  lex_str->str= (char *) c_str;
-  lex_str->length= strlen(c_str);
-}
-
-bool load_charset(MEM_ROOT *mem_root,
-                  Field *field,
-                  CHARSET_INFO *dflt_cs,
-                  CHARSET_INFO **cs);
-
-bool load_collation(MEM_ROOT *mem_root,
-                    Field *field,
-                    CHARSET_INFO *dflt_cl,
-                    CHARSET_INFO **cl);
-
-#define LONG_TIMEOUT ((ulong) 3600L*24L*365L)
-
-/**
-  only options that need special treatment in get_one_option() deserve
-  to be listed below
-*/
-enum options_mysqld
-{
-  OPT_to_set_the_start_number=256,
-  OPT_BIND_ADDRESS,
-  OPT_BINLOG_DO_DB,
-  OPT_BINLOG_FORMAT,
-  OPT_BINLOG_IGNORE_DB,
-  OPT_BIN_LOG,
-  OPT_BOOTSTRAP,
-  OPT_CONSOLE,
-  OPT_DEBUG_SYNC_TIMEOUT,
-  OPT_ISAM_LOG,
-  OPT_KEY_BUFFER_SIZE,
-  OPT_KEY_CACHE_AGE_THRESHOLD,
-  OPT_KEY_CACHE_BLOCK_SIZE,
-  OPT_KEY_CACHE_DIVISION_LIMIT,
-  OPT_LOWER_CASE_TABLE_NAMES,
-  OPT_ONE_THREAD,
-  OPT_POOL_OF_THREADS,
-  OPT_REPLICATE_DO_DB,
-  OPT_REPLICATE_DO_TABLE,
-  OPT_REPLICATE_IGNORE_DB,
-  OPT_REPLICATE_IGNORE_TABLE,
-  OPT_REPLICATE_REWRITE_DB,
-  OPT_REPLICATE_WILD_DO_TABLE,
-  OPT_REPLICATE_WILD_IGNORE_TABLE,
-  OPT_SAFE,
-  OPT_SERVER_ID,
-  OPT_SKIP_HOST_CACHE,
-  OPT_SKIP_NEW,
-  OPT_SKIP_PRIOR,
-  OPT_SKIP_RESOLVE,
-  OPT_SKIP_STACK_TRACE,
-  OPT_SLOW_QUERY_LOG,
-  OPT_SSL_CA,
-  OPT_SSL_CAPATH,
-  OPT_SSL_CERT,
-  OPT_SSL_CIPHER,
-  OPT_SSL_KEY,
-  OPT_WANT_CORE,
-  OPT_ENGINE_CONDITION_PUSHDOWN,
-  OPT_LOG_ERROR
-};
-
-#endif /* MYSQL_SERVER */
-extern "C" int test_if_data_home_dir(const char *dir);
-
-#endif /* MYSQL_CLIENT */
-
-#ifdef MYSQL_SERVER
-#ifdef HAVE_PSI_INTERFACE
-#ifdef HAVE_MMAP
-extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active,
-       key_LOCK_pool;
-#endif /* HAVE_MMAP */
-
-#ifdef HAVE_OPENSSL
-extern PSI_mutex_key key_LOCK_des_key_file;
-#endif
-
-extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
-  key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
-  key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
-  key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
-  key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
-  key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file,
-  key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
-  key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
-  key_LOCK_table_share, key_LOCK_thd_data,
-  key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
-  key_master_info_data_lock, key_master_info_run_lock,
-  key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
-  key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
-  key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, key_LOCK_error_messages,
-  key_LOCK_thread_count;
-
-extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
-  key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
-  key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
-
-#ifdef HAVE_MMAP
-extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
-#endif /* HAVE_MMAP */
-
-extern PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
-  key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager,
-  key_COND_refresh, key_COND_rpl_status, key_COND_server_started,
-  key_delayed_insert_cond, key_delayed_insert_cond_client,
-  key_item_func_sleep_cond, key_master_info_data_cond,
-  key_master_info_start_cond, key_master_info_stop_cond,
-  key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
-  key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
-  key_TABLE_SHARE_cond, key_user_level_lock_cond,
-  key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache;
-
-extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
-  key_thread_handle_manager, key_thread_kill_server, key_thread_main,
-  key_thread_one_connection, key_thread_signal_hand;
-
-#ifdef HAVE_MMAP
-extern PSI_file_key key_file_map;
-#endif /* HAVE_MMAP */
-
-extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
-  key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
-  key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
-  key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
-  key_file_master_info, key_file_misc, key_file_MYSQL_LOG, key_file_partition,
-  key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
-  key_file_trg, key_file_trn, key_file_init;
-
-void init_server_psi_keys();
-#endif /* HAVE_PSI_INTERFACE */
-#endif /* MYSQL_SERVER */
-
-
-#endif /* MYSQL_PRIV_H */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 22aa91e7fc4..a2c1db09aa1 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -13,7 +13,43 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "my_global.h"
+#include 
+#ifndef __WIN__
+#include         // getservbyname, servent
+#endif
+#include "sql_parse.h"    // test_if_data_home_dir
+#include "sql_cache.h"    // query_cache, query_cache_*
+#include "sql_locale.h"   // MY_LOCALES, my_locales, my_locale_by_name
+#include "sql_show.h"     // free_status_vars, add_status_vars,
+                          // reset_status_vars
+#include "strfunc.h"      // find_set_from_flags
+#include "parse_file.h"   // File_parser_dummy_hook
+#include "sql_db.h"       // my_database_names_free,
+                          // my_database_names_init
+#include "sql_table.h"    // release_ddl_log, execute_ddl_log_recovery
+#include "sql_connect.h"  // free_max_user_conn, init_max_user_conn,
+                          // handle_one_connection
+#include "sql_time.h"     // known_date_time_formats,
+                          // get_date_time_format_str,
+                          // date_time_format_make
+#include "tztime.h"       // my_tz_free, my_tz_init, my_tz_SYSTEM
+#include "hostname.h"     // hostname_cache_free, hostname_cache_init
+#include "sql_acl.h"      // acl_free, grant_free, acl_init,
+                          // grant_init
+#include "sql_base.h"     // table_def_free, table_def_init,
+                          // cached_open_tables,
+                          // cached_table_definitions
+#include "sql_test.h"     // mysql_print_status
+#include "item_create.h"  // item_create_cleanup, item_create_init
+#include "sql_servers.h"  // servers_free, servers_init
+#include "init.h"         // unireg_init
+#include "derror.h"       // init_errmessage
+#include "derror.h"       // init_errmessage
+#include "des_key_file.h" // load_des_key_file
+#include "sql_manager.h"  // stop_handle_manager, start_handle_manager
 #include 
 #include 
 #include 
@@ -7653,7 +7689,7 @@ static char *get_relative_path(const char *path)
     1 if len(path) > FN_REFLEN
 */
 
-bool
+static bool
 fn_format_relative_to_data_home(char * to, const char *name,
 				const char *dir, const char *extension)
 {
diff --git a/sql/mysqld.h b/sql/mysqld.h
new file mode 100644
index 00000000000..c57d92733ed
--- /dev/null
+++ b/sql/mysqld.h
@@ -0,0 +1,510 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef MYSQLD_INCLUDED
+#define MYSQLD_INCLUDED
+
+#include "my_global.h" /* MYSQL_PLUGIN_IMPORT, FN_REFLEN, FN_EXTLEN */
+#include "sql_bitmap.h"                         /* Bitmap */
+#include "my_decimal.h"                         /* my_decimal */
+#include "mysql_com.h"                     /* SERVER_VERSION_LENGTH */
+#include "my_atomic.h"                     /* my_atomic_rwlock_t */
+#include "mysql/psi/mysql_file.h"          /* MYSQL_FILE */
+#include "sql_list.h"                      /* I_List */
+
+class THD;
+class handlerton;
+class Time_zone;
+
+class scheduler_functions;
+
+typedef struct st_mysql_const_lex_string LEX_CSTRING;
+typedef struct st_mysql_show_var SHOW_VAR;
+
+/*
+  This forward declaration is used from C files where the real
+  definition is included before.  Since C does not allow repeated
+  typedef declarations, even when identical, the definition may not be
+  repeated.
+*/
+#ifndef CHARSET_INFO_DEFINED
+typedef struct charset_info_st CHARSET_INFO;
+#endif  /* CHARSET_INFO_DEFINED */
+
+#if MAX_INDEXES <= 64
+typedef Bitmap<64>  key_map;          /* Used for finding keys */
+#else
+typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
+#endif
+
+	/* Bits from testflag */
+#define TEST_PRINT_CACHED_TABLES 1
+#define TEST_NO_KEY_GROUP	 2
+#define TEST_MIT_THREAD		4
+#define TEST_BLOCKING		8
+#define TEST_KEEP_TMP_TABLES	16
+#define TEST_READCHECK		64	/**< Force use of readcheck */
+#define TEST_NO_EXTRA		128
+#define TEST_CORE_ON_SIGNAL	256	/**< Give core if signal */
+#define TEST_NO_STACKTRACE	512
+#define TEST_SIGINT		1024	/**< Allow sigint on threads */
+#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in
+                                           some places */
+/* Function prototypes */
+void kill_mysql(void);
+void close_connection(THD *thd, uint errcode, bool lock);
+void handle_connection_in_main_thread(THD *thd);
+void create_thread_to_handle_connection(THD *thd);
+void unlink_thd(THD *thd);
+bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
+void flush_thread_cache();
+void refresh_status(THD *thd);
+
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *files_charset_info ;
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *national_charset_info;
+extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *table_alias_charset;
+
+extern TYPELIB log_output_typelib;
+extern const char *log_output_names[];
+
+/**
+  Character set of the buildin error messages loaded from errmsg.sys.
+*/
+extern CHARSET_INFO *error_message_charset_info;
+
+extern CHARSET_INFO *character_set_filesystem;
+
+extern MY_BITMAP temp_pool;
+extern bool opt_large_files, server_id_supplied;
+extern bool opt_update_log, opt_bin_log, opt_error_log;
+extern my_bool opt_log, opt_slow_log;
+extern my_bool opt_backup_history_log;
+extern my_bool opt_backup_progress_log;
+extern ulonglong log_output_options;
+extern ulong log_backup_output_options;
+extern my_bool opt_log_queries_not_using_indexes;
+extern bool opt_disable_networking, opt_skip_show_db;
+extern bool opt_ignore_builtin_innodb;
+extern my_bool opt_character_set_client_handshake;
+extern bool volatile abort_loop;
+extern bool in_bootstrap;
+extern uint volatile thread_count, global_read_lock;
+extern uint connection_count;
+extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
+extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
+extern my_bool opt_slave_compressed_protocol, use_temp_pool;
+extern uint slave_exec_mode_options;
+extern ulonglong slave_type_conversions_options;
+extern my_bool opt_readonly, lower_case_file_system;
+extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
+extern my_bool opt_secure_auth;
+extern char* opt_secure_file_priv;
+extern char* opt_secure_backup_file_priv;
+extern size_t opt_secure_backup_file_priv_len;
+extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
+extern my_bool sp_automatic_privileges, opt_noacl;
+extern my_bool opt_old_style_user_limits, trust_function_creators;
+extern uint opt_crash_binlog_innodb;
+extern char *shared_memory_base_name, *mysqld_unix_port;
+extern my_bool opt_enable_shared_memory;
+extern char *default_tz_name;
+extern Time_zone *default_tz;
+extern char *default_storage_engine;
+extern bool opt_endinfo, using_udf_functions;
+extern my_bool locked_in_memory;
+extern bool opt_using_transactions;
+extern ulong current_pid;
+extern ulong expire_logs_days;
+extern my_bool relay_log_recovery;
+extern uint sync_binlog_period, sync_relaylog_period, 
+            sync_relayloginfo_period, sync_masterinfo_period;
+extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
+extern ulong tc_log_page_waits;
+extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
+extern my_bool relay_log_recovery;
+extern uint test_flags,select_errors,ha_open_options;
+extern uint protocol_version, mysqld_port, dropping_tables;
+extern uint delay_key_write_options;
+extern char *opt_logname, *opt_slow_logname;
+extern char *opt_backup_history_logname, *opt_backup_progress_logname,
+            *opt_backup_settings_name;
+extern const char *log_output_str;
+extern const char *log_backup_output_str;
+extern char *mysql_home_ptr, *pidfile_name_ptr;
+extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
+extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
+extern char default_logfile_name[FN_REFLEN];
+extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
+extern const double log_10[309];
+extern ulonglong keybuff_size;
+extern ulonglong thd_startup_options;
+extern ulong thread_id;
+extern ulong binlog_cache_use, binlog_cache_disk_use;
+extern ulong aborted_threads,aborted_connects;
+extern ulong delayed_insert_timeout;
+extern ulong delayed_insert_limit, delayed_queue_size;
+extern ulong delayed_insert_threads, delayed_insert_writes;
+extern ulong delayed_rows_in_use,delayed_insert_errors;
+extern ulong slave_open_temp_tables;
+extern ulong query_cache_size, query_cache_min_res_unit;
+extern ulong slow_launch_threads, slow_launch_time;
+extern ulong table_cache_size, table_def_size;
+extern MYSQL_PLUGIN_IMPORT ulong max_connections;
+extern ulong max_connect_errors, connect_timeout;
+extern my_bool slave_allow_batching;
+extern my_bool allow_slave_start;
+extern LEX_CSTRING reason_slave_blocked;
+extern ulong slave_trans_retries;
+extern uint  slave_net_timeout;
+extern uint max_user_connections;
+extern ulong what_to_log,flush_time;
+extern ulong query_buff_size;
+extern ulong max_prepared_stmt_count, prepared_stmt_count;
+extern ulong binlog_cache_size, open_files_limit;
+extern ulonglong max_binlog_cache_size;
+extern ulong max_binlog_size, max_relay_log_size;
+extern ulong opt_binlog_rows_event_max_size;
+extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
+extern ulong back_log;
+extern char language[FN_REFLEN];
+extern ulong server_id, concurrency;
+extern time_t server_start_time, flush_status_time;
+extern char *opt_mysql_tmpdir, mysql_charsets_dir[];
+extern int mysql_unpacked_real_data_home_len;
+extern MY_TMPDIR mysql_tmpdir_list;
+extern const char *first_keyword, *delayed_user, *binary_keyword;
+extern MYSQL_PLUGIN_IMPORT const char  *my_localhost;
+extern MYSQL_PLUGIN_IMPORT const char **errmesg;			/* Error messages */
+extern const char *myisam_recover_options_str;
+extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
+extern SHOW_VAR status_vars[];
+extern struct system_variables max_system_variables;
+extern struct system_status_var global_status_var;
+extern struct rand_struct sql_rand;
+extern const char *opt_date_time_formats[];
+extern handlerton *partition_hton;
+extern handlerton *myisam_hton;
+extern handlerton *heap_hton;
+extern const char *load_default_groups[];
+extern struct my_option my_long_options[];
+extern int mysqld_server_started;
+extern int orig_argc;
+extern char **orig_argv;
+extern pthread_attr_t connection_attrib;
+extern MYSQL_FILE *bootstrap_file;
+extern my_bool old_mode;
+extern LEX_STRING opt_init_connect, opt_init_slave;
+extern int bootstrap_error;
+extern FILE *stderror_file;
+extern I_List threads;
+extern char err_shared_dir[];
+extern scheduler_functions thread_scheduler;
+extern TYPELIB thread_handling_typelib;
+extern my_decimal decimal_zero;
+
+extern pthread_key(MEM_ROOT**,THR_MALLOC);
+
+#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_MMAP
+extern PSI_mutex_key key_PAGE_lock, key_LOCK_sync, key_LOCK_active,
+       key_LOCK_pool;
+#endif /* HAVE_MMAP */
+
+#ifdef HAVE_OPENSSL
+extern PSI_mutex_key key_LOCK_des_key_file;
+#endif
+
+extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
+  key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
+  key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
+  key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
+  key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
+  key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file,
+  key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count,
+  key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
+  key_LOCK_table_share, key_LOCK_thd_data,
+  key_LOCK_user_conn, key_LOCK_uuid_generator, key_LOG_LOCK_log,
+  key_master_info_data_lock, key_master_info_run_lock,
+  key_mutex_slave_reporting_capability_err_lock, key_relay_log_info_data_lock,
+  key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
+  key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data, key_LOCK_error_messages,
+  key_LOCK_thread_count;
+
+extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
+  key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
+  key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
+
+#ifdef HAVE_MMAP
+extern PSI_cond_key key_PAGE_cond, key_COND_active, key_COND_pool;
+#endif /* HAVE_MMAP */
+
+extern PSI_cond_key key_BINLOG_COND_prep_xids, key_BINLOG_update_cond,
+  key_COND_cache_status_changed, key_COND_global_read_lock, key_COND_manager,
+  key_COND_refresh, key_COND_rpl_status, key_COND_server_started,
+  key_delayed_insert_cond, key_delayed_insert_cond_client,
+  key_item_func_sleep_cond, key_master_info_data_cond,
+  key_master_info_start_cond, key_master_info_stop_cond,
+  key_relay_log_info_data_cond, key_relay_log_info_log_space_cond,
+  key_relay_log_info_start_cond, key_relay_log_info_stop_cond,
+  key_TABLE_SHARE_cond, key_user_level_lock_cond,
+  key_COND_thread_count, key_COND_thread_cache, key_COND_flush_thread_cache;
+
+extern PSI_thread_key key_thread_bootstrap, key_thread_delayed_insert,
+  key_thread_handle_manager, key_thread_kill_server, key_thread_main,
+  key_thread_one_connection, key_thread_signal_hand;
+
+#ifdef HAVE_MMAP
+extern PSI_file_key key_file_map;
+#endif /* HAVE_MMAP */
+
+extern PSI_file_key key_file_binlog, key_file_binlog_index, key_file_casetest,
+  key_file_dbopt, key_file_des_key_file, key_file_ERRMSG, key_select_to_file,
+  key_file_fileparser, key_file_frm, key_file_global_ddl_log, key_file_load,
+  key_file_loadfile, key_file_log_event_data, key_file_log_event_info,
+  key_file_master_info, key_file_misc, key_file_MYSQL_LOG, key_file_partition,
+  key_file_pid, key_file_relay_log_info, key_file_send_file, key_file_tclog,
+  key_file_trg, key_file_trn, key_file_init;
+
+void init_server_psi_keys();
+#endif /* HAVE_PSI_INTERFACE */
+
+#ifndef __WIN__
+extern pthread_t signal_thread;
+#endif
+
+#ifdef HAVE_OPENSSL
+extern struct st_VioSSLFd * ssl_acceptor_fd;
+#endif /* HAVE_OPENSSL */
+
+/*
+  The following variables were under INNODB_COMPABILITY_HOOKS
+ */
+extern my_bool opt_large_pages;
+extern uint opt_large_page_size;
+extern char lc_messages_dir[FN_REFLEN];
+extern char *lc_messages_dir_ptr, *log_error_file_ptr;
+extern MYSQL_PLUGIN_IMPORT char reg_ext[FN_EXTLEN];
+extern MYSQL_PLUGIN_IMPORT uint reg_ext_length;
+extern MYSQL_PLUGIN_IMPORT uint lower_case_table_names;
+extern MYSQL_PLUGIN_IMPORT bool mysqld_embedded;
+extern ulong specialflag;
+extern uint mysql_data_home_len;
+extern uint mysql_real_data_home_len;
+extern const char *mysql_real_data_home_ptr;
+extern uint thread_handling;
+extern MYSQL_PLUGIN_IMPORT char  *mysql_data_home;
+extern char server_version[SERVER_VERSION_LENGTH];
+extern MYSQL_PLUGIN_IMPORT char mysql_real_data_home[];
+extern char mysql_unpacked_real_data_home[];
+extern MYSQL_PLUGIN_IMPORT struct system_variables global_system_variables;
+extern char default_logfile_name[FN_REFLEN];
+extern char err_shared_dir[];
+
+#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
+
+extern MYSQL_PLUGIN_IMPORT const key_map key_map_empty;
+extern MYSQL_PLUGIN_IMPORT key_map key_map_full;          /* Should be threaded as const */
+
+/*
+  Server mutex locks and condition variables.
+ */
+extern mysql_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
+       LOCK_mapped_file, LOCK_user_locks, LOCK_status,
+       LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator,
+       LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
+       LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
+       LOCK_global_system_variables, LOCK_user_conn,
+       LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
+extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count;
+#ifdef HAVE_OPENSSL
+extern mysql_mutex_t LOCK_des_key_file;
+#endif
+extern mysql_mutex_t LOCK_server_started;
+extern mysql_cond_t COND_server_started;
+extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
+extern mysql_rwlock_t LOCK_system_variables_hash;
+extern mysql_cond_t COND_thread_count;
+extern mysql_cond_t COND_refresh, COND_manager;
+extern mysql_cond_t COND_global_read_lock;
+extern int32 thread_running;
+extern my_atomic_rwlock_t thread_running_lock;
+
+extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
+            *opt_ssl_key;
+
+extern MYSQL_PLUGIN_IMPORT pthread_key(THD*, THR_THD);
+
+/**
+  only options that need special treatment in get_one_option() deserve
+  to be listed below
+*/
+enum options_mysqld
+{
+  OPT_to_set_the_start_number=256,
+  OPT_BIND_ADDRESS,
+  OPT_BINLOG_DO_DB,
+  OPT_BINLOG_FORMAT,
+  OPT_BINLOG_IGNORE_DB,
+  OPT_BIN_LOG,
+  OPT_BOOTSTRAP,
+  OPT_CONSOLE,
+  OPT_DEBUG_SYNC_TIMEOUT,
+  OPT_DELAY_KEY_WRITE_ALL,
+  OPT_ISAM_LOG,
+  OPT_KEY_BUFFER_SIZE,
+  OPT_KEY_CACHE_AGE_THRESHOLD,
+  OPT_KEY_CACHE_BLOCK_SIZE,
+  OPT_KEY_CACHE_DIVISION_LIMIT,
+  OPT_LOWER_CASE_TABLE_NAMES,
+  OPT_ONE_THREAD,
+  OPT_POOL_OF_THREADS,
+  OPT_REPLICATE_DO_DB,
+  OPT_REPLICATE_DO_TABLE,
+  OPT_REPLICATE_IGNORE_DB,
+  OPT_REPLICATE_IGNORE_TABLE,
+  OPT_REPLICATE_REWRITE_DB,
+  OPT_REPLICATE_WILD_DO_TABLE,
+  OPT_REPLICATE_WILD_IGNORE_TABLE,
+  OPT_SAFE,
+  OPT_SERVER_ID,
+  OPT_SKIP_HOST_CACHE,
+  OPT_SKIP_LOCK,
+  OPT_SKIP_NEW,
+  OPT_SKIP_PRIOR,
+  OPT_SKIP_RESOLVE,
+  OPT_SKIP_STACK_TRACE,
+  OPT_SKIP_SYMLINKS,
+  OPT_SLOW_QUERY_LOG,
+  OPT_SSL_CA,
+  OPT_SSL_CAPATH,
+  OPT_SSL_CERT,
+  OPT_SSL_CIPHER,
+  OPT_SSL_KEY,
+  OPT_UPDATE_LOG,
+  OPT_WANT_CORE,
+  OPT_ENGINE_CONDITION_PUSHDOWN,
+  OPT_LOG_ERROR
+};
+
+
+/**
+  Query type constants.
+
+  QT_ORDINARY -- ordinary SQL query.
+  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
+  character set introducers).
+*/
+enum enum_query_type
+{
+  QT_ORDINARY,
+  QT_IS
+};
+
+/* query_id */
+typedef int64 query_id_t;
+extern query_id_t global_query_id;
+extern my_atomic_rwlock_t global_query_id_lock;
+
+void unireg_end(void) __attribute__((noreturn));
+
+/* increment query_id and return it.  */
+inline query_id_t next_query_id()
+{
+  query_id_t id;
+  my_atomic_rwlock_wrlock(&global_query_id_lock);
+  id= my_atomic_add64(&global_query_id, 1);
+  my_atomic_rwlock_wrunlock(&global_query_id_lock);
+  return (id+1);
+}
+
+inline query_id_t get_query_id()
+{
+  query_id_t id;
+  my_atomic_rwlock_wrlock(&global_query_id_lock);
+  id= my_atomic_load64(&global_query_id);
+  my_atomic_rwlock_wrunlock(&global_query_id_lock);
+  return id;
+}
+
+
+/*
+  TODO: Replace this with an inline function.
+ */
+#ifndef EMBEDDED_LIBRARY
+extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
+#else
+extern "C" void unireg_clear(int exit_code);
+#define unireg_abort(exit_code) do { unireg_clear(exit_code); DBUG_RETURN(exit_code); } while(0)
+#endif
+
+inline void table_case_convert(char * name, uint length)
+{
+  if (lower_case_table_names)
+    files_charset_info->cset->casedn(files_charset_info,
+                                     name, length, name, length);
+}
+
+inline ulong sql_rnd_with_mutex()
+{
+  mysql_mutex_lock(&LOCK_thread_count);
+  ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
+  mysql_mutex_unlock(&LOCK_thread_count);
+  return tmp;
+}
+
+inline int32
+inc_thread_running()
+{
+  int32 num_thread_running;
+  my_atomic_rwlock_wrlock(&thread_running_lock);
+  num_thread_running= my_atomic_add32(&thread_running, 1);
+  my_atomic_rwlock_wrunlock(&thread_running_lock);
+  return (num_thread_running+1);
+}
+
+inline int32
+dec_thread_running()
+{
+  int32 num_thread_running;
+  my_atomic_rwlock_wrlock(&thread_running_lock);
+  num_thread_running= my_atomic_add32(&thread_running, -1);
+  my_atomic_rwlock_wrunlock(&thread_running_lock);
+  return (num_thread_running-1);
+}
+
+inline int32
+get_thread_running()
+{
+  int32 num_thread_running;
+  my_atomic_rwlock_wrlock(&thread_running_lock);
+  num_thread_running= my_atomic_load32(&thread_running);
+  my_atomic_rwlock_wrunlock(&thread_running_lock);
+  return num_thread_running;
+}
+
+#if defined(MYSQL_DYNAMIC_PLUGIN) && defined(_WIN32)
+extern "C" THD *_current_thd_noinline();
+#define _current_thd() _current_thd_noinline()
+#else
+extern pthread_key(THD*, THR_THD);
+inline THD *_current_thd(void)
+{
+  return my_pthread_getspecific_ptr(THD*,THR_THD);
+}
+#endif
+#define current_thd _current_thd()
+
+#endif /* MYSQLD_INCLUDED */
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 12cb1224064..fc8655ea2e7 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -39,7 +39,6 @@
  */
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -88,7 +87,7 @@ void sql_print_error(const char *format,...);
 #ifdef MYSQL_SERVER
 /*
   The following variables/functions should really not be declared
-  extern, but as it's hard to include mysql_priv.h here, we have to
+  extern, but as it's hard to include sql_priv.h here, we have to
   live with this for a while.
 */
 extern uint test_flags;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 5483ed237db..a46bfcf2d0e 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -65,7 +65,13 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "key.h"        // is_key_used, key_copy, key_cmp, key_restore
+#include "sql_parse.h"                          // check_stack_overrun
+#include "sql_partition.h"    // get_part_id_func, PARTITION_ITERATOR,
+                              // struct partition_info
+#include "sql_base.h"         // free_io_cache
+#include "records.h"          // init_read_record, end_read_record
 #include 
 #include "sql_select.h"
 
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 0bb2243080a..3b3b36f7689 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -23,6 +23,20 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "thr_malloc.h"                         /* sql_memdup */
+#include "records.h"                            /* READ_RECORD */
+#include "queues.h"                             /* QUEUE */
+/*
+  It is necessary to include set_var.h instead of item.h because there
+  are dependencies on include order for set_var.h and item.h. This
+  will be resolved later.
+*/
+#include "sql_class.h"                          // set_var.h: THD
+#include "set_var.h"                            /* Item */
+
+class JOIN;
+class Item_sum;
+
 typedef struct st_key_part {
   uint16           key,part;
   /* See KEY_PART_INFO for meaning of the next two: */
@@ -742,10 +756,15 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
                                              struct st_table_ref *ref,
                                              ha_rows records);
 uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit);
+SQL_SELECT *make_select(TABLE *head, table_map const_tables,
+			table_map read_tables, COND *conds,
+                        bool allow_null_cond,  int *error);
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
 bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond);
 void store_key_image_to_rec(Field *field, uchar *ptr, uint len);
 #endif
 
+extern String null_string;
+
 #endif
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 5384c165d65..fd2040a4979 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -47,7 +47,8 @@
   (assuming a index for column d of table t2 is defined)
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "key.h"                                // key_cmp_if_same
 #include "sql_select.h"
 
 static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, Field* field,
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index d94ab3d940d..cce0bb262e7 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -20,7 +20,10 @@
   Text .frm files management routines
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "parse_file.h"
+#include "unireg.h"                            // CREATE_MODE
+#include "sql_table.h"                        // build_table_filename
 #include 
 #include 
 #include 
diff --git a/sql/parse_file.h b/sql/parse_file.h
index 84647e45927..1833e90cadd 100644
--- a/sql/parse_file.h
+++ b/sql/parse_file.h
@@ -17,6 +17,14 @@
 #ifndef _PARSE_FILE_H_
 #define _PARSE_FILE_H_
 
+#include "my_global.h"                          // uchar
+#include "sql_string.h"                         // LEX_STRING
+#include "sql_list.h"                           // Sql_alloc
+
+class THD;
+
+typedef struct st_mem_root MEM_ROOT;
+
 #define PARSE_FILE_TIMESTAMPLENGTH 19
 
 enum file_opt_type {
diff --git a/sql/partition_element.h b/sql/partition_element.h
index 73f85ac275f..cefc32ecac4 100644
--- a/sql/partition_element.h
+++ b/sql/partition_element.h
@@ -16,6 +16,9 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
+#include "my_base.h"                            /* ha_rows */
+#include "handler.h"                            /* UNDEF_NODEGROUP */
+
 /**
  * An enum and a struct to handle partitioning and subpartitioning.
  */
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 65029a817de..f42a8ee2312 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -19,7 +19,13 @@
 #pragma implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+// Required to get server definitions for mysql/plugin.h right
+#include "sql_plugin.h"
+#include "sql_partition.h"     /* partition_info.h: LIST_PART_ENTRY */
+#include "partition_info.h"
+#include "sql_parse.h"                        // test_if_data_home_dir
+#include "sql_acl.h"                          // *_ACL
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
 #include "ha_partition.h"
diff --git a/sql/password.c b/sql/password.c
index 9204c660b77..b77cb618a46 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -58,6 +58,7 @@
 
 *****************************************************************************/
 
+#include 
 #include 
 #include 
 #include 
diff --git a/sql/procedure.cc b/sql/procedure.cc
index c993ba976ac..66e09a42cb4 100644
--- a/sql/procedure.cc
+++ b/sql/procedure.cc
@@ -20,7 +20,7 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "procedure.h"
 #include "sql_analyse.h"			// Includes procedure
 #ifdef USE_PROC_RANGE
diff --git a/sql/procedure.h b/sql/procedure.h
index 25b30ac593d..f34eb228f28 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -23,6 +23,14 @@
 #pragma interface				/* gcc class implementation */
 #endif
 
+/*
+  It is necessary to include set_var.h instead of item.h because there
+  are dependencies on include order for set_var.h and item.h. This
+  will be resolved later.
+*/
+#include "sql_class.h"                          /* select_result, set_var.h: THD */
+#include "set_var.h"                            /* Item */
+
 #define PROC_NO_SORT 1				/**< Bits in flags */
 #define PROC_GROUP   2				/**< proc must have group */
 
diff --git a/sql/protocol.cc b/sql/protocol.cc
index a8cf250689e..e036f255960 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -24,7 +24,10 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "protocol.h"
+#include "sql_class.h"                          // THD
 #include 
 
 static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
diff --git a/sql/protocol.h b/sql/protocol.h
index 142f7919d6f..f661c7663e5 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -21,8 +21,10 @@
 #endif
 
 #include "sql_error.h"
+#include "my_decimal.h"                         /* my_decimal */
 
 class i_string;
+class Field;
 class THD;
 class Item_param;
 typedef struct st_mysql_field MYSQL_FIELD;
diff --git a/sql/records.cc b/sql/records.cc
index c97ffa152dc..d85cb49e013 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -25,7 +25,11 @@
 */
 
 #include "records.h"
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "records.h"
+#include "filesort.h"            // filesort_free_buffers
+#include "opt_range.h"                          // SQL_SELECT
+#include "sql_class.h"                          // THD
 
 
 static int rr_quick(READ_RECORD *info);
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 29443eb6e65..cddf798aac0 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -23,15 +23,18 @@
   functions like register_slave()) are working.
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_parse.h"                          // check_access
 #ifdef HAVE_REPLICATION
 
 #include "repl_failsafe.h"
+#include "sql_acl.h"                            // REPL_SLAVE_ACL
 #include "sql_repl.h"
 #include "slave.h"
 #include "rpl_mi.h"
 #include "rpl_filter.h"
 #include "log_event.h"
+#include "sql_db.h"                             // mysql_create_db
 #include 
 
 #define SLAVE_LIST_CHUNK 128
diff --git a/sql/replication.h b/sql/replication.h
index 5e9c09adf31..1c83025e1d6 100644
--- a/sql/replication.h
+++ b/sql/replication.h
@@ -16,6 +16,8 @@
 #ifndef REPLICATION_H
 #define REPLICATION_H
 
+#include 
+
 typedef struct st_mysql MYSQL;
 
 #ifdef __cplusplus
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 392d8baf50e..63521c0398f 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -13,8 +13,11 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                      // REQUIRED by other includes
 #include "rpl_filter.h"
+#include "hash.h"                               // my_hash_free
+#include "table.h"                              // TABLE_LIST
 
 #define TABLE_RULE_HASH_SIZE   16
 #define TABLE_RULE_ARR_SIZE   16
diff --git a/sql/rpl_filter.h b/sql/rpl_filter.h
index ff7e4081bb1..27bbccbc009 100644
--- a/sql/rpl_filter.h
+++ b/sql/rpl_filter.h
@@ -17,6 +17,12 @@
 #define RPL_FILTER_H
 
 #include "mysql.h"
+#include "sql_list.h"                           /* I_List */
+#include "hash.h"                               /* HASH */
+
+class String;
+class TABLE_LIST;
+typedef struct st_dynamic_array DYNAMIC_ARRAY;
 
 typedef struct st_table_rule_ent
 {
diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc
index 5a406866513..9cb5391075d 100644
--- a/sql/rpl_handler.cc
+++ b/sql/rpl_handler.cc
@@ -13,7 +13,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 
 #include "rpl_mi.h"
 #include "sql_repl.h"
diff --git a/sql/rpl_handler.h b/sql/rpl_handler.h
index 4fb7b4e035b..bf207e53e2d 100644
--- a/sql/rpl_handler.h
+++ b/sql/rpl_handler.h
@@ -16,7 +16,7 @@
 #ifndef RPL_HANDLER_H
 #define RPL_HANDLER_H
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "rpl_mi.h"
 #include "rpl_rli.h"
 #include "sql_plugin.h"
diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc
index 08d81e10d59..0f636f5b2ab 100644
--- a/sql/rpl_injector.cc
+++ b/sql/rpl_injector.cc
@@ -13,9 +13,13 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
-#include "mysql_priv.h" 
+#include "sql_priv.h" 
+#include "unireg.h"                             // REQUIRED by later includes
 #include "rpl_injector.h"
 #include "transaction.h"
+#include "sql_parse.h"                          // begin_trans, end_trans, COMMIT
+#include "sql_base.h"                           // close_thread_tables
+#include "log_event.h"                          // Incident_log_event
 
 /*
   injector::transaction - member definitions
diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h
index a0c71fee099..36cb6aaa184 100644
--- a/sql/rpl_injector.h
+++ b/sql/rpl_injector.h
@@ -21,6 +21,7 @@
 #include 
 
 #include "rpl_constants.h"
+#include "table.h"                              /* TABLE */
 
 /* Forward declarations */
 class handler;
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 7dad340cfa6..10bf752e140 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -14,10 +14,11 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include  // For HAVE_REPLICATION
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include 
-
+#include "unireg.h"                             // REQUIRED by other includes
 #include "rpl_mi.h"
+#include "slave.h"                              // SLAVE_MAX_HEARTBEAT_PERIOD
 
 #ifdef HAVE_REPLICATION
 
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index c4ca5714306..c3734fdf59e 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -22,9 +22,9 @@
 #include "rpl_reporting.h"
 #include "my_sys.h"
 
+typedef struct st_mysql MYSQL;
 
 /*****************************************************************************
-
   Replication IO Thread
 
   Master_info contains:
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 9e1413d726d..ced5c0943dd 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -13,7 +13,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "rpl_rli.h"
 #include "rpl_record.h"
 #include "slave.h"                  // Need to pull in slave_print_msg
diff --git a/sql/rpl_record.h b/sql/rpl_record.h
index 6e8838f82b3..9b3829a435e 100644
--- a/sql/rpl_record.h
+++ b/sql/rpl_record.h
@@ -17,6 +17,11 @@
 #define RPL_RECORD_H
 
 #include 
+#include "my_global.h"                          /* uchar */
+
+class Relay_log_info;
+struct TABLE;
+typedef struct st_bitmap MY_BITMAP;
 
 #if !defined(MYSQL_CLIENT)
 size_t pack_row(TABLE* table, MY_BITMAP const* cols,
diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc
index ab4e993ce41..09d5bcacd62 100644
--- a/sql/rpl_record_old.cc
+++ b/sql/rpl_record_old.cc
@@ -1,7 +1,9 @@
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                      // REQUIRED by other includes
 #include "rpl_rli.h"
 #include "rpl_record_old.h"
+#include "log_event.h"                          // Log_event_type
 
 size_t
 pack_row_old(TABLE *table, MY_BITMAP const* cols,
diff --git a/sql/rpl_record_old.h b/sql/rpl_record_old.h
index bdaedd56741..71c0ccc17b9 100644
--- a/sql/rpl_record_old.h
+++ b/sql/rpl_record_old.h
@@ -16,6 +16,8 @@
 #ifndef RPL_RECORD_OLD_H
 #define RPL_RECORD_OLD_H
 
+#include "log_event.h"                          /* Log_event_type */
+
 #ifndef MYSQL_CLIENT
 size_t pack_row_old(TABLE *table, MY_BITMAP const* cols,
                     uchar *row_data, const uchar *record);
diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc
index ae9d100eeb4..051a3609019 100644
--- a/sql/rpl_reporting.cc
+++ b/sql/rpl_reporting.cc
@@ -14,8 +14,10 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "rpl_reporting.h"
+#include "log.h" // sql_print_error, sql_print_warning,
+                 // sql_print_information
 
 Slave_reporting_capability::Slave_reporting_capability(char const *thread_name)
   : m_thread_name(thread_name)
diff --git a/sql/rpl_reporting.h b/sql/rpl_reporting.h
index b8d9c049653..495c74170d2 100644
--- a/sql/rpl_reporting.h
+++ b/sql/rpl_reporting.h
@@ -1,7 +1,4 @@
-#ifndef RPL_REPORTING_H
-#define RPL_REPORTING_H
-
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -14,7 +11,12 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef RPL_REPORTING_H
+#define RPL_REPORTING_H
+
+#include "my_sys.h"                             /* loglevel */
 
 /**
    Maximum size of an error message from a slave thread.
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index e1c43771b32..8f070c51410 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -13,14 +13,19 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
-
+#include "sql_priv.h"
+#include "unireg.h"                             // HAVE_*
 #include "rpl_mi.h"
 #include "rpl_rli.h"
+#include "sql_base.h"                        // close_thread_tables
 #include     // For MY_STAT
 #include "sql_repl.h"  // For check_binlog_magic
+#include "log_event.h" // Format_description_log_event, Log_event,
+                       // FORMAT_DESCRIPTION_LOG_EVENT, ROTATE_EVENT,
+                       // PREFIX_SQL_LOAD
 #include "rpl_utility.h"
 #include "transaction.h"
+#include "sql_parse.h"                          // end_trans, ROLLBACK
 
 static int count_relay_log_space(Relay_log_info* rli);
 
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index b1ed75146a0..bf8381933c0 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -19,6 +19,8 @@
 #include "rpl_tblmap.h"
 #include "rpl_reporting.h"
 #include "rpl_utility.h"
+#include "log.h"                         /* LOG_INFO, MYSQL_BIN_LOG */
+#include "sql_class.h"                   /* THD */
 
 struct RPL_TABLE_LIST;
 class Master_info;
diff --git a/sql/rpl_tblmap.cc b/sql/rpl_tblmap.cc
index b04a3120a86..5a178ffde83 100644
--- a/sql/rpl_tblmap.cc
+++ b/sql/rpl_tblmap.cc
@@ -13,11 +13,15 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "my_global.h"                          // HAVE_REPLICATION
 
 #ifdef HAVE_REPLICATION
 
 #include "rpl_tblmap.h"
+#ifndef MYSQL_CLIENT
+#include "table.h"
+#endif
 
 #ifdef MYSQL_CLIENT
 #define MAYBE_TABLE_NAME(T) ("")
diff --git a/sql/rpl_tblmap.h b/sql/rpl_tblmap.h
index a6ec8bcbc9b..3d24a47d9ae 100644
--- a/sql/rpl_tblmap.h
+++ b/sql/rpl_tblmap.h
@@ -52,6 +52,8 @@ void free_table_map_log_event(TABLE *table);
   A dedicated MEM_ROOT needs to be used, see below.
 */
 
+#include "hash.h"                               /* HASH */
+
 class table_mapping {
 
 private:
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 8171d028326..0675e9b51ad 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -16,7 +16,9 @@
 #include "rpl_utility.h"
 
 #ifndef MYSQL_CLIENT
+#include "unireg.h"                      // REQUIRED by later includes
 #include "rpl_rli.h"
+#include "sql_select.h"
 
 /**
    Function to compare two size_t integers for their relative
diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h
index 4b9bf3be93f..cf28d2c8e29 100644
--- a/sql/rpl_utility.h
+++ b/sql/rpl_utility.h
@@ -20,7 +20,11 @@
 #error "Don't include this C++ header file from a non-C++ file!"
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "m_string.h"                           /* bzero, memcpy */
+#ifdef MYSQL_SERVER
+#include "table.h"                              /* TABLE_LIST */
+#endif
 #include "mysql_com.h"
 
 class Relay_log_info;
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index b308b84eb19..10009246428 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -21,7 +21,10 @@
 #pragma implementation
 #endif
 
-#include 
+#include 
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "scheduler.h"
+#include "sql_connect.h"         // init_new_connection_handler_thread
 
 /*
   'Dummy' functions to be used when we don't need any handling for a scheduler
diff --git a/sql/set_var.cc b/sql/set_var.cc
index a30fbdc1edd..3f30dcb7df8 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -19,9 +19,30 @@
 
 /* variable declarations are in sys_vars.cc now !!! */
 
-#include "mysql_priv.h"
+#include "sql_class.h"                   // set_var.h: session_var_ptr
+#include "set_var.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "mysqld.h"                             // lc_messages_dir
 #include "sys_vars_shared.h"
 #include "transaction.h"
+#include "sql_base.h"                           // close_thread_tables
+#include "sql_locale.h"                         // my_locale_by_number,
+                                                // my_locale_by_name
+#include "strfunc.h"      // find_set_from_flags, find_set
+#include "sql_parse.h"    // check_global_access
+#include "sql_table.h"  // reassign_keycache_tables
+#include "sql_time.h"   // date_time_format_copy,
+                        // date_time_format_make
+#include "derror.h"
+#include "tztime.h"     // my_tz_find, my_tz_SYSTEM, struct Time_zone
+#include "sql_acl.h"    // SUPER_ACL
+#include "sql_select.h" // free_underlaid_joins
+#include "sql_show.h"   // make_default_log_name
+#include "sql_view.h"   // updatable_views_with_limit_typelib
+#include "lock.h"                               // lock_global_read_lock,
+                                                // make_global_read_lock_block_commit,
+                                                // unlock_global_read_lock
 
 static HASH system_variable_hash;
 static PolyLock_mutex PLock_global_system_variables(&LOCK_global_system_variables);
diff --git a/sql/set_var.h b/sql/set_var.h
index 4a212d3b685..1b415567659 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -30,6 +30,10 @@ class sys_var;
 class set_var;
 class sys_var_pluginvar;
 class PolyLock;
+class Item_func_set_user_var;
+
+// This include needs to be here since item.h requires enum_var_type :-P
+#include "item.h"                          /* Item */
 
 extern TYPELIB bool_typelib;
 
@@ -165,6 +169,9 @@ protected:
   { return ((uchar*)&global_system_variables) + offset; }
 };
 
+#include "log.h"                           /* binlog_format_typelib */
+#include "sql_plugin.h"                    /* SHOW_HA_ROWS, SHOW_MY_BOOL */
+
 /****************************************************************************
   Classes for parsing of the SET command
 ****************************************************************************/
@@ -277,6 +284,18 @@ public:
   int update(THD *thd);
 };
 
+
+/* optional things, have_* variables */
+extern SHOW_COMP_OPTION have_csv, have_innodb;
+extern SHOW_COMP_OPTION have_ndbcluster, have_partitioning;
+extern SHOW_COMP_OPTION have_profiling;
+
+extern SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen;
+extern SHOW_COMP_OPTION have_query_cache;
+extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
+extern SHOW_COMP_OPTION have_crypt;
+extern SHOW_COMP_OPTION have_compress;
+
 /*
   Prototypes for helper functions
 */
diff --git a/sql/slave.cc b/sql/slave.cc
index b0bb1d5882b..e23763696df 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -24,11 +24,11 @@
   replication slave.
 */
 
-#include "mysql_priv.h"
-
-#include 
-#include 
+#include "sql_priv.h"
+#include "my_global.h"
 #include "slave.h"
+#include "sql_parse.h"                         // execute_init_command
+#include "sql_table.h"                         // mysql_rm_table
 #include "rpl_mi.h"
 #include "rpl_rli.h"
 #include "sql_repl.h"
@@ -42,6 +42,15 @@
 #include 
 #include 
 #include "rpl_handler.h"
+#include 
+#include 
+#include 
+
+#include "sql_base.h"                           // close_thread_tables
+#include "tztime.h"                             // struct Time_zone
+#include "log_event.h"                          // Rotate_log_event,
+                                                // Create_file_log_event,
+                                                // Format_description_log_event
 
 #ifdef HAVE_REPLICATION
 
diff --git a/sql/slave.h b/sql/slave.h
index f01eccf09f4..4073c90b612 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -210,6 +210,8 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli);
 
 pthread_handler_t handle_slave_io(void *arg);
 pthread_handler_t handle_slave_sql(void *arg);
+bool net_request_file(NET* net, const char* fname);
+
 extern bool volatile abort_loop;
 extern Master_info main_mi, *active_mi; /* active_mi for multi-master */
 extern LIST master_list;
diff --git a/sql/sp.cc b/sql/sp.cc
index 39a8b6a009f..6aaddb69e05 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -13,10 +13,21 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sp.h"
+#include "sql_base.h"                           // close_thread_tables
+#include "sql_parse.h"                          // parse_sql
+#include "key.h"                                // key_copy
+#include "sql_show.h"             // append_definer, append_identifier
+#include "sql_db.h" // get_default_db_collation, mysql_opt_change_db,
+                    // mysql_change_db, check_db_dir_existence,
+                    // load_db_opt_by_name
+#include "sql_table.h"                          // write_bin_log
+#include "sql_acl.h"                       // SUPER_ACL
 #include "sp_head.h"
 #include "sp_cache.h"
+#include "lock.h"                               // lock_routine_name
 
 #include 
 
diff --git a/sql/sp.h b/sql/sp.h
index 886933eb7cf..f44f9f2d382 100644
--- a/sql/sp.h
+++ b/sql/sp.h
@@ -17,6 +17,25 @@
 #ifndef _SP_H_
 #define _SP_H_
 
+#include "sql_string.h"                         // LEX_STRING
+
+class Field;
+class Open_tables_backup;
+class Open_tables_state;
+class Query_arena;
+class Query_tables_list;
+class Sroutine_hash_entry;
+class THD;
+class sp_cache;
+class sp_head;
+class sp_name;
+class st_sp_chistics;
+struct LEX;
+struct TABLE;
+struct TABLE_LIST;
+typedef struct st_hash HASH;
+typedef struct st_sql_list SQL_LIST;
+
 /* Tells what SP_DEFAULT_ACCESS should be mapped to */
 #define SP_DEFAULT_ACCESS_MAPPING SP_CONTAINS_SQL
 
@@ -162,4 +181,14 @@ sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
                                const char *returns, const char *params,
                                bool *free_sp_head);
 
+bool load_charset(MEM_ROOT *mem_root,
+                  Field *field,
+                  CHARSET_INFO *dflt_cs,
+                  CHARSET_INFO **cs);
+
+bool load_collation(MEM_ROOT *mem_root,
+                    Field *field,
+                    CHARSET_INFO *dflt_cl,
+                    CHARSET_INFO **cl);
+
 #endif /* _SP_H_ */
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc
index 09d347bf951..f062276a9de 100644
--- a/sql/sp_cache.cc
+++ b/sql/sp_cache.cc
@@ -13,7 +13,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #ifdef USE_PRAGMA_IMPLEMENTATION
 #pragma implementation
 #endif
diff --git a/sql/sp_cache.h b/sql/sp_cache.h
index 7dbb0d5429c..c75e29474bc 100644
--- a/sql/sp_cache.h
+++ b/sql/sp_cache.h
@@ -21,6 +21,8 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "my_global.h"                          /* ulong */
+
 /*
   Stored procedures/functions cache. This is used as follows:
    * Each thread has its own cache.
@@ -30,6 +32,7 @@
 
 class sp_head;
 class sp_cache;
+class sp_name;
 
 /*
   Cache usage scenarios:
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index c6bf0e381fb..2d197766782 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -13,9 +13,19 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sql_prepare.h"
+#include "sql_cache.h"                          // query_cache_*
 #include "probes_mysql.h"
+#include "sql_show.h"                           // append_identifier
+#include "sql_db.h"            // mysql_opt_change_db, mysql_change_db
+#include "sql_table.h"         // sp_prepare_create_field,
+                               // prepare_create_field
+#include "sql_acl.h"           // *_ACL
+#include "sql_array.h"         // Dynamic_array
+#include "log_event.h"         // append_query_string, Query_log_event
+
 #ifdef USE_PRAGMA_IMPLEMENTATION
 #pragma implementation
 #endif
@@ -25,6 +35,8 @@
 #include "sp_rcontext.h"
 #include "sp_cache.h"
 #include "set_var.h"
+#include "sql_parse.h"                          // cleanup_items
+#include "sql_base.h"                           // close_thread_tables
 
 /*
   Sufficient max length of printed destinations and frame offsets (all uints).
diff --git a/sql/sp_head.h b/sql/sp_head.h
index d1e152765f2..66cbc47d8e0 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -21,6 +21,14 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+/*
+  It is necessary to include set_var.h instead of item.h because there
+  are dependencies on include order for set_var.h and item.h. This
+  will be resolved later.
+*/
+#include "sql_class.h"                          // THD, set_var.h: THD
+#include "set_var.h"                            // Item
+
 #include 
 
 /**
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 48ceb1371ca..74dda9f456b 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -13,7 +13,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #ifdef USE_PRAGMA_IMPLEMENTATION
 #pragma implementation
 #endif
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index 75e55880e60..b12d5362c6b 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -21,6 +21,12 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "sql_string.h"                         // LEX_STRING
+#include "mysql_com.h"                          // enum_field_types
+#include "field.h"                              // Create_field
+
+class sp_pcontext;
+
 typedef enum
 {
   sp_param_in,
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index d966de03b4e..e3cdf328659 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -13,7 +13,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #ifdef USE_PRAGMA_IMPLEMENTATION
 #pragma implementation
 #endif
@@ -27,7 +28,7 @@
 #include "sql_cursor.h"
 #include "sp_rcontext.h"
 #include "sp_pcontext.h"
-
+#include "sql_select.h"                     // create_virtual_tmp_table
 
 sp_rcontext::sp_rcontext(sp_pcontext *root_parsing_ctx,
                          Field *return_value_fld,
diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h
index 2af96cf64dd..fad253706cb 100644
--- a/sql/sp_rcontext.h
+++ b/sql/sp_rcontext.h
@@ -21,11 +21,19 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "sql_class.h"                    // select_result_interceptor
+
 struct sp_cond_type;
 class sp_cursor;
 struct sp_variable;
 class sp_lex_keeper;
 class sp_instr_cpush;
+class Query_arena;
+class sp_head;
+class sp_pcontext;
+class Item_cache;
+typedef class st_select_lex_unit SELECT_LEX_UNIT;
+class Server_side_cursor;
 
 #define SP_HANDLER_NONE      0
 #define SP_HANDLER_EXIT      1
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 9a31b099e92..34b1f3d1f0c 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -13,7 +13,11 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "my_global.h"                          // REQUIRED for HAVE_* below
+#include "spatial.h"
+#include "gstream.h"                            // Gis_read_stream
+#include "sql_string.h"                         // String
 
 #ifdef HAVE_SPATIAL
 
diff --git a/sql/spatial.h b/sql/spatial.h
index 86c2ed8c197..a4bce47d0e5 100644
--- a/sql/spatial.h
+++ b/sql/spatial.h
@@ -16,8 +16,12 @@
 #ifndef _spatial_h
 #define _spatial_h
 
+#include "sql_string.h"                         /* String, LEX_STRING */
+
 #ifdef HAVE_SPATIAL
 
+class Gis_read_stream;
+
 const uint SRID_SIZE= 4;
 const uint SIZEOF_STORED_DOUBLE= 8;
 const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2; 
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 86f62d9bf72..dae6123c38f 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -24,13 +24,25 @@
   in the relevant fields. Empty strings comes last.
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_acl.h"         // MYSQL_DB_FIELD_COUNT, ACL_ACCESS
+#include "sql_base.h"                           // close_thread_tables
+#include "key.h"             // key_copy, key_cmp_if_same, key_restore
+#include "sql_show.h"        // append_identifier
+#include "sql_table.h"                         // build_table_filename
 #include "hash_filo.h"
+#include "sql_parse.h"                          // check_access
+#include "sql_view.h"                           // VIEW_ANY_ACL
+#include "records.h"              // READ_RECORD, read_record_info,
+                                  // init_read_record, end_read_record
+#include "rpl_filter.h"           // rpl_filter
 #include 
 #include 
 #include "sp_head.h"
 #include "sp.h"
 #include "transaction.h"
+#include "lock.h"                               // MYSQL_LOCK_IGNORE_TIMEOUT
+#include "records.h"             // init_read_record, end_read_record
 
 bool mysql_user_table_is_in_short_password_format= false;
 
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index 8d521be2bc4..1cbbedfe226 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -16,7 +16,8 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "slave.h" // for tables_ok(), rpl_filter
+#include "violite.h"                            /* SSL_type */
+#include "sql_class.h"                          /* LEX_COLUMN */
 
 #define SELECT_ACL	(1L << 0)
 #define INSERT_ACL	(1L << 1)
@@ -278,6 +279,11 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
 bool check_routine_level_acl(THD *thd, const char *db, const char *name,
                              bool is_proc);
 bool is_acl_user(const char *host, const char *user);
+int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
+int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
+int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
+int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
+int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
 
 #ifdef NO_EMBEDDED_ACCESS_CHECKS
 #define check_grant(A,B,C,D,E,F) 0
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index d273b3319ee..0b3e5117c97 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -28,7 +28,7 @@
 
 #define MYSQL_LEX 1
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "procedure.h"
 #include "sql_analyse.h"
 #include 
diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h
index 8f52b90c874..a1461247894 100644
--- a/sql/sql_analyse.h
+++ b/sql/sql_analyse.h
@@ -23,6 +23,8 @@
 #pragma interface				/* gcc class implementation */
 #endif
 
+#include "procedure.h"                          /* Procedure */
+
 #define my_thd_charset	default_charset_info
 
 #define DEC_IN_AVG 4
@@ -359,4 +361,6 @@ public:
 				      List &field_list);
 };
 
+bool append_escaped(String *to_str, String *from_str);
+
 #endif /* SQL_ANALYSE_INCLUDED */
diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc
index 5190cba64de..39ab33abfe6 100644
--- a/sql/sql_audit.cc
+++ b/sql/sql_audit.cc
@@ -13,7 +13,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "sql_audit.h"
 
 extern int initialize_audit_plugin(st_plugin_int *plugin);
diff --git a/sql/sql_audit.h b/sql/sql_audit.h
index c25011d0d59..5b6962b9ecb 100644
--- a/sql/sql_audit.h
+++ b/sql/sql_audit.h
@@ -18,6 +18,7 @@
 
 
 #include 
+#include "sql_class.h"
 
 extern unsigned long mysql_global_audit_mask[];
 
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 651787a7969..51ab56083fc 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -16,8 +16,29 @@
 
 /* Basic functions needed by many modules */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "debug_sync.h"
+#include "sql_base.h"                           // setup_table_map
+#include "lock.h"        // broadcast_refresh, mysql_lock_remove,
+                         // mysql_unlock_tables,
+                         // mysql_lock_have_duplicate
+#include "sql_show.h"    // append_identifier
+#include "strfunc.h"     // find_type
+#include "parse_file.h"  // sql_parse_prepare, File_parser
+#include "sql_view.h"    // mysql_frm_type, mysql_make_view, VIEW_ANY_ACL
+#include "sql_parse.h"   // check_table_access
+#include "sql_insert.h"  // kill_delayed_threads
+#include "sql_acl.h"     // *_ACL, check_grant_all_columns,
+                         // check_column_grant_in_table_ref,
+                         // get_column_grant
+#include "sql_partition.h"               // ALTER_PARTITION_PARAM_TYPE
+#include "sql_derived.h" // mysql_derived_prepare,
+                         // mysql_handle_derived,
+                         // mysql_derived_filling
+#include "sql_handler.h" // mysql_ha_flush
+#include "sql_partition.h"                      // ALTER_PARTITION_PARAM_TYPE
+#include "log_event.h"                          // Query_log_event
 #include "sql_select.h"
 #include "sp_head.h"
 #include "sp.h"
@@ -29,6 +50,7 @@
 #include 
 #include 
 #include "rpl_filter.h"
+#include "sql_table.h"                          // build_table_filename
 #ifdef  __WIN__
 #include 
 #endif
diff --git a/sql/sql_base.h b/sql/sql_base.h
new file mode 100644
index 00000000000..eac29b1c257
--- /dev/null
+++ b/sql/sql_base.h
@@ -0,0 +1,359 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_BASE_INCLUDED
+#define SQL_BASE_INCLUDED
+
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "table.h"                              /* open_table_mode */
+#include "sql_trigger.h"                        /* trg_event_type */
+#include "sql_class.h"                          /* enum_mark_columns */
+#include "mysqld.h"                             /* key_map */
+
+class Item_ident;
+class Name_resolution_context;
+class Open_table_context;
+class Open_tables_state;
+class Prelocking_strategy;
+class TABLE_LIST;
+class THD;
+class handlerton;
+struct TABLE;
+
+typedef class st_select_lex SELECT_LEX;
+
+typedef struct st_lock_param_type ALTER_PARTITION_PARAM_TYPE;
+
+/*
+  This enumeration type is used only by the function find_item_in_list
+  to return the info on how an item has been resolved against a list
+  of possibly aliased items.
+  The item can be resolved:
+   - against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
+   - against non-aliased field name of the list  (RESOLVED_WITH_NO_ALIAS)
+   - against an aliased field name of the list   (RESOLVED_BEHIND_ALIAS)
+   - ignoring the alias name in cases when SQL requires to ignore aliases
+     (e.g. when the resolved field reference contains a table name or
+     when the resolved item is an expression)   (RESOLVED_IGNORING_ALIAS)
+*/
+enum enum_resolution_type {
+  NOT_RESOLVED=0,
+  RESOLVED_IGNORING_ALIAS,
+  RESOLVED_BEHIND_ALIAS,
+  RESOLVED_WITH_NO_ALIAS,
+  RESOLVED_AGAINST_ALIAS
+};
+
+enum enum_open_table_action {OT_NO_ACTION= 0, OT_BACK_OFF_AND_RETRY,
+                             OT_DISCOVER, OT_REPAIR};
+
+enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
+				  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
+                                  IGNORE_EXCEPT_NON_UNIQUE};
+
+enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN,
+                                 TDC_RT_REMOVE_UNUSED};
+
+/* bits for last argument to remove_table_from_cache() */
+#define RTFC_NO_FLAG                0x0000
+#define RTFC_OWNED_BY_THD_FLAG      0x0001
+#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
+#define RTFC_CHECK_KILLED_FLAG      0x0004
+
+bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
+bool table_cache_init(void);
+void table_cache_free(void);
+bool table_def_init(void);
+void table_def_free(void);
+void table_def_start_shutdown(void);
+void assign_new_table_id(TABLE_SHARE *share);
+uint cached_open_tables(void);
+uint cached_table_definitions(void);
+uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
+                          bool tmp_table);
+TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
+                             uint key_length, uint db_flags, int *error,
+                             my_hash_value_type hash_value);
+void release_table_share(TABLE_SHARE *share);
+TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
+
+TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
+                   uint lock_flags);
+bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
+                Open_table_context *ot_ctx, uint flags);
+bool name_lock_locked_table(THD *thd, TABLE_LIST *tables);
+bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in);
+TABLE *table_cache_insert_placeholder(THD *thd, const char *key,
+                                      uint key_length);
+bool lock_table_name_if_not_cached(THD *thd, const char *db,
+                                   const char *table_name, TABLE **table);
+void detach_merge_children(TABLE *table, bool clear_refs);
+bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last,
+                          TABLE_LIST *new_child_list, TABLE_LIST **new_last);
+bool reopen_table(TABLE *table);
+bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
+void close_data_files_and_morph_locks(THD *thd, const char *db,
+                                      const char *table_name);
+void close_handle_and_leave_table_as_lock(TABLE *table);
+bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
+                  uint db_stat, uint prgflag,
+                  uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc,
+                  MEM_ROOT *mem_root);
+bool wait_for_tables(THD *thd);
+bool table_is_used(TABLE *table, bool wait_for_name_lock);
+TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
+void abort_locked_tables(THD *thd,const char *db, const char *table_name);
+
+bool get_key_map_from_key_list(key_map *map, TABLE *table,
+                               List *index_list);
+TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
+			    const char *table_name, bool link_in_list);
+TABLE *find_locked_table(TABLE *list, const char *db, const char *table_name);
+TABLE *find_write_locked_table(TABLE *list, const char *db,
+                               const char *table_name);
+thr_lock_type read_lock_type_for_table(THD *thd, TABLE *table);
+
+my_bool mysql_rm_tmp_tables(void);
+bool rm_temporary_table(handlerton *base, char *path);
+void close_tables_for_reopen(THD *thd, TABLE_LIST **tables,
+                             MDL_ticket *start_of_statement_svp);
+TABLE_LIST *find_table_in_list(TABLE_LIST *table,
+                               TABLE_LIST *TABLE_LIST::*link,
+                               const char *db_name,
+                               const char *table_name);
+TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name);
+TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list);
+void close_thread_tables(THD *thd);
+bool fill_record_n_invoke_before_triggers(THD *thd, List &fields,
+                                          List &values,
+                                          bool ignore_errors,
+                                          Table_triggers_list *triggers,
+                                          enum trg_event_type event);
+bool fill_record_n_invoke_before_triggers(THD *thd, Field **field,
+                                          List &values,
+                                          bool ignore_errors,
+                                          Table_triggers_list *triggers,
+                                          enum trg_event_type event);
+bool insert_fields(THD *thd, Name_resolution_context *context,
+		   const char *db_name, const char *table_name,
+                   List_iterator *it, bool any_privileges);
+int setup_wild(THD *thd, TABLE_LIST *tables, List &fields,
+	       List *sum_func_list, uint wild_num);
+bool setup_fields(THD *thd, Item** ref_pointer_array,
+                  List &item, enum_mark_columns mark_used_columns,
+                  List *sum_func_list, bool allow_sum_func);
+bool fill_record(THD *thd, Field **field, List &values,
+                 bool ignore_errors);
+
+Field *
+find_field_in_tables(THD *thd, Item_ident *item,
+                     TABLE_LIST *first_table, TABLE_LIST *last_table,
+                     Item **ref, find_item_error_report_type report_error,
+                     bool check_privileges, bool register_tree_change);
+Field *
+find_field_in_table_ref(THD *thd, TABLE_LIST *table_list,
+                        const char *name, uint length,
+                        const char *item_name, const char *db_name,
+                        const char *table_name, Item **ref,
+                        bool check_privileges, bool allow_rowid,
+                        uint *cached_field_index_ptr,
+                        bool register_tree_change, TABLE_LIST **actual_table);
+Field *
+find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
+                    bool allow_rowid, uint *cached_field_index_ptr);
+Field *
+find_field_in_table_sef(TABLE *table, const char *name);
+Item ** find_item_in_list(Item *item, List &items, uint *counter,
+                          find_item_error_report_type report_error,
+                          enum_resolution_type *resolution);
+bool setup_tables(THD *thd, Name_resolution_context *context,
+                  List *from_clause, TABLE_LIST *tables,
+                  TABLE_LIST **leaves, bool select_insert);
+bool setup_tables_and_check_access(THD *thd,
+                                   Name_resolution_context *context,
+                                   List *from_clause,
+                                   TABLE_LIST *tables,
+                                   TABLE_LIST **leaves,
+                                   bool select_insert,
+                                   ulong want_access_first,
+                                   ulong want_access);
+bool wait_while_table_is_used(THD *thd, TABLE *table,
+                              enum ha_extra_function function);
+void unlink_open_table(THD *thd, TABLE *find, bool unlock);
+
+void drop_open_table(THD *thd, TABLE *table, const char *db_name,
+                     const char *table_name);
+void close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
+                               bool remove_from_locked_tables);
+void update_non_unique_table_error(TABLE_LIST *update,
+                                   const char *operation,
+                                   TABLE_LIST *duplicate);
+int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
+		COND **conds);
+int setup_ftfuncs(SELECT_LEX* select);
+int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
+void wait_for_condition(THD *thd, mysql_mutex_t *mutex,
+                        mysql_cond_t *cond);
+bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags,
+                 Prelocking_strategy *prelocking_strategy);
+/* open_and_lock_tables with optional derived handling */
+bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
+                          bool derived, uint flags,
+                          Prelocking_strategy *prelocking_strategy);
+int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived);
+/* simple open_and_lock_tables without derived handling for single table */
+TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l,
+                                thr_lock_type lock_type, uint flags);
+bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
+bool lock_tables(THD *thd, TABLE_LIST *tables, uint counter, uint flags);
+int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt);
+int decide_logging_format(THD *thd, TABLE_LIST *tables);
+void free_io_cache(TABLE *entry);
+void intern_close_table(TABLE *entry);
+bool close_thread_table(THD *thd, TABLE **table_ptr);
+void close_temporary_tables(THD *thd);
+TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
+                         bool check_alias);
+int drop_temporary_table(THD *thd, TABLE_LIST *table_list);
+void close_temporary_table(THD *thd, TABLE *table, bool free_share,
+                           bool delete_table);
+void close_temporary(TABLE *table, bool free_share, bool delete_table);
+bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
+			    const char *table_name);
+void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table);
+void remove_db_from_cache(const char *db);
+void flush_tables();
+bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
+
+/* Functions to work with system tables. */
+bool open_system_tables_for_read(THD *thd, TABLE_LIST *table_list,
+                                 Open_tables_backup *backup);
+void close_system_tables(THD *thd, Open_tables_backup *backup);
+TABLE *open_system_table_for_update(THD *thd, TABLE_LIST *one_table);
+TABLE *open_log_table(THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup);
+void close_log_table(THD *thd, Open_tables_backup *backup);
+
+TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
+                                     Open_tables_state *backup);
+void close_performance_schema_table(THD *thd, Open_tables_state *backup);
+
+bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
+                         bool wait_for_refresh);
+bool close_cached_connection_tables(THD *thd, bool wait_for_refresh,
+                                    LEX_STRING *connect_string,
+                                    bool have_lock = FALSE);
+void close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
+                               bool remove_from_locked_tables);
+OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild);
+bool remove_table_from_cache(THD *thd, const char *db, const char *table,
+                             uint flags);
+void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
+                      const char *db, const char *table_name);
+bool tdc_open_view(THD *thd, TABLE_LIST *table_list, const char *alias,
+                   char *cache_key, uint cache_key_length,
+                   MEM_ROOT *mem_root, uint flags);
+TABLE *find_table_for_mdl_upgrade(TABLE *list, const char *db,
+                                  const char *table_name,
+                                  bool no_error);
+void mark_tmp_table_for_reuse(TABLE *table);
+
+extern uint  table_cache_count;
+extern TABLE *unused_tables;
+extern Item **not_found_item;
+extern Field *not_found_field;
+extern Field *view_ref_found;
+extern HASH open_cache;
+extern HASH table_def_cache;
+
+/**
+  clean/setup table fields and map.
+
+  @param table        TABLE structure pointer (which should be setup)
+  @param table_list   TABLE_LIST structure pointer (owner of TABLE)
+  @param tablenr     table number
+*/
+
+
+inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
+{
+  table->used_fields= 0;
+  table->const_table= 0;
+  table->null_row= 0;
+  table->status= STATUS_NO_RECORD;
+  table->maybe_null= table_list->outer_join;
+  TABLE_LIST *embedding= table_list->embedding;
+  while (!table->maybe_null && embedding)
+  {
+    table->maybe_null= embedding->outer_join;
+    embedding= embedding->embedding;
+  }
+  table->tablenr= tablenr;
+  table->map= (table_map) 1 << tablenr;
+  table->force_index= table_list->force_index;
+  table->force_index_order= table->force_index_group= 0;
+  table->covering_keys= table->s->keys_for_keyread;
+  table->merge_keys.clear_all();
+}
+
+inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
+                                             const char *db_name,
+                                             const char *table_name)
+{
+  return find_table_in_list(table, &TABLE_LIST::next_global,
+                            db_name, table_name);
+}
+
+inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table,
+                                            const char *db_name,
+                                            const char *table_name)
+{
+  return find_table_in_list(table, &TABLE_LIST::next_local,
+                            db_name, table_name);
+}
+
+inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array,
+                                      List &item,
+                                      enum_mark_columns mark_used_columns,
+                                      List *sum_func_list,
+                                      bool allow_sum_func)
+{
+  bool res;
+  thd->lex->select_lex.no_wrap_view_item= TRUE;
+  res= setup_fields(thd, ref_pointer_array, item, mark_used_columns,
+                    sum_func_list, allow_sum_func);
+  thd->lex->select_lex.no_wrap_view_item= FALSE;
+  return res;
+}
+
+inline bool
+open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags)
+{
+  DML_prelocking_strategy prelocking_strategy;
+
+  return open_tables(thd, tables, counter, flags, &prelocking_strategy);
+}
+
+
+/* open_and_lock_tables with derived handling */
+inline bool open_and_lock_tables(THD *thd, TABLE_LIST *tables,
+                                 bool derived, uint flags)
+{
+  DML_prelocking_strategy prelocking_strategy;
+
+  return open_and_lock_tables(thd, tables, derived, flags,
+                              &prelocking_strategy);
+}
+
+#endif /* SQL_BASE_INCLUDED */
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 31d4430cbe6..0730f7df00c 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -13,10 +13,20 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_binlog.h"
+#include "sql_parse.h"                          // check_global_access
+#include "sql_acl.h"                            // *_ACL
 #include "rpl_rli.h"
 #include "base64.h"
-
+#include "slave.h"                              // apply_event_and_update_pos
+#include "log_event.h"                          // Format_description_log_event,
+                                                // EVENT_LEN_OFFSET,
+                                                // EVENT_TYPE_OFFSET,
+                                                // FORMAT_DESCRIPTION_LOG_EVENT,
+                                                // START_EVENT_V3,
+                                                // Log_event_type,
+                                                // Log_event
 /**
   Execute a BINLOG statement.
 
diff --git a/sql/sql_binlog.h b/sql/sql_binlog.h
new file mode 100644
index 00000000000..50251eaac50
--- /dev/null
+++ b/sql/sql_binlog.h
@@ -0,0 +1,23 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_BINLOG_INCLUDED
+#define SQL_BINLOG_INCLUDED
+
+class THD;
+
+void mysql_client_binlog_statement(THD *thd);
+
+#endif /* SQL_BINLOG_INCLUDED */
diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h
index 97accefe8aa..80a4712dd69 100644
--- a/sql/sql_bitmap.h
+++ b/sql/sql_bitmap.h
@@ -19,6 +19,9 @@
   also be able to use 32 or 64 bits bitmaps very efficiently
 */
 
+#ifndef SQL_BITMAP_INCLUDED
+#define SQL_BITMAP_INCLUDED
+
 #include 
 
 template  class Bitmap
@@ -138,3 +141,5 @@ public:
   ulonglong to_ulonglong() const { return map; }
 };
 
+
+#endif /* SQL_BITMAP_INCLUDED */
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index f812ef862b0..2d47e3d4f6d 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -327,7 +327,12 @@ TODO list:
       (This could be done with almost no speed penalty)
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_cache.h"
+#include "sql_parse.h"                          // check_table_access
+#include "tztime.h"                             // struct Time_zone
+#include "sql_acl.h"                            // SELECT_ACL
+#include "sql_base.h"                           // TMP_TABLE_KEY_EXTRA
 #ifdef HAVE_QUERY_CACHE
 #include 
 #include 
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index 9d1f32d6ef1..4fbd372d643 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -16,6 +16,16 @@
 #ifndef _SQL_CACHE_H
 #define _SQL_CACHE_H
 
+#include "hash.h"
+#include "my_base.h"                            /* ha_rows */
+
+class MY_LOCALE;
+class TABLE_LIST;
+class Time_zone;
+struct LEX;
+struct TABLE;
+typedef struct st_changed_table_list CHANGED_TABLE_LIST;
+
 /* Query cache */
 
 /*
@@ -66,6 +76,11 @@ struct Query_cache_result;
 class Query_cache;
 struct Query_cache_tls;
 struct LEX;
+class THD;
+
+typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
+                                      uint key_length,
+                                      ulonglong *engine_data);
 
 /**
   This class represents a node in the linked chain of queries
@@ -502,5 +517,68 @@ protected:
   void unlock(void);
 };
 
+#ifdef HAVE_QUERY_CACHE
+struct Query_cache_query_flags
+{
+  unsigned int client_long_flag:1;
+  unsigned int client_protocol_41:1;
+  unsigned int protocol_type:2;
+  unsigned int more_results_exists:1;
+  unsigned int in_trans:1;
+  unsigned int autocommit:1;
+  unsigned int pkt_nr;
+  uint character_set_client_num;
+  uint character_set_results_num;
+  uint collation_connection_num;
+  ha_rows limit;
+  Time_zone *time_zone;
+  ulong sql_mode;
+  ulong max_sort_length;
+  ulong group_concat_max_len;
+  ulong default_week_format;
+  ulong div_precision_increment;
+  MY_LOCALE *lc_time_names;
+};
+#define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags)
+#include "sql_cache.h"
+#define query_cache_abort(A) query_cache.abort(A)
+#define query_cache_end_of_result(A) query_cache.end_of_result(A)
+#define query_cache_store_query(A, B) query_cache.store_query(A, B)
+#define query_cache_destroy() query_cache.destroy()
+#define query_cache_result_size_limit(A) query_cache.result_size_limit(A)
+#define query_cache_init() query_cache.init()
+#define query_cache_resize(A) query_cache.resize(A)
+#define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A)
+#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
+#define query_cache_invalidate1(A) query_cache.invalidate(A)
+#define query_cache_send_result_to_client(A, B, C) \
+  query_cache.send_result_to_client(A, B, C)
+#define query_cache_invalidate_by_MyISAM_filename_ref \
+  &query_cache_invalidate_by_MyISAM_filename
+/* note the "maybe": it's a read without mutex */
+#define query_cache_maybe_disabled(T)                                 \
+  (T->variables.query_cache_type == 0 || query_cache.query_cache_size == 0)
+#define query_cache_is_cacheable_query(L) \
+  (((L)->sql_command == SQLCOM_SELECT) && (L)->safe_to_cache_query)
+#else
+#define QUERY_CACHE_FLAGS_SIZE 0
+#define query_cache_store_query(A, B)
+#define query_cache_destroy()
+#define query_cache_result_size_limit(A)
+#define query_cache_init()
+#define query_cache_resize(A)
+#define query_cache_set_min_res_unit(A)
+#define query_cache_invalidate3(A, B, C)
+#define query_cache_invalidate1(A)
+#define query_cache_send_result_to_client(A, B, C) 0
+#define query_cache_invalidate_by_MyISAM_filename_ref NULL
+
+#define query_cache_abort(A)
+#define query_cache_end_of_result(A)
+#define query_cache_invalidate_by_MyISAM_filename_ref NULL
+#define query_cache_maybe_disabled(T) 1
+#define query_cache_is_cacheable_query(L) 0
+#endif /*HAVE_QUERY_CACHE*/
+
 extern Query_cache query_cache;
 #endif
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 4b21bc283e2..d47aae38f94 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -25,7 +25,17 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_class.h"
+#include "lock.h"      // unlock_global_read_lock, mysql_unlock_tables
+#include "sql_cache.h"                          // query_cache_abort
+#include "sql_base.h"                           // close_thread_tables
+#include "sql_time.h"                         // date_time_format_copy
+#include "sql_acl.h"                          // NO_ACCESS,
+                                              // acl_getroot_no_password
+#include "sql_base.h"                         // close_temporary_tables
+#include "sql_handler.h"                      // mysql_ha_cleanup
 #include "rpl_rli.h"
 #include "rpl_filter.h"
 #include "rpl_record.h"
@@ -46,6 +56,7 @@
 #include "sp_cache.h"
 #include "transaction.h"
 #include "debug_sync.h"
+#include "sql_parse.h"                          // is_update_query
 
 /*
   The following is used to initialise Table_ident with a internal
diff --git a/sql/sql_class.h b/sql/sql_class.h
index de6d92eccfd..97d60a62780 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -23,10 +23,21 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#ifdef MYSQL_SERVER
+#include "unireg.h"                    // REQUIRED: for other includes
+#endif
+#include "sql_const.h"
 #include 
 #include "log.h"
 #include "rpl_tblmap.h"
 #include "mdl.h"
+#include "sql_locale.h"                         /* my_locale_st */
+#include "sql_profile.h"                   /* PROFILING */
+#include "scheduler.h"                     /* thd_scheduler */
+#include "protocol.h"             /* Protocol_text, Protocol_binary */
+#include "violite.h"              /* vio_is_connected */
+#include "thr_lock.h"             /* thr_lock_type, THR_LOCK_DATA,
+                                     THR_LOCK_INFO, THR_LOCK_OWNER */
 
 
 class Reprepare_observer;
@@ -40,6 +51,8 @@ class sp_cache;
 class Parser_state;
 class Rows_log_event;
 class Sroutine_hash_entry;
+class User_level_lock;
+class user_var_entry;
 
 enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
 enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
@@ -55,6 +68,40 @@ enum enum_mark_columns
 { MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
 enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
 
+/* Bits for different SQL modes modes (including ANSI mode) */
+#define MODE_REAL_AS_FLOAT              1
+#define MODE_PIPES_AS_CONCAT            2
+#define MODE_ANSI_QUOTES                4
+#define MODE_IGNORE_SPACE               8
+#define MODE_NOT_USED                   16
+#define MODE_ONLY_FULL_GROUP_BY         32
+#define MODE_NO_UNSIGNED_SUBTRACTION    64
+#define MODE_NO_DIR_IN_CREATE           128
+#define MODE_POSTGRESQL                 256
+#define MODE_ORACLE                     512
+#define MODE_MSSQL                      1024
+#define MODE_DB2                        2048
+#define MODE_MAXDB                      4096
+#define MODE_NO_KEY_OPTIONS             8192
+#define MODE_NO_TABLE_OPTIONS           16384
+#define MODE_NO_FIELD_OPTIONS           32768
+#define MODE_MYSQL323                   65536L
+#define MODE_MYSQL40                    (MODE_MYSQL323*2)
+#define MODE_ANSI                       (MODE_MYSQL40*2)
+#define MODE_NO_AUTO_VALUE_ON_ZERO      (MODE_ANSI*2)
+#define MODE_NO_BACKSLASH_ESCAPES       (MODE_NO_AUTO_VALUE_ON_ZERO*2)
+#define MODE_STRICT_TRANS_TABLES        (MODE_NO_BACKSLASH_ESCAPES*2)
+#define MODE_STRICT_ALL_TABLES          (MODE_STRICT_TRANS_TABLES*2)
+#define MODE_NO_ZERO_IN_DATE            (MODE_STRICT_ALL_TABLES*2)
+#define MODE_NO_ZERO_DATE               (MODE_NO_ZERO_IN_DATE*2)
+#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
+#define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
+#define MODE_TRADITIONAL                (MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
+#define MODE_NO_AUTO_CREATE_USER        (MODE_TRADITIONAL*2)
+#define MODE_HIGH_NOT_PRECEDENCE        (MODE_NO_AUTO_CREATE_USER*2)
+#define MODE_NO_ENGINE_SUBSTITUTION     (MODE_HIGH_NOT_PRECEDENCE*2)
+#define MODE_PAD_CHAR_TO_FULL_LENGTH    (ULL(1) << 31)
+
 extern char internal_table_name[2];
 extern char empty_c_string[1];
 extern MYSQL_PLUGIN_IMPORT const char **errmesg;
@@ -248,6 +295,8 @@ public:
   LEX_COLUMN (const String& x,const  uint& y ): column (x),rights (y) {}
 };
 
+class MY_LOCALE;
+
 /**
   Query_cache_tls -- query cache thread local data.
 */
@@ -2766,8 +2815,6 @@ public:
   bool escaped_given(void);
 };
 
-#include "log_event.h"
-
 /*
   This is used to get result from a select
 */
@@ -3484,13 +3531,55 @@ public:
 */
 #define CF_SKIP_QUESTIONS       (1U << 1)
 
-/* Functions in sql_class.cc */
-
 void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
 
 void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
                         STATUS_VAR *dec_var);
 void mark_transaction_to_rollback(THD *thd, bool all);
 
+/*
+  This prototype is placed here instead of in item_func.h because it
+  depends on the definition of enum_sql_command, which is in this
+  file.
+ */
+int get_var_with_binlog(THD *thd, enum_sql_command sql_command,
+                        LEX_STRING &name, user_var_entry **out_entry);
+
+/* Inline functions */
+
+inline bool add_item_to_list(THD *thd, Item *item)
+{
+  return thd->lex->current_select->add_item_to_list(thd, item);
+}
+
+inline bool add_value_to_list(THD *thd, Item *value)
+{
+  return thd->lex->value_list.push_back(value);
+}
+
+inline bool add_order_to_list(THD *thd, Item *item, bool asc)
+{
+  return thd->lex->current_select->add_order_to_list(thd, item, asc);
+}
+
+inline bool add_group_to_list(THD *thd, Item *item, bool asc)
+{
+  return thd->lex->current_select->add_group_to_list(thd, item, asc);
+}
+
 #endif /* MYSQL_SERVER */
+
+/**
+  The meat of thd_proc_info(THD*, char*), a macro that packs the last
+  three calling-info parameters.
+*/
+extern "C"
+const char *set_thd_proc_info(THD *thd, const char *info,
+                              const char *calling_func,
+                              const char *calling_file,
+                              const unsigned int calling_line);
+
+#define thd_proc_info(thd, msg) \
+  set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
+
 #endif /* SQL_CLASS_INCLUDED */
diff --git a/sql/sql_client.cc b/sql/sql_client.cc
index 032a2e26e3a..0c16449276a 100644
--- a/sql/sql_client.cc
+++ b/sql/sql_client.cc
@@ -17,7 +17,8 @@
   This files defines some MySQL C API functions that are server specific
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_class.h"                          // system_variables
 
 /*
   Function called by my_net_init() to set some check variables
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 90b255b0843..c454933517f 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -18,9 +18,23 @@
   Functions to autenticate and handle reqests for a connection
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "my_global.h"
+#ifndef __WIN__
+#include         // getservbyname, servent
+#endif
 #include "sql_audit.h"
+#include "sql_connect.h"
+#include "my_global.h"
 #include "probes_mysql.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_parse.h"                          // sql_command_flags,
+                                                // execute_init_command,
+                                                // do_command
+#include "sql_db.h"                             // mysql_change_db
+#include "hostname.h" // inc_host_errors, ip_to_hostname,
+                      // reset_host_errors
+#include "sql_acl.h"  // acl_getroot, NO_ACCESS, SUPER_ACL
 
 #ifdef HAVE_OPENSSL
 /*
diff --git a/sql/sql_connect.h b/sql/sql_connect.h
new file mode 100644
index 00000000000..2334b7303be
--- /dev/null
+++ b/sql/sql_connect.h
@@ -0,0 +1,43 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_CONNECT_INCLUDED
+#define SQL_CONNECT_INCLUDED
+
+#include "my_sys.h"                          /* pthread_handler_t */
+#include "mysql_com.h"                         /* enum_server_command */
+
+class THD;
+typedef struct st_lex_user LEX_USER;
+typedef struct user_conn USER_CONN;
+
+void init_max_user_conn(void);
+void free_max_user_conn(void);
+
+pthread_handler_t handle_one_connection(void *arg);
+void do_handle_one_connection(THD *thd_arg);
+bool init_new_connection_handler_thread();
+void reset_mqh(LEX_USER *lu, bool get_them);
+bool check_mqh(THD *thd, uint check_command);
+void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
+void decrease_user_connections(USER_CONN *uc);
+void thd_init_client_charset(THD *thd, uint cs_number);
+bool setup_connection_thread_globals(THD *thd);
+
+int check_user(THD *thd, enum enum_server_command command,
+	       const char *passwd, uint passwd_len, const char *db,
+	       bool check_count);
+
+#endif /* SQL_CONNECT_INCLUDED */
diff --git a/sql/sql_const.h b/sql/sql_const.h
new file mode 100644
index 00000000000..72f34ed6be8
--- /dev/null
+++ b/sql/sql_const.h
@@ -0,0 +1,254 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+/**
+  @file
+  File containing constants that can be used throughout the server.
+
+  @note This file shall not contain any includes of any kinds.
+*/
+
+#ifndef SQL_CONST_INCLUDED
+#define SQL_CONST_INCLUDED
+
+#define LIBLEN FN_REFLEN-FN_LEN			/* Max l{ngd p} dev */
+/* extra 4+4 bytes for slave tmp tables */
+#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
+#define MAX_ALIAS_NAME 256
+#define MAX_FIELD_NAME 34			/* Max colum name length +2 */
+#define MAX_SYS_VAR_LENGTH 32
+#define MAX_KEY MAX_INDEXES                     /* Max used keys */
+#define MAX_REF_PARTS 16			/* Max parts used as ref */
+#define MAX_KEY_LENGTH 3072			/* max possible key */
+#if SIZEOF_OFF_T > 4
+#define MAX_REFLENGTH 8				/* Max length for record ref */
+#else
+#define MAX_REFLENGTH 4				/* Max length for record ref */
+#endif
+#define MAX_HOSTNAME  61			/* len+1 in mysql.user */
+
+#define MAX_MBWIDTH		3		/* Max multibyte sequence */
+#define MAX_FIELD_CHARLENGTH	255
+#define MAX_FIELD_VARCHARLENGTH	65535
+#define MAX_FIELD_BLOBLENGTH UINT_MAX32     /* cf field_blob::get_length() */
+#define CONVERT_IF_BIGGER_TO_BLOB 512		/* Used for CREATE ... SELECT */
+
+/* Max column width +1 */
+#define MAX_FIELD_WIDTH		(MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
+
+#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
+
+#define MAX_DATE_WIDTH		10	/* YYYY-MM-DD */
+#define MAX_TIME_WIDTH		23	/* -DDDDDD HH:MM:SS.###### */
+#define MAX_DATETIME_FULL_WIDTH 29	/* YYYY-MM-DD HH:MM:SS.###### AM */
+#define MAX_DATETIME_WIDTH	19	/* YYYY-MM-DD HH:MM:SS */
+#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
+
+#define MAX_TABLES	(sizeof(table_map)*8-3)	/* Max tables in join */
+#define PARAM_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-3))
+#define OUTER_REF_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-2))
+#define RAND_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-1))
+#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
+                           RAND_TABLE_BIT)
+#define MAX_FIELDS	4096			/* Limit in the .frm file */
+#define MAX_PARTITIONS  1024
+
+#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
+
+#define MAX_SORT_MEMORY 2048*1024
+#define MIN_SORT_MEMORY 32*1024
+
+/* Some portable defines */
+
+#define portable_sizeof_char_ptr 8
+#define STRING_BUFFER_USUAL_SIZE 80
+
+/* Memory allocated when parsing a statement / saving a statement */
+#define MEM_ROOT_BLOCK_SIZE       8192
+#define MEM_ROOT_PREALLOC         8192
+#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
+#define TRANS_MEM_ROOT_PREALLOC   4096
+
+#define DEFAULT_ERROR_COUNT	64
+#define EXTRA_RECORDS	10			/* Extra records in sort */
+#define SCROLL_EXTRA	5			/* Extra scroll-rows. */
+#define FIELD_NAME_USED ((uint) 32768)		/* Bit set if fieldname used */
+#define FORM_NAME_USED	((uint) 16384)		/* Bit set if formname used */
+#define FIELD_NR_MASK	16383			/* To get fieldnumber */
+#define FERR		-1			/* Error from my_functions */
+#define CREATE_MODE	0			/* Default mode on new files */
+#define NAMES_SEP_CHAR	'\377'			/* Char to sep. names */
+
+#define READ_RECORD_BUFFER	(uint) (IO_SIZE*8) /* Pointer_buffer_size */
+#define DISK_BUFFER_SIZE	(uint) (IO_SIZE*16) /* Size of diskbuffer */
+
+#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
+
+/***************************************************************************
+  Configuration parameters
+****************************************************************************/
+
+#define ACL_CACHE_SIZE		256
+#define MAX_PASSWORD_LENGTH	32
+#define HOST_CACHE_SIZE		128
+#define MAX_ACCEPT_RETRY	10	// Test accept this many times
+#define MAX_FIELDS_BEFORE_HASH	32
+#define USER_VARS_HASH_SIZE     16
+#define TABLE_OPEN_CACHE_MIN    400
+#define TABLE_OPEN_CACHE_DEFAULT 400
+#define TABLE_DEF_CACHE_DEFAULT 400
+/**
+  We must have room for at least 400 table definitions in the table
+  cache, since otherwise there is no chance prepared
+  statements that use these many tables can work.
+  Prepared statements use table definition cache ids (table_map_id)
+  as table version identifiers. If the table definition
+  cache size is less than the number of tables used in a statement,
+  the contents of the table definition cache is guaranteed to rotate
+  between a prepare and execute. This leads to stable validation
+  errors. In future we shall use more stable version identifiers,
+  for now the only solution is to ensure that the table definition
+  cache can contain at least all tables of a given statement.
+*/
+#define TABLE_DEF_CACHE_MIN     400
+
+/*
+  Stack reservation.
+  Feel free to raise this by the smallest amount you can to get the
+  "execution_constants" test to pass.
+*/
+#define STACK_MIN_SIZE          16000   // Abort if less stack during eval.
+
+#define STACK_MIN_SIZE_FOR_OPEN 1024*80
+#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
+#ifndef MYSQLD_NET_RETRY_COUNT
+#define MYSQLD_NET_RETRY_COUNT  10	///< Abort read after this many int.
+#endif
+#define TEMP_POOL_SIZE          128
+
+#define QUERY_ALLOC_BLOCK_SIZE		8192
+#define QUERY_ALLOC_PREALLOC_SIZE   	8192
+#define TRANS_ALLOC_BLOCK_SIZE		4096
+#define TRANS_ALLOC_PREALLOC_SIZE	4096
+#define RANGE_ALLOC_BLOCK_SIZE		4096
+#define ACL_ALLOC_BLOCK_SIZE		1024
+#define UDF_ALLOC_BLOCK_SIZE		1024
+#define TABLE_ALLOC_BLOCK_SIZE		1024
+#define BDB_LOG_ALLOC_BLOCK_SIZE	1024
+#define WARN_ALLOC_BLOCK_SIZE		2048
+#define WARN_ALLOC_PREALLOC_SIZE	1024
+#define PROFILE_ALLOC_BLOCK_SIZE  2048
+#define PROFILE_ALLOC_PREALLOC_SIZE 1024
+
+/*
+  The following parameters is to decide when to use an extra cache to
+  optimise seeks when reading a big table in sorted order
+*/
+#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
+#define MIN_ROWS_TO_USE_TABLE_CACHE	 100
+#define MIN_ROWS_TO_USE_BULK_INSERT	 100
+
+/**
+  The following is used to decide if MySQL should use table scanning
+  instead of reading with keys.  The number says how many evaluation of the
+  WHERE clause is comparable to reading one extra row from a table.
+*/
+#define TIME_FOR_COMPARE   5	// 5 compares == one read
+
+/**
+  Number of comparisons of table rowids equivalent to reading one row from a 
+  table.
+*/
+#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
+
+/*
+  For sequential disk seeks the cost formula is:
+    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
+  
+  The cost of average seek 
+    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
+*/
+#define DISK_SEEK_BASE_COST ((double)0.5)
+
+#define BLOCKS_IN_AVG_SEEK  128
+
+#define DISK_SEEK_PROP_COST ((double)0.5/BLOCKS_IN_AVG_SEEK)
+
+
+/**
+  Number of rows in a reference table when refereed through a not unique key.
+  This value is only used when we don't know anything about the key
+  distribution.
+*/
+#define MATCHING_ROWS_IN_OTHER_TABLE 10
+
+#define RAID_BLOCK_SIZE 1024
+
+#define MY_CHARSET_BIN_MB_MAXLEN 1
+
+/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
+#define KEY_DEFAULT_PACK_LENGTH 8
+
+/** Characters shown for the command in 'show processlist'. */
+#define PROCESS_LIST_WIDTH 100
+/* Characters shown for the command in 'information_schema.processlist' */
+#define PROCESS_LIST_INFO_WIDTH 65535
+
+#define PRECISION_FOR_DOUBLE 53
+#define PRECISION_FOR_FLOAT  24
+
+/* -[digits].E+## */
+#define MAX_FLOAT_STR_LENGTH (FLT_DIG + 6)
+/* -[digits].E+### */
+#define MAX_DOUBLE_STR_LENGTH (DBL_DIG + 7)
+
+/*
+  Default time to wait before aborting a new client connection
+  that does not respond to "initial server greeting" timely
+*/
+#define CONNECT_TIMEOUT		10
+
+/* The following can also be changed from the command line */
+#define DEFAULT_CONCURRENCY	10
+#define DELAYED_LIMIT		100		/**< pause after xxx inserts */
+#define DELAYED_QUEUE_SIZE	1000
+#define DELAYED_WAIT_TIMEOUT	5*60		/**< Wait for delayed insert */
+#define FLUSH_TIME		0		/**< Don't flush tables */
+#define MAX_CONNECT_ERRORS	10		///< errors before disabling host
+
+#define LONG_TIMEOUT ((ulong) 3600L*24L*365L)
+
+/**
+  Maximum length of time zone name that we support (Time zone name is
+  char(64) in db). mysqlbinlog needs it.
+*/
+#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
+
+#if defined(__WIN__)
+#undef	FLUSH_TIME
+#define FLUSH_TIME	1800			/**< Flush every half hour */
+
+#define INTERRUPT_PRIOR -2
+#define CONNECT_PRIOR	-1
+#define WAIT_PRIOR	0
+#define QUERY_PRIOR	2
+#else
+#define INTERRUPT_PRIOR 10
+#define CONNECT_PRIOR	9
+#define WAIT_PRIOR	8
+#define QUERY_PRIOR	6
+#endif /* __WIN92__ */
+
+#endif /* SQL_CONST_INCLUDED */
diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc
index 3d7d248782b..455e7dc1e7b 100644
--- a/sql/sql_crypt.cc
+++ b/sql/sql_crypt.cc
@@ -26,7 +26,9 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_crypt.h"
+#include "password.h"
 
 void SQL_CRYPT::init(ulong *rand_nr)
 {
diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h
index dd1cba9ee0c..15cc495858b 100644
--- a/sql/sql_crypt.h
+++ b/sql/sql_crypt.h
@@ -21,6 +21,9 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "sql_list.h"                           /* Sql_alloc */
+#include "mysql_com.h"                          /* rand_struct */
+
 class SQL_CRYPT :public Sql_alloc
 {
   struct rand_struct rand,org_rand;
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 0391ce6dc72..59bf0764ada 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -16,10 +16,12 @@
 #pragma implementation                         /* gcc class implementation */
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sql_cursor.h"
 #include "sql_select.h"
 #include "probes_mysql.h"
+#include "sql_parse.h"                        // mysql_execute_command
 
 /****************************************************************************
   Declarations.
diff --git a/sql/sql_cursor.h b/sql/sql_cursor.h
index 1f19cbfdbcf..2a394e281b4 100644
--- a/sql/sql_cursor.h
+++ b/sql/sql_cursor.h
@@ -20,6 +20,10 @@
 #pragma interface                              /* gcc class interface */
 #endif
 
+#include "sql_class.h"                          /* Query_arena */
+
+class JOIN;
+
 /**
   @file
 
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index e700dd93a55..3bd89cb7302 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -16,7 +16,19 @@
 
 /* create and drop of databases */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_db.h"
+#include "sql_cache.h"                   // query_cache_*
+#include "lock.h"                        // wait_if_global_read_lock,
+                                         // start_waiting_global_read_lock
+#include "sql_table.h"                   // build_table_filename,
+                                         // filename_to_tablename
+#include "sql_rename.h"                  // mysql_rename_tables
+#include "sql_acl.h"                     // SELECT_ACL, DB_ACLS,
+                                         // acl_get, check_grant_db
+#include "sql_base.h"                    // wait_for_condition
+#include "log_event.h"                   // Query_log_event
 #include 
 #include "sp.h"
 #include "events.h"
diff --git a/sql/sql_db.h b/sql/sql_db.h
new file mode 100644
index 00000000000..96b3de80d3a
--- /dev/null
+++ b/sql/sql_db.h
@@ -0,0 +1,53 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_DB_INCLUDED
+#define SQL_DB_INCLUDED
+
+#include "hash.h"                               /* HASH */
+
+class THD;
+typedef struct charset_info_st CHARSET_INFO;
+typedef struct st_ha_create_information HA_CREATE_INFO;
+typedef struct st_mysql_lex_string LEX_STRING;
+
+int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
+bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
+bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
+bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db);
+bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
+                     bool force_switch);
+
+bool mysql_opt_change_db(THD *thd,
+                         const LEX_STRING *new_db_name,
+                         LEX_STRING *saved_db_name,
+                         bool force_switch,
+                         bool *cur_db_changed);
+bool my_database_names_init(void);
+void my_database_names_free(void);
+bool check_db_dir_existence(const char *db_name);
+bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create);
+bool load_db_opt_by_name(THD *thd, const char *db_name,
+                         HA_CREATE_INFO *db_create_info);
+CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
+bool my_dbopt_init(void);
+void my_dbopt_cleanup(void);
+
+extern int creating_database; // How many database locks are made
+extern HASH lock_db_cache;
+
+#define MY_DB_OPT_FILE "db.opt"
+
+#endif /* SQL_DB_INCLUDED */
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 58073a40319..2a8503077aa 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -19,11 +19,25 @@
   Multi-table deletes were introduced by Monty and Sinisa
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_delete.h"
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_base.h"                           // open_temprary_table
+#include "sql_table.h"                         // build_table_filename
+#include "lock.h"                              // lock_and_wait_for_table_name,
+                                               // unlock_table_name
+#include "sql_view.h"             // check_key_in_view, mysql_frm_type
+#include "sql_parse.h"            // mysql_init_select
+#include "sql_acl.h"              // *_ACL
+#include "filesort.h"             // filesort
+#include "sql_handler.h"          // mysql_ha_rm_tables
 #include "sql_select.h"
 #include "sp_head.h"
 #include "sql_trigger.h"
 #include "transaction.h"
+#include "records.h"                            // init_read_record,
+                                                // end_read_record
 
 /**
   Implement DELETE SQL word.
diff --git a/sql/sql_delete.h b/sql/sql_delete.h
new file mode 100644
index 00000000000..cbaa21cef25
--- /dev/null
+++ b/sql/sql_delete.h
@@ -0,0 +1,34 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_DELETE_INCLUDED
+#define SQL_DELETE_INCLUDED
+
+#include "my_base.h"                            /* ha_rows */
+
+class THD;
+class TABLE_LIST;
+class Item;
+
+typedef class Item COND;
+typedef struct st_sql_list SQL_LIST;
+
+int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
+bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
+                  SQL_LIST *order, ha_rows rows, ulonglong options,
+                  bool reset_auto_increment);
+bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
+
+#endif /* SQL_DELETE_INCLUDED */
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 24088872471..aea3b8b1d20 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -20,9 +20,12 @@
 */
 
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_derived.h"
 #include "sql_select.h"
-
+#include "sql_view.h"                         // check_duplicate_names
+#include "sql_acl.h"                          // SELECT_ACL
 
 
 /*
diff --git a/sql/sql_derived.h b/sql/sql_derived.h
new file mode 100644
index 00000000000..71dd929feca
--- /dev/null
+++ b/sql/sql_derived.h
@@ -0,0 +1,29 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_DERIVED_INCLUDED
+#define SQL_DERIVED_INCLUDED
+
+class TABLE_LIST;
+class THD;
+struct LEX;
+
+bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
+                                                      LEX *lex,
+                                                      TABLE_LIST *table));
+bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
+bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
+
+#endif /* SQL_DERIVED_INCLUDED */
diff --git a/sql/sql_do.cc b/sql/sql_do.cc
index 0f3a7e1ecef..79e488ac2a5 100644
--- a/sql/sql_do.cc
+++ b/sql/sql_do.cc
@@ -16,8 +16,12 @@
 
 /* Execute DO statement */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "transaction.h"
+#include "unireg.h"
+#include "sql_do.h"
+#include "sql_base.h"                           // setup_fields
+#include "sql_select.h"                         // free_underlaid_joins
 
 bool mysql_do(THD *thd, List &values)
 {
diff --git a/sql/sql_do.h b/sql/sql_do.h
new file mode 100644
index 00000000000..56479f8f88e
--- /dev/null
+++ b/sql/sql_do.h
@@ -0,0 +1,26 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_DO_INCLUDED
+#define SQL_DO_INCLUDED
+
+#include "sql_list.h"                           /* List */
+
+class THD;
+class Item;
+
+bool mysql_do(THD *thd, List &values);
+
+#endif /* SQL_DO_INCLUDED */
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index eeefdb99eed..cc6529f7b10 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -42,7 +42,8 @@ This file contains the implementation of error and warnings related
 
 ***********************************************************************/
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sql_error.h"
 #include "sp_rcontext.h"
 
diff --git a/sql/sql_error.h b/sql/sql_error.h
index ac86ca4770c..9e649a004df 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -19,6 +19,7 @@
 
 #include "sql_list.h" /* Sql_alloc, MEM_ROOT */
 #include "m_string.h" /* LEX_STRING */
+#include "sql_string.h"                        /* String */
 #include "mysql_com.h" /* MYSQL_ERRMSG_SIZE */
 
 class THD;
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index dfa06495e9d..23177b8f51a 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -51,7 +51,13 @@
   cursor points at the first record).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_handler.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_base.h"                           // close_thread_tables
+#include "lock.h"            // broadcast_refresh, mysql_unlock_tables
+#include "key.h"                                // key_copy
+#include "sql_base.h"                           // insert_fields
 #include "sql_select.h"
 #include 
 
diff --git a/sql/sql_handler.h b/sql/sql_handler.h
new file mode 100644
index 00000000000..d4a528d0bd0
--- /dev/null
+++ b/sql/sql_handler.h
@@ -0,0 +1,35 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_HANDLER_INCLUDED
+#define SQL_HANDLER_INCLUDED
+
+#include "sql_class.h"                 /* enum_ha_read_mode */
+#include "my_base.h"                   /* ha_rkey_function, ha_rows */
+#include "sql_list.h"                  /* List */
+
+class THD;
+class TABLE_LIST;
+
+bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen);
+bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
+bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *,
+                   List *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
+void mysql_ha_flush(THD *thd);
+void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
+void mysql_ha_cleanup(THD *thd);
+void mysql_ha_move_tickets_after_trans_sentinel(THD *thd);
+
+#endif /* SQL_HANDLER_INCLUDED */
diff --git a/sql/sql_help.cc b/sql/sql_help.cc
index e9b15e07e9d..7bea236269a 100644
--- a/sql/sql_help.cc
+++ b/sql/sql_help.cc
@@ -13,7 +13,13 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_help.h"
+#include "sql_table.h"                          // primary_key_name
+#include "sql_base.h"               // REPORT_ALL_ERRORS, setup_tables
+#include "opt_range.h"              // SQL_SELECT
+#include "records.h"          // init_read_record, end_read_record
 
 struct st_find_field
 {
diff --git a/sql/sql_help.h b/sql/sql_help.h
new file mode 100644
index 00000000000..74cff691730
--- /dev/null
+++ b/sql/sql_help.h
@@ -0,0 +1,28 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_HELP_INCLUDED
+#define SQL_HELP_INCLUDED
+
+class THD;
+
+
+/*
+  Function prototypes
+*/
+
+bool mysqld_help (THD *thd, const char *text);
+
+#endif /* SQL_HELP_INCLUDED */
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 7423dd9d292..216e3a65dfe 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -54,12 +54,23 @@
 
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_insert.h"
+#include "sql_update.h"                         // compare_record
+#include "sql_base.h"                           // close_thread_tables
+#include "sql_cache.h"                          // query_cache_*
+#include "key.h"                                // key_copy
+#include "lock.h"                               // mysql_unlock_tables
 #include "sp_head.h"
+#include "sql_view.h"         // check_key_in_view, insert_view_fields
+#include "sql_table.h"        // mysql_create_table_no_lock
+#include "sql_acl.h"          // *_ACL, check_grant_all_columns
 #include "sql_trigger.h"
 #include "sql_select.h"
 #include "sql_show.h"
 #include "slave.h"
+#include "sql_parse.h"                          // end_active_trans
 #include "rpl_mi.h"
 #include "transaction.h"
 #include "sql_audit.h"
diff --git a/sql/sql_insert.h b/sql/sql_insert.h
new file mode 100644
index 00000000000..9511cee8526
--- /dev/null
+++ b/sql/sql_insert.h
@@ -0,0 +1,49 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_INSERT_INCLUDED
+#define SQL_INSERT_INCLUDED
+
+#include "sql_class.h"                          /* enum_duplicates */
+#include "sql_list.h"
+
+/* Instead of including sql_lex.h we add this typedef here */
+typedef List List_item;
+typedef struct st_copy_info COPY_INFO;
+
+bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
+                          List &fields, List_item *values,
+                          List &update_fields,
+                          List &update_values, enum_duplicates duplic,
+                          COND **where, bool select_insert,
+                          bool check_fields, bool abort_on_warning);
+bool mysql_insert(THD *thd,TABLE_LIST *table,List &fields,
+                  List &values, List &update_fields,
+                  List &update_values, enum_duplicates flag,
+                  bool ignore);
+void upgrade_lock_type_for_insert(THD *thd, thr_lock_type *lock_type,
+                                  enum_duplicates duplic,
+                                  bool is_multi_insert);
+int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
+                                           TABLE_LIST *table_list);
+void prepare_triggers_for_insert_stmt(TABLE *table);
+int write_record(THD *thd, TABLE *table, COPY_INFO *info);
+void kill_delayed_threads(void);
+
+#ifdef EMBEDDED_LIBRARY
+inline void kill_delayed_threads(void) {}
+#endif
+
+#endif /* SQL_INSERT_INCLUDED */
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 14b5e160629..6384aa575fe 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -17,7 +17,11 @@
 /* A lexical scanner on a temporary buffer with a yacc interface */
 
 #define MYSQL_LEX 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_class.h"                          // sql_lex.h: SQLCOM_END
+#include "sql_lex.h"
+#include "sql_parse.h"                          // add_to_list
 #include "item_create.h"
 #include 
 #include 
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 0b27f73e763..cb8a96ad2ed 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -20,6 +20,11 @@
 #ifndef SQL_LEX_INCLUDED
 #define SQL_LEX_INCLUDED
 
+#include "violite.h"                            /* SSL_type */
+#include "sql_trigger.h"
+#include "item.h"               /* From item_subselect.h: subselect_union_engine */
+#include "thr_lock.h"                  /* thr_lock_type, TL_UNLOCK */
+
 /* YACC and LEX Definitions */
 
 /* These may not be declared yet */
@@ -35,6 +40,12 @@ class partition_info;
 class Event_parse_data;
 class set_var_base;
 class sys_var;
+class Item_func_match;
+class Alter_drop;
+class Alter_column;
+class Key;
+class File_parser;
+class Key_part_spec;
 
 /**
   used by the parser to store internal variable name
@@ -55,6 +66,7 @@ struct sys_var_with_base
 #else
 #include "lex_symbol.h"
 #if MYSQL_LEX
+#include "item_func.h"            /* Cast_target used in sql_yacc.h */
 #include "sql_yacc.h"
 #define LEX_YYSTYPE YYSTYPE *
 #else
@@ -192,6 +204,12 @@ enum enum_drop_mode
   DROP_RESTRICT // RESTRICT option
 };
 
+/* Options to add_table_to_list() */
+#define TL_OPTION_UPDATING	1
+#define TL_OPTION_FORCE_INDEX	2
+#define TL_OPTION_IGNORE_LEAVES 4
+#define TL_OPTION_ALIAS         8
+
 typedef List List_item;
 
 /* SERVERS CACHE CHANGES */
@@ -2287,6 +2305,7 @@ extern bool is_lex_native_function(const LEX_STRING *name);
 */
 
 void my_missing_function_error(const LEX_STRING &token, const char *name);
+bool is_keyword(const char *name, uint len);
 
 #endif /* MYSQL_SERVER */
 #endif /* SQL_LEX_INCLUDED */
diff --git a/sql/sql_list.cc b/sql/sql_list.cc
index a256212471d..31f0ba28b85 100644
--- a/sql/sql_list.cc
+++ b/sql/sql_list.cc
@@ -18,6 +18,7 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
+#include "unireg.h"
 #include "sql_list.h"
 
 list_node end_of_list;
diff --git a/sql/sql_list.h b/sql/sql_list.h
index fdc80b116a7..60d9697a606 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -26,6 +26,11 @@
 
 void *sql_alloc(size_t);
 
+#include "my_sys.h"                    /* alloc_root, TRASH, MY_WME,
+                                          MY_FAE, MY_ALLOW_ZERO_PTR */
+#include "m_string.h"                           /* bfill */
+#include "thr_malloc.h"                         /* sql_alloc */
+
 /* mysql standard class memory allocator */
 
 class Sql_alloc
@@ -61,6 +66,57 @@ public:
 };
 
 
+/**
+   Struct to handle simple linked lists.
+
+   @todo What is the relation between this class and list_node, below?
+   /Matz
+
+   @see list_node, base_list, List
+
+*/
+typedef struct st_sql_list {
+  uint elements;
+  uchar *first;
+  uchar **next;
+
+  st_sql_list() {}                              /* Remove gcc warning */
+  inline void empty()
+  {
+    elements=0;
+    first=0;
+    next= &first;
+  }
+  inline void link_in_list(uchar *element,uchar **next_ptr)
+  {
+    elements++;
+    (*next)=element;
+    next= next_ptr;
+    *next=0;
+  }
+  inline void save_and_clear(struct st_sql_list *save)
+  {
+    *save= *this;
+    empty();
+  }
+  inline void push_front(struct st_sql_list *save)
+  {
+    *save->next= first;				/* link current list last */
+    first= save->first;
+    elements+= save->elements;
+  }
+  inline void push_back(struct st_sql_list *save)
+  {
+    if (save->first)
+    {
+      *next= save->first;
+      next= save->next;
+      elements+= save->elements;
+    }
+  }
+} SQL_LIST;
+
+
 /*
   Basic single linked list
   Used for item and item_buffs.
@@ -637,4 +693,7 @@ list_copy_and_replace_each_value(List &list, MEM_ROOT *mem_root)
     it.replace(el->clone(mem_root));
 }
 
+void free_list(I_List  *list);
+void free_list(I_List  *list);
+
 #endif // INCLUDES_MYSQL_SQL_LIST_H
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 3f49543c69d..87a347b9f98 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -17,8 +17,21 @@
 /* Copy data from a textfile to table */
 /* 2006-12 Erik Wetterberg : LOAD XML added */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_load.h"
+#include "sql_load.h"
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_base.h"          // fill_record_n_invoke_before_triggers
 #include 
+#include "sql_view.h"                           // check_key_in_view
+#include "sql_insert.h" // check_that_all_fields_are_given_values,
+                        // prepare_triggers_for_insert_stmt,
+                        // write_record
+#include "sql_acl.h"    // INSERT_ACL, UPDATE_ACL
+#include "log_event.h"  // Delete_file_log_event,
+                        // Execute_load_query_log_event,
+                        // LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F
 #include 
 #include "rpl_mi.h"
 #include "sql_repl.h"
diff --git a/sql/sql_load.h b/sql/sql_load.h
new file mode 100644
index 00000000000..344b869854a
--- /dev/null
+++ b/sql/sql_load.h
@@ -0,0 +1,34 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_LOAD_INCLUDED
+#define SQL_LOAD_INCLUDED
+
+#include "sql_list.h"                           /* List */
+
+class Item;
+
+#include "sql_class.h"                          /* enum_duplicates */
+
+class sql_exchange;
+
+int mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list,
+	        List &fields_vars, List &set_fields,
+                List &set_values_list,
+                enum enum_duplicates handle_duplicates, bool ignore,
+                bool local_file);
+
+
+#endif /* SQL_LOAD_INCLUDED */
diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc
index 9b1bb67ca06..abd9c395083 100644
--- a/sql/sql_locale.cc
+++ b/sql/sql_locale.cc
@@ -20,7 +20,11 @@
   !! This file is built from my_locale.pl !!
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_locale.h"
+#include "sql_class.h"                          // THD
+#include "my_sys.h"                             // MY_*, NullS, NULL
 
 
 enum err_msgs_index
diff --git a/sql/sql_locale.h b/sql/sql_locale.h
new file mode 100644
index 00000000000..e62660aaa47
--- /dev/null
+++ b/sql/sql_locale.h
@@ -0,0 +1,78 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_LOCALE_INCLUDED
+#define SQL_LOCALE_INCLUDED
+
+typedef struct my_locale_errmsgs
+{
+  const char *language;
+  const char **errmsgs;
+} MY_LOCALE_ERRMSGS;
+
+#include "my_global.h"                          /* uint */
+
+typedef struct st_typelib TYPELIB;
+
+class MY_LOCALE
+{
+public:
+  uint  number;
+  const char *name;
+  const char *description;
+  const bool is_ascii;
+  TYPELIB *month_names;
+  TYPELIB *ab_month_names;
+  TYPELIB *day_names;
+  TYPELIB *ab_day_names;
+  uint max_month_name_length;
+  uint max_day_name_length;
+  uint decimal_point;
+  uint thousand_sep;
+  const char *grouping;
+  MY_LOCALE_ERRMSGS *errmsgs;
+  MY_LOCALE(uint number_par,
+            const char *name_par, const char *descr_par, bool is_ascii_par,
+            TYPELIB *month_names_par, TYPELIB *ab_month_names_par,
+            TYPELIB *day_names_par, TYPELIB *ab_day_names_par,
+            uint max_month_name_length_par, uint max_day_name_length_par,
+            uint decimal_point_par, uint thousand_sep_par,
+            const char *grouping_par, MY_LOCALE_ERRMSGS *errmsgs_par) :
+    number(number_par),
+    name(name_par), description(descr_par), is_ascii(is_ascii_par),
+    month_names(month_names_par), ab_month_names(ab_month_names_par),
+    day_names(day_names_par), ab_day_names(ab_day_names_par),
+    max_month_name_length(max_month_name_length_par),
+    max_day_name_length(max_day_name_length_par),
+    decimal_point(decimal_point_par),
+    thousand_sep(thousand_sep_par),
+    grouping(grouping_par),
+    errmsgs(errmsgs_par)
+  {}
+};
+/* Exported variables */
+
+extern MY_LOCALE my_locale_en_US;
+extern MY_LOCALE *my_locales[];
+extern MY_LOCALE *my_default_lc_messages;
+extern MY_LOCALE *my_default_lc_time_names;
+
+/* Exported functions */
+
+MY_LOCALE *my_locale_by_name(const char *name);
+MY_LOCALE *my_locale_by_number(uint number);
+void cleanup_errmsgs(void);
+
+#endif /* SQL_LOCALE_INCLUDED */
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index 4f3e4e1c6d1..e9c9402a89a 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -21,8 +21,10 @@
  *   o Berkeley DB: removing unneeded log files.
  */
 
-#include "mysql_priv.h"
-
+#include "sql_priv.h"
+#include "sql_manager.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_base.h"                           // flush_tables
 
 static bool volatile manager_thread_in_use;
 static bool abort_manager;
diff --git a/sql/sql_manager.h b/sql/sql_manager.h
new file mode 100644
index 00000000000..a0ef8080aa7
--- /dev/null
+++ b/sql/sql_manager.h
@@ -0,0 +1,23 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_MANAGER_INCLUDED
+#define SQL_MANAGER_INCLUDED
+
+void start_handle_manager();
+void stop_handle_manager();
+bool mysql_manager_submit(void (*action)());
+
+#endif /* SQL_MANAGER_INCLUDED */
diff --git a/sql/sql_map.cc b/sql/sql_map.cc
index e4e85c51d17..35a248e5465 100644
--- a/sql/sql_map.cc
+++ b/sql/sql_map.cc
@@ -18,7 +18,11 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_map.h"                            // mapped_files
+#include "sql_class.h"                          // THD
+
 #include 
 #ifdef HAVE_SYS_MMAN_H
 #include 
diff --git a/sql/sql_map.h b/sql/sql_map.h
index 5ae260841e0..be1c145df3f 100644
--- a/sql/sql_map.h
+++ b/sql/sql_map.h
@@ -23,6 +23,9 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "my_base.h"                            /* ha_rows */
+#include "sql_list.h"                           /* ilink */
+
 class mapped_files;
 mapped_files *map_file(const char * name,uchar *magic,uint magic_length);
 void unmap_file(mapped_files *map);
diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc
index dccfcbaf8ac..cdfa5e3f496 100644
--- a/sql/sql_olap.cc
+++ b/sql/sql_olap.cc
@@ -31,7 +31,8 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sql_select.h"
 
 
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 23e0d8c0d70..3dc372f7304 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -14,7 +14,67 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #define MYSQL_LEX 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_parse.h"        // sql_kill, *_precheck, *_prepare
+#include "lock.h"             // wait_if_global_read_lock,
+                              // unlock_global_read_lock,
+                              // try_transactional_lock,
+                              // check_transactional_lock,
+                              // set_handler_table_locks,
+                              // start_waiting_global_read_lock,
+                              // lock_global_read_lock,
+                              // make_global_read_lock_block_commit
+#include "sql_base.h"         // find_temporary_tablesx
+#include "sql_cache.h"        // QUERY_CACHE_FLAGS_SIZE, query_cache_*
+#include "sql_show.h"         // mysqld_list_*, mysqld_show_*,
+                              // calc_sum_of_all_status
+#include "mysqld.h"
+#include "sql_locale.h"                         // my_locale_en_US
+#include "log.h"                                // flush_error_log
+#include "sql_view.h"         // mysql_create_view, mysql_drop_view
+#include "sql_delete.h"       // mysql_truncate, mysql_delete
+#include "sql_insert.h"       // mysql_insert
+#include "sql_update.h"       // mysql_update, mysql_multi_update
+#include "sql_partition.h"    // struct partition_info
+#include "sql_db.h"           // mysql_change_db, mysql_create_db,
+                              // mysql_rm_db, mysql_upgrade_db,
+                              // mysql_alter_db,
+                              // check_db_dir_existence,
+                              // my_dbopt_cleanup
+#include "sql_table.h"        // mysql_create_like_table,
+                              // mysql_create_table,
+                              // mysql_alter_table,
+                              // mysql_recreate_table,
+                              // mysql_backup_table,
+                              // mysql_restore_table
+#include "sql_connect.h"      // check_user,
+                              // decrease_user_connections,
+                              // thd_init_client_charset, check_mqh,
+                              // reset_mqh
+#include "sql_rename.h"       // mysql_rename_table
+#include "sql_tablespace.h"   // mysql_alter_tablespace
+#include "hostname.h"         // hostname_cache_refresh
+#include "sql_acl.h"          // *_ACL, check_grant, is_acl_user,
+                              // has_any_table_level_privileges,
+                              // mysql_drop_user, mysql_rename_user,
+                              // check_grant_routine,
+                              // mysql_routine_grant,
+                              // mysql_show_grants,
+                              // sp_grant_privileges, ...
+#include "sql_test.h"         // mysql_print_status
+#include "sql_select.h"       // handle_select, mysql_select,
+                              // mysql_explain_union
+#include "sql_load.h"         // mysql_load
+#include "sql_servers.h"      // create_servers, alter_servers,
+                              // drop_servers, servers_reload
+#include "sql_handler.h"      // mysql_ha_open, mysql_ha_close,
+                              // mysql_ha_read
+#include "sql_binlog.h"       // mysql_client_binlog_statement
+#include "sql_do.h"           // mysql_do
+#include "sql_help.h"         // mysqld_help
+#include "rpl_constants.h"    // Incident, INCIDENT_LOST_EVENTS
+#include "log_event.h"
 #include "sql_repl.h"
 #include "rpl_filter.h"
 #include "repl_failsafe.h"
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
new file mode 100644
index 00000000000..9ef6d1b4c2f
--- /dev/null
+++ b/sql/sql_parse.h
@@ -0,0 +1,210 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_PARSE_INCLUDED
+#define SQL_PARSE_INCLUDED
+
+#include "sql_acl.h"                            /* GLOBAL_ACLS */
+
+class Comp_creator;
+class Item;
+class Object_creation_ctx;
+class Parser_state;
+class TABLE_LIST;
+class THD;
+class Table_ident;
+struct LEX;
+
+enum enum_mysql_completiontype {
+  ROLLBACK_RELEASE=-2, ROLLBACK=1,  ROLLBACK_AND_CHAIN=7,
+  COMMIT_RELEASE=-1,   COMMIT=0,    COMMIT_AND_CHAIN=6
+};
+
+extern "C" int test_if_data_home_dir(const char *dir);
+
+bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
+bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
+int mysql_multi_update_prepare(THD *thd);
+int mysql_multi_delete_prepare(THD *thd);
+bool mysql_insert_select_prepare(THD *thd);
+bool update_precheck(THD *thd, TABLE_LIST *tables);
+bool delete_precheck(THD *thd, TABLE_LIST *tables);
+bool insert_precheck(THD *thd, TABLE_LIST *tables);
+bool create_table_precheck(THD *thd, TABLE_LIST *tables,
+                           TABLE_LIST *create_table);
+
+bool parse_sql(THD *thd,
+               Parser_state *parser_state,
+               Object_creation_ctx *creation_ctx);
+
+uint kill_one_thread(THD *thd, ulong id, bool only_kill_query);
+void sql_kill(THD *thd, ulong id, bool only_kill_query);
+
+void free_items(Item *item);
+void cleanup_items(Item *item);
+
+Comp_creator *comp_eq_creator(bool invert);
+Comp_creator *comp_ge_creator(bool invert);
+Comp_creator *comp_gt_creator(bool invert);
+Comp_creator *comp_le_creator(bool invert);
+Comp_creator *comp_lt_creator(bool invert);
+Comp_creator *comp_ne_creator(bool invert);
+
+int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
+                         enum enum_schema_tables schema_table_idx);
+void get_default_definer(THD *thd, LEX_USER *definer);
+LEX_USER *create_default_definer(THD *thd);
+LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name);
+LEX_USER *get_current_user(THD *thd, LEX_USER *user);
+bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
+                              uint max_byte_length);
+bool check_string_char_length(LEX_STRING *str, const char *err_msg,
+                              uint max_char_length, CHARSET_INFO *cs,
+                              bool no_error);
+CHARSET_INFO* merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl);
+bool check_host_name(LEX_STRING *str);
+bool check_identifier_name(LEX_STRING *str, uint max_char_length,
+                           uint err_code, const char *param_for_err_msg);
+bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
+bool is_update_query(enum enum_sql_command command);
+bool is_log_table_write_query(enum enum_sql_command command);
+bool alloc_query(THD *thd, const char *packet, uint packet_length);
+void mysql_init_select(LEX *lex);
+void mysql_parse(THD *thd, const char *inBuf, uint length,
+                 const char ** semicolon);
+void mysql_reset_thd_for_next_command(THD *thd);
+bool mysql_new_select(LEX *lex, bool move_down);
+void create_select_for_variable(const char *var_name);
+void create_table_set_open_action_and_adjust_tables(LEX *lex);
+void mysql_init_multi_delete(LEX *lex);
+bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
+void create_table_set_open_action_and_adjust_tables(LEX *lex);
+pthread_handler_t handle_bootstrap(void *arg);
+bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
+                          bool *write_to_binlog);
+int mysql_execute_command(THD *thd);
+bool do_command(THD *thd);
+void do_handle_bootstrap(THD *thd);
+bool dispatch_command(enum enum_server_command command, THD *thd,
+		      char* packet, uint packet_length);
+void log_slow_statement(THD *thd);
+bool append_file_to_dir(THD *thd, const char **filename_ptr,
+                        const char *table_name);
+bool append_file_to_dir(THD *thd, const char **filename_ptr,
+                        const char *table_name);
+void execute_init_command(THD *thd, LEX_STRING *init_command,
+                          mysql_rwlock_t *var_lock);
+bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
+		       char *length, char *decimal,
+		       uint type_modifier,
+		       Item *default_value, Item *on_update_value,
+		       LEX_STRING *comment,
+		       char *change, List *interval_list,
+		       CHARSET_INFO *cs,
+		       uint uint_geom_type);
+bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc);
+void add_join_on(TABLE_LIST *b,Item *expr);
+void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List *using_fields,
+                      SELECT_LEX *lex);
+bool add_proc_to_list(THD *thd, Item *item);
+bool push_new_name_resolution_context(THD *thd,
+                                      TABLE_LIST *left_op,
+                                      TABLE_LIST *right_op);
+void store_position_for_column(const char *name);
+void init_update_queries(void);
+bool check_simple_select();
+Item *negate_expression(THD *thd, Item *expr);
+bool check_stack_overrun(THD *thd, long margin, uchar *dummy);
+
+bool begin_trans(THD *thd);
+bool end_active_trans(THD *thd);
+int end_trans(THD *thd, enum enum_mysql_completiontype completion);
+
+
+/* Variables */
+
+extern const char* any_db;
+extern uint sql_command_flags[];
+extern uint server_command_flags[];
+extern const LEX_STRING command_name[];
+extern uint server_command_flags[];
+
+/* Inline functions */
+inline bool check_identifier_name(LEX_STRING *str, uint err_code)
+{
+  return check_identifier_name(str, NAME_CHAR_LEN, err_code, "");
+}
+
+inline bool check_identifier_name(LEX_STRING *str)
+{
+  return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
+}
+
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
+bool check_single_table_access(THD *thd, ulong privilege,
+			   TABLE_LIST *tables, bool no_errors);
+bool check_routine_access(THD *thd,ulong want_access,char *db,char *name,
+			  bool is_proc, bool no_errors);
+bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table);
+bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc);
+bool check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
+                  GRANT_INTERNAL_INFO *grant_internal_info,
+                  bool dont_check_global_grants, bool no_errors);
+bool check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
+                        bool any_combination_of_privileges_will_do,
+                        uint number,
+                        bool no_errors);
+#else
+inline bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables)
+{ return false; }
+inline bool check_single_table_access(THD *thd, ulong privilege,
+			   TABLE_LIST *tables, bool no_errors)
+{ return false; }
+inline bool check_routine_access(THD *thd,ulong want_access,char *db,
+                                 char *name, bool is_proc, bool no_errors)
+{ return false; }
+inline bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table)
+{ return false; }
+inline bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
+{ return false; }
+inline bool check_some_routine_access(THD *thd, const char *db,
+                                      const char *name, bool is_proc)
+{ return false; }
+inline bool check_access(THD *thd, ulong access, const char *db,
+                         ulong *save_priv, bool no_grant, bool no_errors,
+                         bool schema_db)
+{
+  if (save_priv)
+    *save_priv= GLOBAL_ACLS;
+  return false;
+}
+inline bool
+check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
+                   bool any_combination_of_privileges_will_do,
+                   uint number,
+                   bool no_errors)
+{ return false; }
+#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
+
+#ifdef EMBEDDED_LIBRARY
+#define check_stack_overrun(A, B, C) 0
+#endif /* EMBEDDED_LIBRARY */
+
+/* These were under the INNODB_COMPATIBILITY_HOOKS */
+
+bool check_global_access(THD *thd, ulong want_access);
+
+#endif /* SQL_PARSE_INCLUDED */
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 490ef4e9e27..0eb92dc23a9 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -46,12 +46,26 @@
 /* Some general useful functions */
 
 #define MYSQL_LEX 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_partition.h"
+#include "key.h"                            // key_restore
+#include "sql_parse.h"                      // parse_sql
+#include "sql_cache.h"                      // query_cache_invalidate3
+#include "lock.h"                           // mysql_lock_remove
+#include "sql_show.h"                       // append_identifier
 #include 
 #include 
 #include "my_md5.h"
 #include "transaction.h"
 
+#include "sql_base.h"                           // close_thread_tables
+#include "sql_table.h"                  // build_table_filename,
+                                        // build_table_shadow_filename,
+                                        // table_to_filename
+#include "opt_range.h"                  // store_key_image_to_rec
+#include "sql_analyse.h"                // append_escaped
+
 #ifdef WITH_PARTITION_STORAGE_ENGINE
 #include "ha_partition.h"
 
diff --git a/sql/sql_partition.h b/sql/sql_partition.h
index 7ac1415c158..8542074e718 100644
--- a/sql/sql_partition.h
+++ b/sql/sql_partition.h
@@ -20,12 +20,51 @@
 #pragma interface				/* gcc class implementation */
 #endif
 
+#include "sql_list.h"                           /* List */
+#include "table.h"                              /* TABLE_LIST */
+
+class Alter_info;
+class Field;
+class String;
+class handler;
+class partition_info;
+struct TABLE;
+struct TABLE_LIST;
+typedef struct st_bitmap MY_BITMAP;
+typedef struct st_ha_create_information HA_CREATE_INFO;
+typedef struct st_key KEY;
+typedef struct st_key_range key_range;
+
 /* Flags for partition handlers */
 #define HA_CAN_PARTITION       (1 << 0) /* Partition support */
 #define HA_CAN_UPDATE_PARTITION_KEY (1 << 1)
 #define HA_CAN_PARTITION_UNIQUE (1 << 2)
 #define HA_USE_AUTO_PARTITION (1 << 3)
 
+#define NORMAL_PART_NAME 0
+#define TEMP_PART_NAME 1
+#define RENAMED_PART_NAME 2
+
+typedef struct st_lock_param_type
+{
+  TABLE_LIST *table_list;
+  ulonglong copied;
+  ulonglong deleted;
+  THD *thd;
+  HA_CREATE_INFO *create_info;
+  Alter_info *alter_info;
+  TABLE *table;
+  KEY *key_info_buffer;
+  const char *db;
+  const char *table_name;
+  uchar *pack_frm_data;
+  uint key_count;
+  uint db_options;
+  size_t pack_frm_len;
+  partition_info *part_info;
+} ALTER_PARTITION_PARAM_TYPE;
+
+
 /*typedef struct {
   ulonglong data_file_length;
   ulonglong max_data_file_length;
@@ -101,6 +140,7 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
 bool check_part_func_fields(Field **ptr, bool ok_with_charsets);
 bool field_is_partition_charset(Field *field);
 Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs);
+void mem_alloc_error(size_t size);
 
 /*
   A "Get next" function for partition iterator.
@@ -220,4 +260,39 @@ typedef int (*get_partitions_in_range_iter)(partition_info *part_info,
 
 #include "partition_info.h"
 
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+uint fast_alter_partition_table(THD *thd, TABLE *table,
+                                Alter_info *alter_info,
+                                HA_CREATE_INFO *create_info,
+                                TABLE_LIST *table_list,
+                                char *db,
+                                const char *table_name,
+                                uint fast_alter_partition);
+uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
+                    enum partition_state part_state);
+uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
+                           HA_CREATE_INFO *create_info,
+                           handlerton *old_db_type,
+                           bool *partition_changed,
+                           uint *fast_alter_partition);
+char *generate_partition_syntax(partition_info *part_info,
+                                uint *buf_length, bool use_sql_alloc,
+                                bool show_partition_options,
+                                HA_CREATE_INFO *create_info,
+                                Alter_info *alter_info);
+#endif
+
+void create_partition_name(char *out, const char *in1,
+                           const char *in2, uint name_variant,
+                           bool translate);
+void create_subpartition_name(char *out, const char *in1,
+                              const char *in2, const char *in3,
+                              uint name_variant);
+
+void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
+void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
+                       const uchar *old_buf);
+
+extern const LEX_STRING partition_keywords[];
+
 #endif /* SQL_PARTITION_INCLUDED */
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 3ff5e91ccb6..31e0cced207 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -13,10 +13,24 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
+#include "sql_priv.h"                         // SHOW_MY_BOOL
+#include "unireg.h"
+#include "my_global.h"                       // REQUIRED by m_string.h
+#include "sql_class.h"                          // set_var.h: THD
 #include "sys_vars_shared.h"
+#include "sql_locale.h"
+#include "sql_plugin.h"
+#include "sql_parse.h"          // check_table_access
+#include "sql_base.h"                           // close_thread_tables
+#include "key.h"                                // key_copy
+#include "sql_show.h"           // remove_status_vars, add_status_vars
+#include "strfunc.h"            // find_set
+#include "sql_acl.h"                       // *_ACL
+#include "records.h"          // init_read_record, end_read_record
 #include 
 #include 
 #include 
+#include "lock.h"                               // MYSQL_LOCK_IGNORE_TIMEOUT
 #define REPORT_TO_LOG  1
 #define REPORT_TO_USER 2
 
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 1a870ec260e..e7ecca029b9 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -16,6 +16,22 @@
 #ifndef _sql_plugin_h
 #define _sql_plugin_h
 
+/*
+  the following #define adds server-only members to enum_mysql_show_type,
+  that is defined in plugin.h
+*/
+#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
+            SHOW_KEY_CACHE_LONGLONG, SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
+            SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
+            SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS, SHOW_LEX_STRING
+#include 
+#undef SHOW_always_last
+
+#include "m_string.h"                       /* LEX_STRING */
+#include "my_alloc.h"                       /* MEM_ROOT */
+
+#include "my_sys.h"                         /* CALLER_INFO_PROTO */
+
 class sys_var;
 enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
 
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 94a35db3a2d..89d450d9061 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -83,10 +83,23 @@ When one supplies long data for a placeholder:
     at statement execute.
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_class.h"                          // set_var.h: THD
 #include "set_var.h"
 #include "sql_prepare.h"
+#include "sql_parse.h" // insert_precheck, update_precheck, delete_precheck
+#include "sql_base.h"  // close_thread_tables
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_view.h"                          // create_view_precheck
+#include "sql_delete.h"                        // mysql_prepare_delete
 #include "sql_select.h" // for JOIN
+#include "sql_insert.h" // upgrade_lock_type_for_insert, mysql_prepare_insert
+#include "sql_update.h" // mysql_prepare_update
+#include "sql_db.h"     // mysql_opt_change_db, mysql_change_db
+#include "sql_acl.h"    // *_ACL
+#include "sql_derived.h" // mysql_derived_prepare,
+                         // mysql_handle_derived
 #include "sql_cursor.h"
 #include "sp_head.h"
 #include "sp.h"
@@ -98,6 +111,7 @@ When one supplies long data for a placeholder:
 #else
 #include 
 #endif
+#include "lock.h"                               // MYSQL_OPEN_FORCE_SHARED_MDL
 
 /**
   A result class used to send cursor rows using the binary protocol.
diff --git a/sql/sql_priv.h b/sql/sql_priv.h
new file mode 100644
index 00000000000..cc67fa9c010
--- /dev/null
+++ b/sql/sql_priv.h
@@ -0,0 +1,265 @@
+/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/**
+  @file
+
+  @details
+  Mostly this file is used in the server. But a little part of it is used in
+  mysqlbinlog too (definition of SELECT_DISTINCT and others).
+  The consequence is that 90% of the file is wrapped in \#ifndef MYSQL_CLIENT,
+  except the part which must be in the server and in the client.
+*/
+
+#ifndef MYSQL_PRIV_H
+#define MYSQL_PRIV_H
+
+#ifndef MYSQL_CLIENT
+
+/*
+  Generates a warning that a feature is deprecated. After a specified
+  version asserts that the feature is removed.
+
+  Using it as
+
+  WARN_DEPRECATED(thd, 6,2, "BAD", "'GOOD'");
+
+  Will result in a warning
+ 
+  "The syntax 'BAD' is deprecated and will be removed in MySQL 6.2. Please
+   use 'GOOD' instead"
+
+   Note that in macro arguments BAD is not quoted, while 'GOOD' is.
+   Note that the version is TWO numbers, separated with a comma
+   (two macro arguments, that is)
+*/
+#define WARN_DEPRECATED(Thd,VerHi,VerLo,Old,New)                            \
+  do {                                                                      \
+    compile_time_assert(MYSQL_VERSION_ID < VerHi * 10000 + VerLo * 100);    \
+    if (((THD *) Thd) != NULL)                                              \
+      push_warning_printf(((THD *) Thd), MYSQL_ERROR::WARN_LEVEL_WARN,      \
+                        ER_WARN_DEPRECATED_SYNTAX,                          \
+                        ER(ER_WARN_DEPRECATED_SYNTAX),                      \
+                        (Old), (New));                                      \
+    else                                                                    \
+      sql_print_warning("The syntax '%s' is deprecated and will be removed " \
+                        "in a future release. Please use %s instead.",      \
+                        (Old), (New));                                      \
+  } while(0)
+
+extern char err_shared_dir[];
+
+/*************************************************************************/
+
+#endif
+
+/*
+   This is included in the server and in the client.
+   Options for select set by the yacc parser (stored in lex->options).
+
+   NOTE
+   log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
+   options list are written into binlog. These options can NOT change their
+   values, or it will break replication between version.
+
+   context is encoded as following:
+   SELECT - SELECT_LEX_NODE::options
+   THD    - THD::options
+   intern - neither. used only as
+            func(..., select_node->options | thd->options | OPTION_XXX, ...)
+
+   TODO: separate three contexts above, move them to separate bitfields.
+*/
+
+#define SELECT_DISTINCT         (1ULL << 0)     // SELECT, user
+#define SELECT_STRAIGHT_JOIN    (1ULL << 1)     // SELECT, user
+#define SELECT_DESCRIBE         (1ULL << 2)     // SELECT, user
+#define SELECT_SMALL_RESULT     (1ULL << 3)     // SELECT, user
+#define SELECT_BIG_RESULT       (1ULL << 4)     // SELECT, user
+#define OPTION_FOUND_ROWS       (1ULL << 5)     // SELECT, user
+#define OPTION_TO_QUERY_CACHE   (1ULL << 6)     // SELECT, user
+#define SELECT_NO_JOIN_CACHE    (1ULL << 7)     // intern
+/** always the opposite of OPTION_NOT_AUTOCOMMIT except when in fix_autocommit() */
+#define OPTION_AUTOCOMMIT       (1ULL << 8)    // THD, user
+#define OPTION_BIG_SELECTS      (1ULL << 9)     // THD, user
+#define OPTION_LOG_OFF          (1ULL << 10)    // THD, user
+#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11)   // THD, user, unused
+#define TMP_TABLE_ALL_COLUMNS   (1ULL << 12)    // SELECT, intern
+#define OPTION_WARNINGS         (1ULL << 13)    // THD, user
+#define OPTION_AUTO_IS_NULL     (1ULL << 14)    // THD, user, binlog
+#define OPTION_FOUND_COMMENT    (1ULL << 15)    // SELECT, intern, parser
+#define OPTION_SAFE_UPDATES     (1ULL << 16)    // THD, user
+#define OPTION_BUFFER_RESULT    (1ULL << 17)    // SELECT, user
+#define OPTION_BIN_LOG          (1ULL << 18)    // THD, user
+#define OPTION_NOT_AUTOCOMMIT   (1ULL << 19)    // THD, user
+#define OPTION_BEGIN            (1ULL << 20)    // THD, intern
+#define OPTION_TABLE_LOCK       (1ULL << 21)    // THD, intern
+#define OPTION_QUICK            (1ULL << 22)    // SELECT (for DELETE)
+#define OPTION_KEEP_LOG         (1ULL << 23)    // THD, user
+
+/* The following is used to detect a conflict with DISTINCT */
+#define SELECT_ALL              (1ULL << 24)    // SELECT, user, parser
+/** The following can be set when importing tables in a 'wrong order'
+   to suppress foreign key checks */
+#define OPTION_NO_FOREIGN_KEY_CHECKS    (1ULL << 26) // THD, user, binlog
+/** The following speeds up inserts to InnoDB tables by suppressing unique
+   key checks in some cases */
+#define OPTION_RELAXED_UNIQUE_CHECKS    (1ULL << 27) // THD, user, binlog
+#define SELECT_NO_UNLOCK                (1ULL << 28) // SELECT, intern
+#define OPTION_SCHEMA_TABLE             (1ULL << 29) // SELECT, intern
+/** Flag set if setup_tables already done */
+#define OPTION_SETUP_TABLES_DONE        (1ULL << 30) // intern
+/** If not set then the thread will ignore all warnings with level notes. */
+#define OPTION_SQL_NOTES                (1ULL << 31) // THD, user
+/**
+  Force the used temporary table to be a MyISAM table (because we will use
+  fulltext functions when reading from it.
+*/
+#define TMP_TABLE_FORCE_MYISAM          (1ULL << 32)
+#define OPTION_PROFILING                (1ULL << 33)
+
+
+/* The rest of the file is included in the server only */
+#ifndef MYSQL_CLIENT
+
+/* @@optimizer_switch flags. These must be in sync with optimizer_switch_typelib */
+#define OPTIMIZER_SWITCH_INDEX_MERGE               (1ULL << 0)
+#define OPTIMIZER_SWITCH_INDEX_MERGE_UNION         (1ULL << 1)
+#define OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION    (1ULL << 2)
+#define OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT     (1ULL << 3)
+#define OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN (1ULL << 4)
+#define OPTIMIZER_SWITCH_LAST                      (1ULL << 5)
+
+/* The following must be kept in sync with optimizer_switch_str in mysqld.cc */
+#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
+                                  OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
+                                  OPTIMIZER_SWITCH_INDEX_MERGE_SORT_UNION | \
+                                  OPTIMIZER_SWITCH_INDEX_MERGE_INTERSECT | \
+                                  OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN)
+
+
+/*
+  Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
+  use strictly more than 64 bits by adding one more define above, you should
+  contact the replication team because the replication code should then be
+  updated (to store more bytes on disk).
+
+  NOTE: When adding new SQL_MODE types, make sure to also add them to
+  the scripts used for creating the MySQL system tables
+  in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
+
+*/
+
+// uncachable cause
+#define UNCACHEABLE_DEPENDENT   1
+#define UNCACHEABLE_RAND        2
+#define UNCACHEABLE_SIDEEFFECT	4
+/// forcing to save JOIN for explain
+#define UNCACHEABLE_EXPLAIN     8
+/** Don't evaluate subqueries in prepare even if they're not correlated */
+#define UNCACHEABLE_PREPARE    16
+/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
+#define UNCACHEABLE_UNITED     32
+#define UNCACHEABLE_CHECKOPTION   64
+
+/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
+#define UNDEF_POS (-1)
+
+/* BINLOG_DUMP options */
+
+#define BINLOG_DUMP_NON_BLOCK   1
+
+/* sql_show.cc:show_log_files() */
+#define SHOW_LOG_STATUS_FREE "FREE"
+#define SHOW_LOG_STATUS_INUSE "IN USE"
+
+/*
+  Some defines for exit codes for ::is_equal class functions.
+*/
+#define IS_EQUAL_NO 0
+#define IS_EQUAL_YES 1
+#define IS_EQUAL_PACK_LENGTH 2
+
+enum enum_parsing_place
+{
+  NO_MATTER,
+  IN_HAVING,
+  SELECT_LIST,
+  IN_WHERE,
+  IN_ON
+};
+
+
+enum enum_var_type
+{
+  OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
+};
+
+class sys_var;
+
+#ifdef MYSQL_SERVER
+
+#endif /* MYSQL_SERVER */
+
+#ifdef MYSQL_SERVER
+/*
+  A set of constants used for checking non aggregated fields and sum
+  functions mixture in the ONLY_FULL_GROUP_BY_MODE.
+*/
+#define NON_AGG_FIELD_USED  1
+#define SUM_FUNC_USED       2
+
+/*
+  External variables
+*/
+
+/* sql_yacc.cc */
+#ifndef DBUG_OFF
+extern void turn_parser_debug_on();
+
+#endif
+
+/**
+  convert a hex digit into number.
+*/
+
+inline int hexchar_to_int(char c)
+{
+  if (c <= '9' && c >= '0')
+    return c-'0';
+  c|=32;
+  if (c <= 'f' && c >= 'a')
+    return c-'a'+10;
+  return -1;
+}
+
+/* This must match the path length limit in the ER_NOT_RW_DIR error msg. */
+#define ER_NOT_RW_DIR_PATHSIZE 200
+
+#define IS_TABLESPACES_TABLESPACE_NAME    0
+#define IS_TABLESPACES_ENGINE             1
+#define IS_TABLESPACES_TABLESPACE_TYPE    2
+#define IS_TABLESPACES_LOGFILE_GROUP_NAME 3
+#define IS_TABLESPACES_EXTENT_SIZE        4
+#define IS_TABLESPACES_AUTOEXTEND_SIZE    5
+#define IS_TABLESPACES_MAXIMUM_SIZE       6
+#define IS_TABLESPACES_NODEGROUP_ID       7
+#define IS_TABLESPACES_TABLESPACE_COMMENT 8
+
+#endif /* MYSQL_SERVER */
+
+#endif /* MYSQL_CLIENT */
+
+#endif /* MYSQL_PRIV_H */
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 20c1b336f5c..4a0d3d944ad 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -29,8 +29,12 @@
 */
 
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_profile.h"
 #include "my_sys.h"
+#include "sql_show.h"                     // schema_table_store_record
+#include "sql_class.h"                    // THD
 
 #define TIME_FLOAT_DIGITS 9
 /** two vals encoded: (dec*100)+len */
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index 33597ca337e..151dd43c58a 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -16,6 +16,12 @@
 #ifndef _SQL_PROFILE_H
 #define _SQL_PROFILE_H
 
+class Item;
+class TABLE_LIST;
+class THD;
+typedef struct st_field_info ST_FIELD_INFO;
+typedef struct st_schema_table ST_SCHEMA_TABLE;
+
 extern ST_FIELD_INFO query_profile_statistics_info[];
 int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
 int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
@@ -34,7 +40,8 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
 
 
 #if defined(ENABLED_PROFILING)
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include 
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 009563319cd..d387010141c 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -17,9 +17,18 @@
   Atomic rename of table;  RENAME TABLE t1 to t2, tmp to t1 [,...]
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_rename.h"
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_table.h"                         // build_table_filename
+#include "sql_view.h"             // mysql_frm_type, mysql_rename_view
 #include "sql_trigger.h"
-
+#include "lock.h"       // wait_if_global_read_lock, lock_table_names,
+                        // unlock_table_names,
+                        // start_waiting_global_read_lock
+#include "sql_base.h"   // tdc_remove_table
+#include "sql_handler.h"                        // mysql_ha_rm_tables
 
 static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
 				 bool skip_error);
diff --git a/sql/sql_rename.h b/sql/sql_rename.h
new file mode 100644
index 00000000000..7fbf9f1e5cd
--- /dev/null
+++ b/sql/sql_rename.h
@@ -0,0 +1,27 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_RENAME_INCLUDED
+#define SQL_RENAME_INCLUDED
+
+class THD;
+struct TABLE_LIST;
+
+bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
+bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
+               char *new_table_name, char *new_table_alias,
+               bool skip_error);
+
+#endif /* SQL_RENAME_INCLUDED */
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 207f5994d5d..1ee770f70ef 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -13,11 +13,14 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_parse.h"                          // check_access
 #ifdef HAVE_REPLICATION
 
 #include "rpl_mi.h"
 #include "sql_repl.h"
+#include "sql_acl.h"                            // SUPER_ACL
 #include "log_event.h"
 #include "rpl_filter.h"
 #include 
diff --git a/sql/sql_repl.h b/sql/sql_repl.h
index aa71ac96ff8..4d3b0b8d62c 100644
--- a/sql/sql_repl.h
+++ b/sql/sql_repl.h
@@ -65,6 +65,7 @@ typedef struct st_load_file_info
 
 int log_loaded_block(IO_CACHE* file);
 int init_replication_sys_vars();
+void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
 
 #endif /* HAVE_REPLICATION */
 
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 3a62396b880..7d379ab34de 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -28,16 +28,33 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sql_select.h"
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_table.h"                          // primary_key_name
 #include "sql_cursor.h"
 #include "probes_mysql.h"
-
+#include "key.h"                 // key_copy, key_cmp, key_cmp_if_same
+#include "lock.h"                // mysql_unlock_some_tables,
+                                 // mysql_unlock_read_tables
+#include "sql_show.h"            // append_identifier
+#include "sql_base.h"            // setup_wild, setup_fields, fill_record
+#include "sql_parse.h"                          // check_stack_overrun
+#include "sql_partition.h"       // make_used_partitions_str
+#include "sql_acl.h"             // *_ACL
+#include "sql_test.h"            // print_where, print_keyuse_array,
+                                 // print_sjm, print_plan
+#include "records.h"             // init_read_record, end_read_record
+#include "filesort.h"            // filesort_free_buffers
+#include "sql_union.h"           // mysql_union
 #include 
 #include 
 #include 
 #include 
 
+#define PREV_BITS(type,A)	((type) (((type) 1 << (A)) -1))
+
 const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
 			      "MAYBE_REF","ALL","range","index","fulltext",
 			      "ref_or_null","unique_subquery","index_subquery",
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 3cec00a84c8..ccf88c2cc5c 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -30,6 +30,10 @@
 
 #include "procedure.h"
 #include 
+#include "sql_array.h"                        /* Array */
+#include "records.h"                          /* READ_RECORD */
+#include "opt_range.h"                /* SQL_SELECT, QUICK_SELECT_I */
+
 
 typedef struct keyuse_t {
   TABLE *table;
@@ -798,6 +802,46 @@ bool error_if_full_join(JOIN *join);
 int report_error(TABLE *table, int error);
 int safe_index_read(JOIN_TAB *tab);
 COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
+int get_quick_record(SQL_SELECT *select);
+SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length,
+                                  SORT_FIELD *sortorder);
+int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
+		List &fields, List  &all_fields, ORDER *order);
+int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
+		List &fields, List &all_fields, ORDER *order,
+		bool *hidden_group_fields);
+bool fix_inner_refs(THD *thd, List &all_fields, SELECT_LEX *select,
+                   Item **ref_pointer_array, ORDER *group_list= NULL);
+
+bool handle_select(THD *thd, LEX *lex, select_result *result,
+                   ulong setup_tables_done_option);
+bool mysql_select(THD *thd, Item ***rref_pointer_array,
+                  TABLE_LIST *tables, uint wild_num,  List &list,
+                  COND *conds, uint og_num, ORDER *order, ORDER *group,
+                  Item *having, ORDER *proc_param, ulonglong select_type, 
+                  select_result *result, SELECT_LEX_UNIT *unit, 
+                  SELECT_LEX *select_lex);
+void free_underlaid_joins(THD *thd, SELECT_LEX *select);
+bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
+                         select_result *result);
+Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
+			Item ***copy_func, Field **from_field,
+                        Field **def_field,
+			bool group, bool modify_item,
+			bool table_cant_handle_bit_fields,
+                        bool make_copy_field,
+                        uint convert_blob_length);
+
+/*
+  General routine to change field->ptr of a NULL-terminated array of Field
+  objects. Useful when needed to call val_int, val_str or similar and the
+  field data is not in table->record[0] but in some other structure.
+  set_key_field_ptr changes all fields of an index using a key_info object.
+  All methods presume that there is at least one field to change.
+*/
+
+TABLE *create_virtual_tmp_table(THD *thd, List &field_list);
+
 
 inline bool optimizer_flag(THD *thd, uint flag)
 { 
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc
index 0bf38639ff7..c7f9cf0b132 100644
--- a/sql/sql_servers.cc
+++ b/sql/sql_servers.cc
@@ -33,13 +33,18 @@
   currently running transactions etc will not be disrupted.
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_servers.h"
+#include "unireg.h"
+#include "sql_base.h"                           // close_thread_tables
+#include "records.h"          // init_read_record, end_read_record
 #include "hash_filo.h"
 #include 
 #include 
 #include "sp_head.h"
 #include "sp.h"
 #include "transaction.h"
+#include "lock.h"                               // MYSQL_LOCK_IGNORE_TIMEOUT
 
 /*
   We only use 1 mutex to guard the data structures - THR_LOCK_servers.
diff --git a/sql/sql_servers.h b/sql/sql_servers.h
index 12855f8473c..3c338bbe3f9 100644
--- a/sql/sql_servers.h
+++ b/sql/sql_servers.h
@@ -16,8 +16,13 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
+#include "my_global.h"                  /* uint */
 #include "slave.h" // for tables_ok(), rpl_filter
 
+class THD;
+typedef struct st_lex_server_options LEX_SERVER_OPTIONS;
+typedef struct st_mem_root MEM_ROOT;
+
 /* structs */
 typedef struct st_federated_server
 {
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 542a0378bf4..06c6f4d6b59 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -16,10 +16,25 @@
 
 /* Function with list databases, tables or fields */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_acl.h"                        // fill_schema_*_privileges
 #include "sql_select.h"                         // For select_describe
+#include "sql_base.h"                       // close_tables_for_reopen
 #include "sql_show.h"
+#include "sql_table.h"                        // filename_to_tablename,
+                                              // primary_key_name,
+                                              // build_table_filename
 #include "repl_failsafe.h"
+#include "sql_view.h"                           // mysql_frm_type
+#include "sql_parse.h"             // check_access, check_table_access
+#include "sql_partition.h"         // partition_element
+#include "sql_db.h"     // check_db_dir_existence, load_db_opt_by_name
+#include "sql_time.h"   // interval_type_to_name
+#include "tztime.h"                             // struct Time_zone
+#include "sql_acl.h"     // TABLE_ACLS, check_grant, DB_ACLS, acl_get,
+                         // check_grant_db
+#include "filesort.h"    // filesort_free_buffers
 #include "sp.h"
 #include "sp_head.h"
 #include "sp_pcontext.h"
@@ -33,6 +48,7 @@
 #include "event_data_objects.h"
 #endif
 #include 
+#include "lock.h"                           // MYSQL_LOCK_IGNORE_FLUSH
 
 #define STR_OR_NIL(S) ((S) ? (S) : "")
 
diff --git a/sql/sql_show.h b/sql/sql_show.h
index fa067a46033..d1323ede8c1 100644
--- a/sql/sql_show.h
+++ b/sql/sql_show.h
@@ -16,12 +16,24 @@
 #ifndef SQL_SHOW_H
 #define SQL_SHOW_H
 
+#include "sql_list.h"                           /* List */
+#include "handler.h"                            /* enum_schema_tables */
+#include "table.h"                              /* enum_schema_table_state */
+
 /* Forward declarations */
+class JOIN;
 class String;
 class THD;
-struct st_ha_create_information;
-typedef st_ha_create_information HA_CREATE_INFO;
+class sp_name;
 struct TABLE_LIST;
+struct st_ha_create_information;
+typedef class st_select_lex SELECT_LEX;
+typedef st_ha_create_information HA_CREATE_INFO;
+struct LEX;
+typedef struct st_mysql_show_var SHOW_VAR;
+typedef struct st_schema_table ST_SCHEMA_TABLE;
+struct TABLE;
+typedef struct system_status_var STATUS_VAR;
 
 enum find_files_result {
   FIND_FILES_OK,
@@ -29,6 +41,46 @@ enum find_files_result {
   FIND_FILES_DIR
 };
 
+/* Used by handlers to store things in schema tables */
+#define IS_FILES_FILE_ID              0
+#define IS_FILES_FILE_NAME            1
+#define IS_FILES_FILE_TYPE            2
+#define IS_FILES_TABLESPACE_NAME      3
+#define IS_FILES_TABLE_CATALOG        4
+#define IS_FILES_TABLE_SCHEMA         5
+#define IS_FILES_TABLE_NAME           6
+#define IS_FILES_LOGFILE_GROUP_NAME   7
+#define IS_FILES_LOGFILE_GROUP_NUMBER 8
+#define IS_FILES_ENGINE               9
+#define IS_FILES_FULLTEXT_KEYS       10
+#define IS_FILES_DELETED_ROWS        11
+#define IS_FILES_UPDATE_COUNT        12
+#define IS_FILES_FREE_EXTENTS        13
+#define IS_FILES_TOTAL_EXTENTS       14
+#define IS_FILES_EXTENT_SIZE         15
+#define IS_FILES_INITIAL_SIZE        16
+#define IS_FILES_MAXIMUM_SIZE        17
+#define IS_FILES_AUTOEXTEND_SIZE     18
+#define IS_FILES_CREATION_TIME       19
+#define IS_FILES_LAST_UPDATE_TIME    20
+#define IS_FILES_LAST_ACCESS_TIME    21
+#define IS_FILES_RECOVER_TIME        22
+#define IS_FILES_TRANSACTION_COUNTER 23
+#define IS_FILES_VERSION             24
+#define IS_FILES_ROW_FORMAT          25
+#define IS_FILES_TABLE_ROWS          26
+#define IS_FILES_AVG_ROW_LENGTH      27
+#define IS_FILES_DATA_LENGTH         28
+#define IS_FILES_MAX_DATA_LENGTH     29
+#define IS_FILES_INDEX_LENGTH        30
+#define IS_FILES_DATA_FREE           31
+#define IS_FILES_CREATE_TIME         32
+#define IS_FILES_UPDATE_TIME         33
+#define IS_FILES_CHECK_TIME          34
+#define IS_FILES_CHECKSUM            35
+#define IS_FILES_STATUS              36
+#define IS_FILES_EXTRA               37
+
 find_files_result find_files(THD *thd, List *files, const char *db,
                              const char *path, const char *wild, bool dir);
 
@@ -38,4 +90,47 @@ int view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
 
 int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table);
 
+void append_identifier(THD *thd, String *packet, const char *name,
+		       uint length);
+void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
+int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd);
+bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
+bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
+
+void mysqld_list_processes(THD *thd,const char *user,bool verbose);
+int mysqld_show_status(THD *thd);
+int mysqld_show_variables(THD *thd,const char *wild);
+bool mysqld_show_storage_engines(THD *thd);
+bool mysqld_show_authors(THD *thd);
+bool mysqld_show_contributors(THD *thd);
+bool mysqld_show_privileges(THD *thd);
+bool mysqld_show_column_types(THD *thd);
+char *make_backup_log_name(char *buff, const char *name, const char* log_ext);
+void calc_sum_of_all_status(STATUS_VAR *to);
+void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
+                    const LEX_STRING *definer_host);
+int add_status_vars(SHOW_VAR *list);
+void remove_status_vars(SHOW_VAR *list);
+void init_status_vars();
+void free_status_vars();
+void reset_status_vars();
+bool show_create_trigger(THD *thd, const sp_name *trg_name);
+void view_store_options(THD *thd, TABLE_LIST *table, String *buff);
+
+void init_fill_schema_files_row(TABLE* table);
+bool schema_table_store_record(THD *thd, TABLE *table);
+void initialize_information_schema_acl();
+
+ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
+ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
+int make_schema_select(THD *thd,  SELECT_LEX *sel,
+                       enum enum_schema_tables schema_table_idx);
+int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list);
+bool get_schema_tables_result(JOIN *join,
+                              enum enum_schema_table_state executed_place);
+enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
+
+/* These functions were under INNODB_COMPATIBILITY_HOOKS */
+int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
+
 #endif /* SQL_SHOW_H */
diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc
index c9ab37272b8..8ae77f3645b 100644
--- a/sql/sql_signal.cc
+++ b/sql/sql_signal.cc
@@ -13,7 +13,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "sp_head.h"
 #include "sp_pcontext.h"
 #include "sp_rcontext.h"
diff --git a/sql/sql_sort.h b/sql/sql_sort.h
index 102b3ef0a11..45ef14c1319 100644
--- a/sql/sql_sort.h
+++ b/sql/sql_sort.h
@@ -16,6 +16,18 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
+#include "my_global.h"                          /* uchar */
+#include "my_base.h"                            /* ha_rows */
+#include "my_sys.h"                             /* qsort2_cmp */
+
+typedef struct st_buffpek BUFFPEK;
+typedef struct st_queue QUEUE;
+typedef struct st_sort_field SORT_FIELD;
+
+class Field;
+struct TABLE;
+
+
 /* Defines used by filesort and uniques */
 
 #define MERGEBUFF		7
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 38f843e7e8f..f67d6de9a0f 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -22,7 +22,15 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "m_ctype.h"                            /* my_charset_bin */
+#include "my_sys.h"              /* alloc_root, my_free, my_realloc */
+#include "m_string.h"                           /* TRASH */
+
 class String;
+typedef struct charset_info_st CHARSET_INFO;
+typedef struct st_io_cache IO_CACHE;
+typedef struct st_mem_root MEM_ROOT;
+
 int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
 String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
 uint32 copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 393200a81db..c3a39354ff1 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -15,14 +15,40 @@
 
 /* drop and alter of tables */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "debug_sync.h"
+#include "sql_table.h"
+#include "sql_rename.h" // do_rename
+#include "sql_parse.h"                        // test_if_data_home_dir
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_base.h"                          // open_temporary_table
+#include "lock.h"       // wait_if_global_read_lock, lock_table_names,
+                        // start_waiting_global_read_lock,
+                        // unlock_table_names, mysql_unlock_tables
+#include "strfunc.h"    // find_type2, find_set
+#include "sql_view.h" // mysql_frm_type, view_checksum, mysql_frm_type
+#include "sql_delete.h"                         // mysql_truncate
+#include "sql_partition.h"                      // mem_alloc_error,
+                                                // generate_partition_syntax,
+                                                // partition_info
+#include "sql_db.h" // load_db_opt_by_name, lock_db_cache, creating_database
+#include "sql_time.h"                  // make_truncated_value_warning
+#include "records.h"             // init_read_record, end_read_record
+#include "filesort.h"            // filesort_free_buffers
+#include "sql_select.h"                // setup_order,
+                                       // make_unireg_sortorder
+#include "sql_handler.h"               // mysql_ha_rm_tables
+#include "discover.h"                  // readfrm
+#include "my_pthread.h"                // pthread_mutex_t
+#include "log_event.h"                 // Query_log_event
 #include 
 #include 
 #include 
 #include "sp_head.h"
 #include "sp.h"
 #include "sql_trigger.h"
+#include "sql_parse.h"
 #include "sql_show.h"
 #include "transaction.h"
 #include "keycaches.h"
diff --git a/sql/sql_table.h b/sql/sql_table.h
new file mode 100644
index 00000000000..6dbfbe3c9b0
--- /dev/null
+++ b/sql/sql_table.h
@@ -0,0 +1,215 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_TABLE_INCLUDED
+#define SQL_TABLE_INCLUDED
+
+#include "my_global.h"                          /* my_bool */
+#include "my_sys.h"                             // pthread_mutex_t
+
+class Alter_info;
+class Alter_info;
+class Create_field;
+class TABLE_LIST;
+class THD;
+struct TABLE;
+struct handlerton;
+typedef struct st_ha_check_opt HA_CHECK_OPT;
+typedef struct st_ha_create_information HA_CREATE_INFO;
+typedef struct st_key_cache KEY_CACHE;
+typedef struct st_lock_param_type ALTER_PARTITION_PARAM_TYPE;
+typedef struct st_lock_param_type ALTER_PARTITION_PARAM_TYPE;
+typedef struct st_mysql_lex_string LEX_STRING;
+typedef struct st_order ORDER;
+
+enum ddl_log_entry_code
+{
+  /*
+    DDL_LOG_EXECUTE_CODE:
+      This is a code that indicates that this is a log entry to
+      be executed, from this entry a linked list of log entries
+      can be found and executed.
+    DDL_LOG_ENTRY_CODE:
+      An entry to be executed in a linked list from an execute log
+      entry.
+    DDL_IGNORE_LOG_ENTRY_CODE:
+      An entry that is to be ignored
+  */
+  DDL_LOG_EXECUTE_CODE = 'e',
+  DDL_LOG_ENTRY_CODE = 'l',
+  DDL_IGNORE_LOG_ENTRY_CODE = 'i'
+};
+
+enum ddl_log_action_code
+{
+  /*
+    The type of action that a DDL_LOG_ENTRY_CODE entry is to
+    perform.
+    DDL_LOG_DELETE_ACTION:
+      Delete an entity
+    DDL_LOG_RENAME_ACTION:
+      Rename an entity
+    DDL_LOG_REPLACE_ACTION:
+      Rename an entity after removing the previous entry with the
+      new name, that is replace this entry.
+  */
+  DDL_LOG_DELETE_ACTION = 'd',
+  DDL_LOG_RENAME_ACTION = 'r',
+  DDL_LOG_REPLACE_ACTION = 's'
+};
+
+
+typedef struct st_ddl_log_entry
+{
+  const char *name;
+  const char *from_name;
+  const char *handler_name;
+  uint next_entry;
+  uint entry_pos;
+  enum ddl_log_entry_code entry_type;
+  enum ddl_log_action_code action_type;
+  /*
+    Most actions have only one phase. REPLACE does however have two
+    phases. The first phase removes the file with the new name if
+    there was one there before and the second phase renames the
+    old name to the new name.
+  */
+  char phase;
+} DDL_LOG_ENTRY;
+
+typedef struct st_ddl_log_memory_entry
+{
+  uint entry_pos;
+  struct st_ddl_log_memory_entry *next_log_entry;
+  struct st_ddl_log_memory_entry *prev_log_entry;
+  struct st_ddl_log_memory_entry *next_active_log_entry;
+} DDL_LOG_MEMORY_ENTRY;
+
+
+enum enum_explain_filename_mode
+{
+  EXPLAIN_ALL_VERBOSE= 0,
+  EXPLAIN_PARTITIONS_VERBOSE,
+  EXPLAIN_PARTITIONS_AS_COMMENT
+};
+
+/* depends on errmsg.txt Database `db`, Table `t` ... */
+#define EXPLAIN_FILENAME_MAX_EXTRA_LENGTH 63
+
+#define MYSQL50_TABLE_NAME_PREFIX         "#mysql50#"
+#define MYSQL50_TABLE_NAME_PREFIX_LENGTH  9
+
+#define WFRM_WRITE_SHADOW 1
+#define WFRM_INSTALL_SHADOW 2
+#define WFRM_PACK_FRM 4
+#define WFRM_KEEP_SHARE 8
+
+/* Flags for conversion functions. */
+#define FN_FROM_IS_TMP  (1 << 0)
+#define FN_TO_IS_TMP    (1 << 1)
+#define FN_IS_TMP       (FN_FROM_IS_TMP | FN_TO_IS_TMP)
+#define NO_FRM_RENAME   (1 << 2)
+#define FRM_ONLY        (1 << 3)
+
+uint filename_to_tablename(const char *from, char *to, uint to_length);
+uint tablename_to_filename(const char *from, char *to, uint to_length);
+uint check_n_cut_mysql50_prefix(const char *from, char *to, uint to_length);
+uint build_table_filename(char *buff, size_t bufflen, const char *db,
+                          const char *table, const char *ext, uint flags);
+uint build_table_shadow_filename(char *buff, size_t bufflen,
+                                 ALTER_PARTITION_PARAM_TYPE *lpt);
+bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
+                        HA_CREATE_INFO *create_info,
+                        Alter_info *alter_info);
+bool mysql_create_table_no_lock(THD *thd, const char *db,
+                                const char *table_name,
+                                HA_CREATE_INFO *create_info,
+                                Alter_info *alter_info,
+                                bool tmp_table, uint select_field_count);
+
+bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
+                       HA_CREATE_INFO *create_info,
+                       TABLE_LIST *table_list,
+                       Alter_info *alter_info,
+                       uint order_num, ORDER *order, bool ignore);
+bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
+bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
+                             TABLE_LIST *src_table,
+                             HA_CREATE_INFO *create_info);
+bool mysql_rename_table(handlerton *base, const char *old_db,
+                        const char * old_name, const char *new_db,
+                        const char * new_name, uint flags);
+
+bool mysql_backup_table(THD* thd, TABLE_LIST* table_list);
+bool mysql_restore_table(THD* thd, TABLE_LIST* table_list);
+
+bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list,
+                          HA_CHECK_OPT* check_opt);
+bool mysql_check_table(THD* thd, TABLE_LIST* table_list,
+                       HA_CHECK_OPT* check_opt);
+bool mysql_repair_table(THD* thd, TABLE_LIST* table_list,
+                        HA_CHECK_OPT* check_opt);
+bool mysql_analyze_table(THD* thd, TABLE_LIST* table_list,
+                         HA_CHECK_OPT* check_opt);
+bool mysql_optimize_table(THD* thd, TABLE_LIST* table_list,
+                          HA_CHECK_OPT* check_opt);
+bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
+                              LEX_STRING *key_cache_name);
+bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
+int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
+                             KEY_CACHE *dst_cache);
+bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
+                    my_bool drop_temporary);
+int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
+                         bool drop_temporary, bool drop_view, bool log_query);
+bool quick_rm_table(handlerton *base,const char *db,
+                    const char *table_name, uint flags);
+void close_cached_table(THD *thd, TABLE *table);
+void sp_prepare_create_field(THD *thd, Create_field *sql_field);
+int prepare_create_field(Create_field *sql_field,
+			 uint *blob_columns,
+			 int *timestamps, int *timestamps_with_niladic,
+			 longlong table_flags);
+CHARSET_INFO* get_sql_field_charset(Create_field *sql_field,
+                                    HA_CREATE_INFO *create_info);
+bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags);
+int write_bin_log(THD *thd, bool clear_error,
+                  char const *query, ulong query_length,
+                  bool is_trans= FALSE);
+bool write_ddl_log_entry(DDL_LOG_ENTRY *ddl_log_entry,
+                           DDL_LOG_MEMORY_ENTRY **active_entry);
+bool write_execute_ddl_log_entry(uint first_entry,
+                                   bool complete,
+                                   DDL_LOG_MEMORY_ENTRY **active_entry);
+bool deactivate_ddl_log_entry(uint entry_no);
+void release_ddl_log_memory_entry(DDL_LOG_MEMORY_ENTRY *log_entry);
+bool sync_ddl_log();
+void release_ddl_log();
+void execute_ddl_log_recovery();
+bool execute_ddl_log_entry(THD *thd, uint first_entry);
+bool check_duplicate_warning(THD *thd, char *msg, ulong length);
+
+/*
+  These prototypes where under INNODB_COMPATIBILITY_HOOKS.
+*/
+uint explain_filename(THD* thd, const char *from, char *to, uint to_length,
+                      enum_explain_filename_mode explain_mode);
+
+
+extern MYSQL_PLUGIN_IMPORT const char *primary_key_name;
+extern int creating_table;    // How many mysql_create_table() are running
+extern mysql_mutex_t LOCK_gdl;
+
+#endif /* SQL_TABLE_INCLUDED */
diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc
index 4db3083eb04..18650c11c09 100644
--- a/sql/sql_tablespace.cc
+++ b/sql/sql_tablespace.cc
@@ -15,7 +15,11 @@
 
 /* drop and alter of tablespaces */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_tablespace.h"
+#include "sql_table.h"                          // write_bin_log
+#include "sql_class.h"                          // THD
 
 int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
 {
diff --git a/sql/sql_tablespace.h b/sql/sql_tablespace.h
new file mode 100644
index 00000000000..93544dea4af
--- /dev/null
+++ b/sql/sql_tablespace.h
@@ -0,0 +1,24 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_TABLESPACE_INCLUDED
+#define SQL_TABLESPACE_INCLUDED
+
+class THD;
+class st_alter_tablespace;
+
+int mysql_alter_tablespace(THD* thd, st_alter_tablespace *ts_info);
+
+#endif /* SQL_TABLESPACE_INCLUDED */
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index bfd053d3333..d34aee854d0 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -17,7 +17,11 @@
 /* Write some debug info */
 
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_test.h"
+#include "sql_base.h" // table_def_cache, table_cache_count, unused_tables
+#include "sql_show.h" // calc_sum_of_all_status
 #include "sql_select.h"
 #include "keycaches.h"
 #include 
diff --git a/sql/sql_test.h b/sql/sql_test.h
new file mode 100644
index 00000000000..539e89ec949
--- /dev/null
+++ b/sql/sql_test.h
@@ -0,0 +1,37 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_TEST_INCLUDED
+#define SQL_TEST_INCLUDED
+
+#include "mysqld.h"
+
+class JOIN;
+struct TABLE_LIST;
+typedef class Item COND;
+typedef class st_select_lex SELECT_LEX;
+typedef struct st_sort_field SORT_FIELD;
+
+#ifndef DBUG_OFF
+void print_where(COND *cond,const char *info, enum_query_type query_type);
+void print_cached_tables(void);
+void TEST_filesort(SORT_FIELD *sortorder,uint s_length);
+void print_plan(JOIN* join,uint idx, double record_count, double read_time,
+                double current_read_time, const char *info);
+void dump_TABLE_LIST_graph(SELECT_LEX *select_lex, TABLE_LIST* tl);
+#endif
+void mysql_print_status();
+
+#endif /* SQL_TEST_INCLUDED */
diff --git a/sql/time.cc b/sql/sql_time.cc
similarity index 99%
rename from sql/time.cc
rename to sql/sql_time.cc
index 2db7812b9ef..9606304ea16 100644
--- a/sql/time.cc
+++ b/sql/sql_time.cc
@@ -16,7 +16,11 @@
 
 /* Functions to handle date and time */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                      // REQUIRED by other includes
+#include "sql_time.h"
+#include "tztime.h"                             // struct Time_zone
+#include "sql_class.h"   // THD, MODE_INVALID_DATES, MODE_NO_ZERO_DATE
 #include 
 
 
diff --git a/sql/sql_time.h b/sql/sql_time.h
new file mode 100644
index 00000000000..47e1a2b4843
--- /dev/null
+++ b/sql/sql_time.h
@@ -0,0 +1,101 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_TIME_INCLUDED
+#define SQL_TIME_INCLUDED
+
+#include "my_global.h"                          /* ulong */
+#include "my_time.h"
+#include "mysql_time.h"                         /* timestamp_type */
+#include "sql_error.h"                          /* MYSQL_ERROR */
+#include "structs.h"                            /* INTERVAL */
+
+typedef enum enum_mysql_timestamp_type timestamp_type;
+typedef struct st_date_time_format DATE_TIME_FORMAT;
+typedef struct st_known_date_time_format KNOWN_DATE_TIME_FORMAT;
+
+/* Flags for calc_week() function.  */
+#define WEEK_MONDAY_FIRST    1
+#define WEEK_YEAR            2
+#define WEEK_FIRST_WEEKDAY   4
+
+ulong convert_period_to_month(ulong period);
+ulong convert_month_to_period(ulong month);
+void get_date_from_daynr(long daynr,uint *year, uint *month, uint *day);
+my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *not_exist);
+bool str_to_time_with_warn(CHARSET_INFO *cs, const char *str, uint length,
+                           MYSQL_TIME *l_time);
+timestamp_type str_to_datetime_with_warn(CHARSET_INFO *cs, const char *str,
+                                         uint length, MYSQL_TIME *l_time,
+                                         uint flags);
+void make_truncated_value_warning(THD *thd,
+                                  MYSQL_ERROR::enum_warning_level level,
+                                  const char *str_val, uint str_length,
+                                  timestamp_type time_type,
+                                  const char *field_name);
+extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
+					       const char *format_str,
+					       uint format_length);
+extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
+					       DATE_TIME_FORMAT *format);
+const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
+				     timestamp_type type);
+void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
+               String *str);
+void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
+               String *str);
+void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
+                   String *str);
+
+/* MYSQL_TIME operations */
+bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type,
+                       INTERVAL interval);
+bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
+                    longlong *seconds_out, long *microseconds_out);
+int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
+void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
+void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
+uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
+
+int calc_weekday(long daynr,bool sunday_first_day_of_week);
+bool parse_date_time_format(timestamp_type format_type, 
+                            const char *format, uint format_length,
+                            DATE_TIME_FORMAT *date_time_format);
+/* Character set-aware version of str_to_time() */
+bool str_to_time(CHARSET_INFO *cs, const char *str,uint length,
+                 MYSQL_TIME *l_time, int *warning);
+/* Character set-aware version of str_to_datetime() */
+timestamp_type str_to_datetime(CHARSET_INFO *cs,
+                               const char *str, uint length,
+                               MYSQL_TIME *l_time, uint flags, int *was_cut);
+
+/* convenience wrapper */
+inline bool parse_date_time_format(timestamp_type format_type, 
+                                   DATE_TIME_FORMAT *date_time_format)
+{
+  return parse_date_time_format(format_type,
+                                date_time_format->format.str,
+                                date_time_format->format.length,
+                                date_time_format);
+}
+
+
+extern DATE_TIME_FORMAT global_date_format;
+extern DATE_TIME_FORMAT global_datetime_format;
+extern DATE_TIME_FORMAT global_time_format;
+extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
+extern LEX_STRING interval_type_to_name[];
+
+#endif /* SQL_TIME_INCLUDED */
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index b1367a61b37..9f45ce3919e 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -15,11 +15,22 @@
 
 
 #define MYSQL_LEX 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sp_head.h"
 #include "sql_trigger.h"
+#include "sql_parse.h"                          // parse_sql
 #include "parse_file.h"
 #include "sp.h"
+#include "sql_base.h"                          // find_temporary_table
+#include "lock.h"                    // wait_if_global_read_lock,
+                                     // start_waiting_global_read_lock
+#include "sql_show.h"                // append_definer, append_identifier
+#include "sql_table.h"                        // build_table_filename,
+                                              // check_n_cut_mysql50_prefix
+#include "sql_db.h"                        // get_default_db_collation
+#include "sql_acl.h"                       // *_ACL, is_acl_user
+#include "sql_handler.h"                        // mysql_ha_rm_tables
 
 /*************************************************************************/
 
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h
index 85b2dbe5f21..28bf0a60877 100644
--- a/sql/sql_trigger.h
+++ b/sql/sql_trigger.h
@@ -16,6 +16,38 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
 
+/* Forward declarations */
+
+class Item_trigger_field;
+class sp_head;
+class sp_name;
+class Query_tables_list;
+struct TABLE_LIST;
+class Query_tables_list;
+
+/** Event on which trigger is invoked. */
+enum trg_event_type
+{
+  TRG_EVENT_INSERT= 0,
+  TRG_EVENT_UPDATE= 1,
+  TRG_EVENT_DELETE= 2,
+  TRG_EVENT_MAX
+};
+
+#include "table.h"                              /* GRANT_INFO */
+
+/*
+  We need this two enums here instead of sql_lex.h because
+  at least one of them is used by Item_trigger_field interface.
+
+  Time when trigger is invoked (i.e. before or after row actually
+  inserted/updated/deleted).
+*/
+enum trg_action_time_type
+{
+  TRG_ACTION_BEFORE= 0, TRG_ACTION_AFTER= 1, TRG_ACTION_MAX
+};
+
 
 /**
   This class holds all information about triggers of table.
@@ -178,5 +210,9 @@ bool load_table_name_for_trigger(THD *thd,
                                  const sp_name *trg_name,
                                  const LEX_STRING *trn_path,
                                  LEX_STRING *tbl_name);
+bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
+
+extern const char * const TRG_EXT;
+extern const char * const TRN_EXT;
 
 #endif /* SQL_TRIGGER_INCLUDED */
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 7dfcf9f6b2e..9ec17a67533 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -31,8 +31,14 @@
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_base.h"                           // close_thread_tables
+#include "sql_parse.h"                        // check_identifier_name
+#include "sql_table.h"                        // write_bin_log
+#include "records.h"          // init_read_record, end_read_record
 #include 
+#include "lock.h"                               // MYSQL_LOCK_IGNORE_TIMEOUT
 
 #ifdef HAVE_DLOPEN
 extern "C"
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index ad14d2e4ecd..a4d3f61f0e3 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -20,9 +20,13 @@
 */
 
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_union.h"
 #include "sql_select.h"
 #include "sql_cursor.h"
+#include "sql_base.h"                           // fill_record
+#include "filesort.h"                           // filesort_free_buffers
 
 bool mysql_union(THD *thd, LEX *lex, select_result *result,
                  SELECT_LEX_UNIT *unit, ulong setup_tables_done_option)
diff --git a/sql/sql_union.h b/sql/sql_union.h
new file mode 100644
index 00000000000..43e1b7a6910
--- /dev/null
+++ b/sql/sql_union.h
@@ -0,0 +1,31 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_UNION_INCLUDED
+#define SQL_UNION_INCLUDED
+
+#include "my_global.h"                          /* ulong */
+
+class THD;
+class select_result;
+struct LEX;
+
+typedef class st_select_lex_unit SELECT_LEX_UNIT;
+
+bool mysql_union(THD *thd, LEX *lex, select_result *result,
+                 SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
+
+
+#endif /* SQL_UNION_INCLUDED */
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 62a35335374..3adee53f0be 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -19,12 +19,27 @@
   Multi-table updates were introduced by Sinisa & Monty
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_update.h"
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_base.h"                       // close_tables_for_reopen
+#include "sql_parse.h"                          // cleanup_items
+#include "sql_partition.h"                   // partition_key_modified
 #include "sql_select.h"
+#include "sql_view.h"                           // check_key_in_view
 #include "sp_head.h"
 #include "sql_trigger.h"
 #include "probes_mysql.h"
 #include "debug_sync.h"
+#include "key.h"                                // is_key_used
+#include "sql_acl.h"                            // *_ACL, check_grant
+#include "records.h"                            // init_read_record,
+                                                // end_read_record
+#include "filesort.h"                           // filesort
+#include "sql_derived.h" // mysql_derived_prepare,
+                         // mysql_handle_derived,
+                         // mysql_derived_filling
 
 /* Return 0 if row hasn't changed */
 
diff --git a/sql/sql_update.h b/sql/sql_update.h
new file mode 100644
index 00000000000..e5a0ca5c627
--- /dev/null
+++ b/sql/sql_update.h
@@ -0,0 +1,43 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef SQL_UPDATE_INCLUDED
+#define SQL_UPDATE_INCLUDED
+
+#include "sql_class.h"                          /* enum_duplicates */
+
+class Item;
+class TABLE_LIST;
+class THD;
+
+typedef class st_select_lex SELECT_LEX;
+typedef class st_select_lex_unit SELECT_LEX_UNIT;
+
+bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
+                          Item **conds, uint order_num, ORDER *order);
+int mysql_update(THD *thd,TABLE_LIST *tables,List &fields,
+		 List &values,COND *conds,
+		 uint order_num, ORDER *order, ha_rows limit,
+		 enum enum_duplicates handle_duplicates, bool ignore,
+                 ha_rows *found_return, ha_rows *updated_return);
+bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
+                        List *fields, List *values,
+                        COND *conds, ulonglong options,
+                        enum enum_duplicates handle_duplicates, bool ignore,
+                        SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex,
+                        multi_update **result);
+bool compare_record(TABLE *table);
+
+#endif /* SQL_UPDATE_INCLUDED */
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 2f40720c7ae..004b7d80124 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -15,7 +15,17 @@
 */
 
 #define MYSQL_LEX 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_view.h"
+#include "sql_base.h"                     // find_table_in_global_list
+#include "sql_parse.h"                          // sql_parse
+#include "sql_cache.h"                          // query_cache_*
+#include "lock.h"        // wait_if_global_read_lock, lock_table_names
+#include "sql_show.h"    // append_identifier
+#include "sql_table.h"                         // build_table_filename
+#include "sql_db.h"            // mysql_opt_change_db, mysql_change_db
+#include "sql_acl.h"           // *_ACL, check_grant
 #include "sql_select.h"
 #include "parse_file.h"
 #include "sp.h"
diff --git a/sql/sql_view.h b/sql/sql_view.h
index 3de51c3264e..7d06abb9068 100644
--- a/sql/sql_view.h
+++ b/sql/sql_view.h
@@ -18,6 +18,16 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#include "sql_class.h"     /* Required by sql_lex.h */
+#include "sql_lex.h"       /* enum_view_create_mode, enum_drop_mode */
+
+/* Forward declarations */
+
+class File_parser;
+
+
+/* Function declarations */
+
 bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view,
                           enum_view_create_mode mode);
 
@@ -45,4 +55,6 @@ bool mysql_rename_view(THD *thd, const char *new_db, const char *new_name,
 
 #define VIEW_ANY_ACL (SELECT_ACL | UPDATE_ACL | INSERT_ACL | DELETE_ACL)
 
+extern const LEX_STRING view_type;
+
 #endif /* SQL_VIEW_INCLUDED */
diff --git a/sql/sql_yacc.h b/sql/sql_yacc.h
new file mode 100644
index 00000000000..62575750bb2
--- /dev/null
+++ b/sql/sql_yacc.h
@@ -0,0 +1,1291 @@
+
+/* A Bison parser, made by GNU Bison 2.4.1.  */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+   
+      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+   
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see .  */
+
+/* As a special exception, you may create a larger work that contains
+   part or all of the Bison parser skeleton and distribute that work
+   under terms of your choice, so long as that work isn't itself a
+   parser generator using the skeleton or a modified version thereof
+   as a parser skeleton.  Alternatively, if you modify or redistribute
+   the parser skeleton itself, you may (at your option) remove this
+   special exception, which will cause the skeleton and the resulting
+   Bison output files to be licensed under the GNU General Public
+   License without this special exception.
+   
+   This special exception was added by the Free Software Foundation in
+   version 2.2 of Bison.  */
+
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     ABORT_SYM = 258,
+     ACCESSIBLE_SYM = 259,
+     ACTION = 260,
+     ADD = 261,
+     ADDDATE_SYM = 262,
+     AFTER_SYM = 263,
+     AGAINST = 264,
+     AGGREGATE_SYM = 265,
+     ALGORITHM_SYM = 266,
+     ALL = 267,
+     ALTER = 268,
+     ANALYZE_SYM = 269,
+     AND_AND_SYM = 270,
+     AND_SYM = 271,
+     ANY_SYM = 272,
+     AS = 273,
+     ASC = 274,
+     ASCII_SYM = 275,
+     ASENSITIVE_SYM = 276,
+     AT_SYM = 277,
+     AUTHORS_SYM = 278,
+     AUTOEXTEND_SIZE_SYM = 279,
+     AUTO_INC = 280,
+     AVG_ROW_LENGTH = 281,
+     AVG_SYM = 282,
+     BACKUP_SYM = 283,
+     BEFORE_SYM = 284,
+     BEGIN_SYM = 285,
+     BETWEEN_SYM = 286,
+     BIGINT = 287,
+     BINARY = 288,
+     BINLOG_SYM = 289,
+     BIN_NUM = 290,
+     BIT_AND = 291,
+     BIT_OR = 292,
+     BIT_SYM = 293,
+     BIT_XOR = 294,
+     BLOB_SYM = 295,
+     BLOCK_SYM = 296,
+     BOOLEAN_SYM = 297,
+     BOOL_SYM = 298,
+     BOTH = 299,
+     BTREE_SYM = 300,
+     BY = 301,
+     BYTE_SYM = 302,
+     CACHE_SYM = 303,
+     CALL_SYM = 304,
+     CASCADE = 305,
+     CASCADED = 306,
+     CASE_SYM = 307,
+     CAST_SYM = 308,
+     CATALOG_NAME_SYM = 309,
+     CHAIN_SYM = 310,
+     CHANGE = 311,
+     CHANGED = 312,
+     CHARSET = 313,
+     CHAR_SYM = 314,
+     CHECKSUM_SYM = 315,
+     CHECK_SYM = 316,
+     CIPHER_SYM = 317,
+     CLASS_ORIGIN_SYM = 318,
+     CLIENT_SYM = 319,
+     CLOSE_SYM = 320,
+     COALESCE = 321,
+     CODE_SYM = 322,
+     COLLATE_SYM = 323,
+     COLLATION_SYM = 324,
+     COLUMNS = 325,
+     COLUMN_SYM = 326,
+     COLUMN_NAME_SYM = 327,
+     COMMENT_SYM = 328,
+     COMMITTED_SYM = 329,
+     COMMIT_SYM = 330,
+     COMPACT_SYM = 331,
+     COMPLETION_SYM = 332,
+     COMPRESSED_SYM = 333,
+     CONCURRENT = 334,
+     CONDITION_SYM = 335,
+     CONNECTION_SYM = 336,
+     CONSISTENT_SYM = 337,
+     CONSTRAINT = 338,
+     CONSTRAINT_CATALOG_SYM = 339,
+     CONSTRAINT_NAME_SYM = 340,
+     CONSTRAINT_SCHEMA_SYM = 341,
+     CONTAINS_SYM = 342,
+     CONTEXT_SYM = 343,
+     CONTINUE_SYM = 344,
+     CONTRIBUTORS_SYM = 345,
+     CONVERT_SYM = 346,
+     COUNT_SYM = 347,
+     CPU_SYM = 348,
+     CREATE = 349,
+     CROSS = 350,
+     CUBE_SYM = 351,
+     CURDATE = 352,
+     CURRENT_USER = 353,
+     CURSOR_SYM = 354,
+     CURSOR_NAME_SYM = 355,
+     CURTIME = 356,
+     DATABASE = 357,
+     DATABASES = 358,
+     DATAFILE_SYM = 359,
+     DATA_SYM = 360,
+     DATETIME = 361,
+     DATE_ADD_INTERVAL = 362,
+     DATE_SUB_INTERVAL = 363,
+     DATE_SYM = 364,
+     DAY_HOUR_SYM = 365,
+     DAY_MICROSECOND_SYM = 366,
+     DAY_MINUTE_SYM = 367,
+     DAY_SECOND_SYM = 368,
+     DAY_SYM = 369,
+     DEALLOCATE_SYM = 370,
+     DECIMAL_NUM = 371,
+     DECIMAL_SYM = 372,
+     DECLARE_SYM = 373,
+     DEFAULT = 374,
+     DEFINER_SYM = 375,
+     DELAYED_SYM = 376,
+     DELAY_KEY_WRITE_SYM = 377,
+     DELETE_SYM = 378,
+     DESC = 379,
+     DESCRIBE = 380,
+     DES_KEY_FILE = 381,
+     DETERMINISTIC_SYM = 382,
+     DIRECTORY_SYM = 383,
+     DISABLE_SYM = 384,
+     DISCARD = 385,
+     DISK_SYM = 386,
+     DISTINCT = 387,
+     DIV_SYM = 388,
+     DOUBLE_SYM = 389,
+     DO_SYM = 390,
+     DROP = 391,
+     DUAL_SYM = 392,
+     DUMPFILE = 393,
+     DUPLICATE_SYM = 394,
+     DYNAMIC_SYM = 395,
+     EACH_SYM = 396,
+     ELSE = 397,
+     ELSEIF_SYM = 398,
+     ENABLE_SYM = 399,
+     ENCLOSED = 400,
+     END = 401,
+     ENDS_SYM = 402,
+     END_OF_INPUT = 403,
+     ENGINES_SYM = 404,
+     ENGINE_SYM = 405,
+     ENUM = 406,
+     EQ = 407,
+     EQUAL_SYM = 408,
+     ERROR_SYM = 409,
+     ERRORS = 410,
+     ESCAPED = 411,
+     ESCAPE_SYM = 412,
+     EVENTS_SYM = 413,
+     EVENT_SYM = 414,
+     EVERY_SYM = 415,
+     EXECUTE_SYM = 416,
+     EXISTS = 417,
+     EXIT_SYM = 418,
+     EXPANSION_SYM = 419,
+     EXTENDED_SYM = 420,
+     EXTENT_SIZE_SYM = 421,
+     EXTRACT_SYM = 422,
+     FALSE_SYM = 423,
+     FAST_SYM = 424,
+     FAULTS_SYM = 425,
+     FETCH_SYM = 426,
+     FILE_SYM = 427,
+     FIRST_SYM = 428,
+     FIXED_SYM = 429,
+     FLOAT_NUM = 430,
+     FLOAT_SYM = 431,
+     FLUSH_SYM = 432,
+     FORCE_SYM = 433,
+     FOREIGN = 434,
+     FOR_SYM = 435,
+     FOUND_SYM = 436,
+     FROM = 437,
+     FULL = 438,
+     FULLTEXT_SYM = 439,
+     FUNCTION_SYM = 440,
+     GE = 441,
+     GENERAL = 442,
+     GEOMETRYCOLLECTION = 443,
+     GEOMETRY_SYM = 444,
+     GET_FORMAT = 445,
+     GLOBAL_SYM = 446,
+     GRANT = 447,
+     GRANTS = 448,
+     GROUP_SYM = 449,
+     GROUP_CONCAT_SYM = 450,
+     GT_SYM = 451,
+     HANDLER_SYM = 452,
+     HASH_SYM = 453,
+     HAVING = 454,
+     HELP_SYM = 455,
+     HEX_NUM = 456,
+     HIGH_PRIORITY = 457,
+     HOST_SYM = 458,
+     HOSTS_SYM = 459,
+     HOUR_MICROSECOND_SYM = 460,
+     HOUR_MINUTE_SYM = 461,
+     HOUR_SECOND_SYM = 462,
+     HOUR_SYM = 463,
+     IDENT = 464,
+     IDENTIFIED_SYM = 465,
+     IDENT_QUOTED = 466,
+     IF = 467,
+     IGNORE_SYM = 468,
+     IGNORE_SERVER_IDS_SYM = 469,
+     IMPORT = 470,
+     INDEXES = 471,
+     INDEX_SYM = 472,
+     INFILE = 473,
+     INITIAL_SIZE_SYM = 474,
+     INNER_SYM = 475,
+     INOUT_SYM = 476,
+     INSENSITIVE_SYM = 477,
+     INSERT = 478,
+     INSERT_METHOD = 479,
+     INSTALL_SYM = 480,
+     INTERVAL_SYM = 481,
+     INTO = 482,
+     INT_SYM = 483,
+     INVOKER_SYM = 484,
+     IN_SYM = 485,
+     IO_SYM = 486,
+     IPC_SYM = 487,
+     IS = 488,
+     ISOLATION = 489,
+     ISSUER_SYM = 490,
+     ITERATE_SYM = 491,
+     JOIN_SYM = 492,
+     KEYS = 493,
+     KEY_BLOCK_SIZE = 494,
+     KEY_SYM = 495,
+     KILL_SYM = 496,
+     LANGUAGE_SYM = 497,
+     LAST_SYM = 498,
+     LE = 499,
+     LEADING = 500,
+     LEAVES = 501,
+     LEAVE_SYM = 502,
+     LEFT = 503,
+     LESS_SYM = 504,
+     LEVEL_SYM = 505,
+     LEX_HOSTNAME = 506,
+     LIKE = 507,
+     LIMIT = 508,
+     LINEAR_SYM = 509,
+     LINES = 510,
+     LINESTRING = 511,
+     LIST_SYM = 512,
+     LOAD = 513,
+     LOCAL_SYM = 514,
+     LOCATOR_SYM = 515,
+     LOCKS_SYM = 516,
+     LOCK_SYM = 517,
+     LOGFILE_SYM = 518,
+     LOGS_SYM = 519,
+     LONGBLOB = 520,
+     LONGTEXT = 521,
+     LONG_NUM = 522,
+     LONG_SYM = 523,
+     LOOP_SYM = 524,
+     LOW_PRIORITY = 525,
+     LT = 526,
+     MASTER_CONNECT_RETRY_SYM = 527,
+     MASTER_HOST_SYM = 528,
+     MASTER_LOG_FILE_SYM = 529,
+     MASTER_LOG_POS_SYM = 530,
+     MASTER_PASSWORD_SYM = 531,
+     MASTER_PORT_SYM = 532,
+     MASTER_SERVER_ID_SYM = 533,
+     MASTER_SSL_CAPATH_SYM = 534,
+     MASTER_SSL_CA_SYM = 535,
+     MASTER_SSL_CERT_SYM = 536,
+     MASTER_SSL_CIPHER_SYM = 537,
+     MASTER_SSL_KEY_SYM = 538,
+     MASTER_SSL_SYM = 539,
+     MASTER_SSL_VERIFY_SERVER_CERT_SYM = 540,
+     MASTER_SYM = 541,
+     MASTER_USER_SYM = 542,
+     MASTER_HEARTBEAT_PERIOD_SYM = 543,
+     MATCH = 544,
+     MAX_CONNECTIONS_PER_HOUR = 545,
+     MAX_QUERIES_PER_HOUR = 546,
+     MAX_ROWS = 547,
+     MAX_SIZE_SYM = 548,
+     MAX_SYM = 549,
+     MAX_UPDATES_PER_HOUR = 550,
+     MAX_USER_CONNECTIONS_SYM = 551,
+     MAX_VALUE_SYM = 552,
+     MEDIUMBLOB = 553,
+     MEDIUMINT = 554,
+     MEDIUMTEXT = 555,
+     MEDIUM_SYM = 556,
+     MEMORY_SYM = 557,
+     MERGE_SYM = 558,
+     MESSAGE_TEXT_SYM = 559,
+     MICROSECOND_SYM = 560,
+     MIGRATE_SYM = 561,
+     MINUTE_MICROSECOND_SYM = 562,
+     MINUTE_SECOND_SYM = 563,
+     MINUTE_SYM = 564,
+     MIN_ROWS = 565,
+     MIN_SYM = 566,
+     MODE_SYM = 567,
+     MODIFIES_SYM = 568,
+     MODIFY_SYM = 569,
+     MOD_SYM = 570,
+     MONTH_SYM = 571,
+     MULTILINESTRING = 572,
+     MULTIPOINT = 573,
+     MULTIPOLYGON = 574,
+     MUTEX_SYM = 575,
+     MYSQL_ERRNO_SYM = 576,
+     NAMES_SYM = 577,
+     NAME_SYM = 578,
+     NATIONAL_SYM = 579,
+     NATURAL = 580,
+     NCHAR_STRING = 581,
+     NCHAR_SYM = 582,
+     NDBCLUSTER_SYM = 583,
+     NE = 584,
+     NEG = 585,
+     NEW_SYM = 586,
+     NEXT_SYM = 587,
+     NODEGROUP_SYM = 588,
+     NONE_SYM = 589,
+     NOT2_SYM = 590,
+     NOT_SYM = 591,
+     NOW_SYM = 592,
+     NO_SYM = 593,
+     NO_WAIT_SYM = 594,
+     NO_WRITE_TO_BINLOG = 595,
+     NULL_SYM = 596,
+     NUM = 597,
+     NUMERIC_SYM = 598,
+     NVARCHAR_SYM = 599,
+     OFFSET_SYM = 600,
+     OLD_PASSWORD = 601,
+     ON = 602,
+     ONE_SHOT_SYM = 603,
+     ONE_SYM = 604,
+     OPEN_SYM = 605,
+     OPTIMIZE = 606,
+     OPTIONS_SYM = 607,
+     OPTION = 608,
+     OPTIONALLY = 609,
+     OR2_SYM = 610,
+     ORDER_SYM = 611,
+     OR_OR_SYM = 612,
+     OR_SYM = 613,
+     OUTER = 614,
+     OUTFILE = 615,
+     OUT_SYM = 616,
+     OWNER_SYM = 617,
+     PACK_KEYS_SYM = 618,
+     PAGE_SYM = 619,
+     PARAM_MARKER = 620,
+     PARSER_SYM = 621,
+     PARTIAL = 622,
+     PARTITIONING_SYM = 623,
+     PARTITIONS_SYM = 624,
+     PARTITION_SYM = 625,
+     PASSWORD = 626,
+     PHASE_SYM = 627,
+     PLUGINS_SYM = 628,
+     PLUGIN_SYM = 629,
+     POINT_SYM = 630,
+     POLYGON = 631,
+     PORT_SYM = 632,
+     POSITION_SYM = 633,
+     PRECISION = 634,
+     PREPARE_SYM = 635,
+     PRESERVE_SYM = 636,
+     PREV_SYM = 637,
+     PRIMARY_SYM = 638,
+     PRIVILEGES = 639,
+     PROCEDURE_SYM = 640,
+     PROCESS = 641,
+     PROCESSLIST_SYM = 642,
+     PROFILE_SYM = 643,
+     PROFILES_SYM = 644,
+     PURGE = 645,
+     QUARTER_SYM = 646,
+     QUERY_SYM = 647,
+     QUICK = 648,
+     RANGE_SYM = 649,
+     READS_SYM = 650,
+     READ_ONLY_SYM = 651,
+     READ_SYM = 652,
+     READ_WRITE_SYM = 653,
+     REAL = 654,
+     REBUILD_SYM = 655,
+     RECOVER_SYM = 656,
+     REDOFILE_SYM = 657,
+     REDO_BUFFER_SIZE_SYM = 658,
+     REDUNDANT_SYM = 659,
+     REFERENCES = 660,
+     REGEXP = 661,
+     RELAY = 662,
+     RELAYLOG_SYM = 663,
+     RELAY_LOG_FILE_SYM = 664,
+     RELAY_LOG_POS_SYM = 665,
+     RELAY_THREAD = 666,
+     RELEASE_SYM = 667,
+     RELOAD = 668,
+     REMOVE_SYM = 669,
+     RENAME = 670,
+     REORGANIZE_SYM = 671,
+     REPAIR = 672,
+     REPEATABLE_SYM = 673,
+     REPEAT_SYM = 674,
+     REPLACE = 675,
+     REPLICATION = 676,
+     REQUIRE_SYM = 677,
+     RESET_SYM = 678,
+     RESIGNAL_SYM = 679,
+     RESOURCES = 680,
+     RESTORE_SYM = 681,
+     RESTRICT = 682,
+     RESUME_SYM = 683,
+     RETURNS_SYM = 684,
+     RETURN_SYM = 685,
+     REVOKE = 686,
+     RIGHT = 687,
+     ROLLBACK_SYM = 688,
+     ROLLUP_SYM = 689,
+     ROUTINE_SYM = 690,
+     ROWS_SYM = 691,
+     ROW_FORMAT_SYM = 692,
+     ROW_SYM = 693,
+     RTREE_SYM = 694,
+     SAVEPOINT_SYM = 695,
+     SCHEDULE_SYM = 696,
+     SCHEMA_NAME_SYM = 697,
+     SECOND_MICROSECOND_SYM = 698,
+     SECOND_SYM = 699,
+     SECURITY_SYM = 700,
+     SELECT_SYM = 701,
+     SENSITIVE_SYM = 702,
+     SEPARATOR_SYM = 703,
+     SERIALIZABLE_SYM = 704,
+     SERIAL_SYM = 705,
+     SESSION_SYM = 706,
+     SERVER_SYM = 707,
+     SERVER_OPTIONS = 708,
+     SET = 709,
+     SET_VAR = 710,
+     SHARE_SYM = 711,
+     SHIFT_LEFT = 712,
+     SHIFT_RIGHT = 713,
+     SHOW = 714,
+     SHUTDOWN = 715,
+     SIGNAL_SYM = 716,
+     SIGNED_SYM = 717,
+     SIMPLE_SYM = 718,
+     SLAVE = 719,
+     SLOW = 720,
+     SMALLINT = 721,
+     SNAPSHOT_SYM = 722,
+     SOCKET_SYM = 723,
+     SONAME_SYM = 724,
+     SOUNDS_SYM = 725,
+     SOURCE_SYM = 726,
+     SPATIAL_SYM = 727,
+     SPECIFIC_SYM = 728,
+     SQLEXCEPTION_SYM = 729,
+     SQLSTATE_SYM = 730,
+     SQLWARNING_SYM = 731,
+     SQL_BIG_RESULT = 732,
+     SQL_BUFFER_RESULT = 733,
+     SQL_CACHE_SYM = 734,
+     SQL_CALC_FOUND_ROWS = 735,
+     SQL_NO_CACHE_SYM = 736,
+     SQL_SMALL_RESULT = 737,
+     SQL_SYM = 738,
+     SQL_THREAD = 739,
+     SSL_SYM = 740,
+     STARTING = 741,
+     STARTS_SYM = 742,
+     START_SYM = 743,
+     STATUS_SYM = 744,
+     STDDEV_SAMP_SYM = 745,
+     STD_SYM = 746,
+     STOP_SYM = 747,
+     STORAGE_SYM = 748,
+     STRAIGHT_JOIN = 749,
+     STRING_SYM = 750,
+     SUBCLASS_ORIGIN_SYM = 751,
+     SUBDATE_SYM = 752,
+     SUBJECT_SYM = 753,
+     SUBPARTITIONS_SYM = 754,
+     SUBPARTITION_SYM = 755,
+     SUBSTRING = 756,
+     SUM_SYM = 757,
+     SUPER_SYM = 758,
+     SUSPEND_SYM = 759,
+     SWAPS_SYM = 760,
+     SWITCHES_SYM = 761,
+     SYSDATE = 762,
+     TABLES = 763,
+     TABLESPACE = 764,
+     TABLE_REF_PRIORITY = 765,
+     TABLE_SYM = 766,
+     TABLE_CHECKSUM_SYM = 767,
+     TABLE_NAME_SYM = 768,
+     TEMPORARY = 769,
+     TEMPTABLE_SYM = 770,
+     TERMINATED = 771,
+     TEXT_STRING = 772,
+     TEXT_SYM = 773,
+     THAN_SYM = 774,
+     THEN_SYM = 775,
+     TIMESTAMP = 776,
+     TIMESTAMP_ADD = 777,
+     TIMESTAMP_DIFF = 778,
+     TIME_SYM = 779,
+     TINYBLOB = 780,
+     TINYINT = 781,
+     TINYTEXT = 782,
+     TO_SYM = 783,
+     TRAILING = 784,
+     TRANSACTION_SYM = 785,
+     TRIGGERS_SYM = 786,
+     TRIGGER_SYM = 787,
+     TRIM = 788,
+     TRUE_SYM = 789,
+     TRUNCATE_SYM = 790,
+     TYPES_SYM = 791,
+     TYPE_SYM = 792,
+     UDF_RETURNS_SYM = 793,
+     ULONGLONG_NUM = 794,
+     UNCOMMITTED_SYM = 795,
+     UNDEFINED_SYM = 796,
+     UNDERSCORE_CHARSET = 797,
+     UNDOFILE_SYM = 798,
+     UNDO_BUFFER_SIZE_SYM = 799,
+     UNDO_SYM = 800,
+     UNICODE_SYM = 801,
+     UNINSTALL_SYM = 802,
+     UNION_SYM = 803,
+     UNIQUE_SYM = 804,
+     UNKNOWN_SYM = 805,
+     UNLOCK_SYM = 806,
+     UNSIGNED = 807,
+     UNTIL_SYM = 808,
+     UPDATE_SYM = 809,
+     UPGRADE_SYM = 810,
+     USAGE = 811,
+     USER = 812,
+     USE_FRM = 813,
+     USE_SYM = 814,
+     USING = 815,
+     UTC_DATE_SYM = 816,
+     UTC_TIMESTAMP_SYM = 817,
+     UTC_TIME_SYM = 818,
+     VALUES = 819,
+     VALUE_SYM = 820,
+     VARBINARY = 821,
+     VARCHAR = 822,
+     VARIABLES = 823,
+     VARIANCE_SYM = 824,
+     VARYING = 825,
+     VAR_SAMP_SYM = 826,
+     VIEW_SYM = 827,
+     WAIT_SYM = 828,
+     WARNINGS = 829,
+     WEEK_SYM = 830,
+     WHEN_SYM = 831,
+     WHERE = 832,
+     WHILE_SYM = 833,
+     WITH = 834,
+     WITH_CUBE_SYM = 835,
+     WITH_ROLLUP_SYM = 836,
+     WORK_SYM = 837,
+     WRAPPER_SYM = 838,
+     WRITE_SYM = 839,
+     X509_SYM = 840,
+     XA_SYM = 841,
+     XML_SYM = 842,
+     XOR = 843,
+     YEAR_MONTH_SYM = 844,
+     YEAR_SYM = 845,
+     ZEROFILL = 846
+   };
+#endif
+/* Tokens.  */
+#define ABORT_SYM 258
+#define ACCESSIBLE_SYM 259
+#define ACTION 260
+#define ADD 261
+#define ADDDATE_SYM 262
+#define AFTER_SYM 263
+#define AGAINST 264
+#define AGGREGATE_SYM 265
+#define ALGORITHM_SYM 266
+#define ALL 267
+#define ALTER 268
+#define ANALYZE_SYM 269
+#define AND_AND_SYM 270
+#define AND_SYM 271
+#define ANY_SYM 272
+#define AS 273
+#define ASC 274
+#define ASCII_SYM 275
+#define ASENSITIVE_SYM 276
+#define AT_SYM 277
+#define AUTHORS_SYM 278
+#define AUTOEXTEND_SIZE_SYM 279
+#define AUTO_INC 280
+#define AVG_ROW_LENGTH 281
+#define AVG_SYM 282
+#define BACKUP_SYM 283
+#define BEFORE_SYM 284
+#define BEGIN_SYM 285
+#define BETWEEN_SYM 286
+#define BIGINT 287
+#define BINARY 288
+#define BINLOG_SYM 289
+#define BIN_NUM 290
+#define BIT_AND 291
+#define BIT_OR 292
+#define BIT_SYM 293
+#define BIT_XOR 294
+#define BLOB_SYM 295
+#define BLOCK_SYM 296
+#define BOOLEAN_SYM 297
+#define BOOL_SYM 298
+#define BOTH 299
+#define BTREE_SYM 300
+#define BY 301
+#define BYTE_SYM 302
+#define CACHE_SYM 303
+#define CALL_SYM 304
+#define CASCADE 305
+#define CASCADED 306
+#define CASE_SYM 307
+#define CAST_SYM 308
+#define CATALOG_NAME_SYM 309
+#define CHAIN_SYM 310
+#define CHANGE 311
+#define CHANGED 312
+#define CHARSET 313
+#define CHAR_SYM 314
+#define CHECKSUM_SYM 315
+#define CHECK_SYM 316
+#define CIPHER_SYM 317
+#define CLASS_ORIGIN_SYM 318
+#define CLIENT_SYM 319
+#define CLOSE_SYM 320
+#define COALESCE 321
+#define CODE_SYM 322
+#define COLLATE_SYM 323
+#define COLLATION_SYM 324
+#define COLUMNS 325
+#define COLUMN_SYM 326
+#define COLUMN_NAME_SYM 327
+#define COMMENT_SYM 328
+#define COMMITTED_SYM 329
+#define COMMIT_SYM 330
+#define COMPACT_SYM 331
+#define COMPLETION_SYM 332
+#define COMPRESSED_SYM 333
+#define CONCURRENT 334
+#define CONDITION_SYM 335
+#define CONNECTION_SYM 336
+#define CONSISTENT_SYM 337
+#define CONSTRAINT 338
+#define CONSTRAINT_CATALOG_SYM 339
+#define CONSTRAINT_NAME_SYM 340
+#define CONSTRAINT_SCHEMA_SYM 341
+#define CONTAINS_SYM 342
+#define CONTEXT_SYM 343
+#define CONTINUE_SYM 344
+#define CONTRIBUTORS_SYM 345
+#define CONVERT_SYM 346
+#define COUNT_SYM 347
+#define CPU_SYM 348
+#define CREATE 349
+#define CROSS 350
+#define CUBE_SYM 351
+#define CURDATE 352
+#define CURRENT_USER 353
+#define CURSOR_SYM 354
+#define CURSOR_NAME_SYM 355
+#define CURTIME 356
+#define DATABASE 357
+#define DATABASES 358
+#define DATAFILE_SYM 359
+#define DATA_SYM 360
+#define DATETIME 361
+#define DATE_ADD_INTERVAL 362
+#define DATE_SUB_INTERVAL 363
+#define DATE_SYM 364
+#define DAY_HOUR_SYM 365
+#define DAY_MICROSECOND_SYM 366
+#define DAY_MINUTE_SYM 367
+#define DAY_SECOND_SYM 368
+#define DAY_SYM 369
+#define DEALLOCATE_SYM 370
+#define DECIMAL_NUM 371
+#define DECIMAL_SYM 372
+#define DECLARE_SYM 373
+#define DEFAULT 374
+#define DEFINER_SYM 375
+#define DELAYED_SYM 376
+#define DELAY_KEY_WRITE_SYM 377
+#define DELETE_SYM 378
+#define DESC 379
+#define DESCRIBE 380
+#define DES_KEY_FILE 381
+#define DETERMINISTIC_SYM 382
+#define DIRECTORY_SYM 383
+#define DISABLE_SYM 384
+#define DISCARD 385
+#define DISK_SYM 386
+#define DISTINCT 387
+#define DIV_SYM 388
+#define DOUBLE_SYM 389
+#define DO_SYM 390
+#define DROP 391
+#define DUAL_SYM 392
+#define DUMPFILE 393
+#define DUPLICATE_SYM 394
+#define DYNAMIC_SYM 395
+#define EACH_SYM 396
+#define ELSE 397
+#define ELSEIF_SYM 398
+#define ENABLE_SYM 399
+#define ENCLOSED 400
+#define END 401
+#define ENDS_SYM 402
+#define END_OF_INPUT 403
+#define ENGINES_SYM 404
+#define ENGINE_SYM 405
+#define ENUM 406
+#define EQ 407
+#define EQUAL_SYM 408
+#define ERROR_SYM 409
+#define ERRORS 410
+#define ESCAPED 411
+#define ESCAPE_SYM 412
+#define EVENTS_SYM 413
+#define EVENT_SYM 414
+#define EVERY_SYM 415
+#define EXECUTE_SYM 416
+#define EXISTS 417
+#define EXIT_SYM 418
+#define EXPANSION_SYM 419
+#define EXTENDED_SYM 420
+#define EXTENT_SIZE_SYM 421
+#define EXTRACT_SYM 422
+#define FALSE_SYM 423
+#define FAST_SYM 424
+#define FAULTS_SYM 425
+#define FETCH_SYM 426
+#define FILE_SYM 427
+#define FIRST_SYM 428
+#define FIXED_SYM 429
+#define FLOAT_NUM 430
+#define FLOAT_SYM 431
+#define FLUSH_SYM 432
+#define FORCE_SYM 433
+#define FOREIGN 434
+#define FOR_SYM 435
+#define FOUND_SYM 436
+#define FROM 437
+#define FULL 438
+#define FULLTEXT_SYM 439
+#define FUNCTION_SYM 440
+#define GE 441
+#define GENERAL 442
+#define GEOMETRYCOLLECTION 443
+#define GEOMETRY_SYM 444
+#define GET_FORMAT 445
+#define GLOBAL_SYM 446
+#define GRANT 447
+#define GRANTS 448
+#define GROUP_SYM 449
+#define GROUP_CONCAT_SYM 450
+#define GT_SYM 451
+#define HANDLER_SYM 452
+#define HASH_SYM 453
+#define HAVING 454
+#define HELP_SYM 455
+#define HEX_NUM 456
+#define HIGH_PRIORITY 457
+#define HOST_SYM 458
+#define HOSTS_SYM 459
+#define HOUR_MICROSECOND_SYM 460
+#define HOUR_MINUTE_SYM 461
+#define HOUR_SECOND_SYM 462
+#define HOUR_SYM 463
+#define IDENT 464
+#define IDENTIFIED_SYM 465
+#define IDENT_QUOTED 466
+#define IF 467
+#define IGNORE_SYM 468
+#define IGNORE_SERVER_IDS_SYM 469
+#define IMPORT 470
+#define INDEXES 471
+#define INDEX_SYM 472
+#define INFILE 473
+#define INITIAL_SIZE_SYM 474
+#define INNER_SYM 475
+#define INOUT_SYM 476
+#define INSENSITIVE_SYM 477
+#define INSERT 478
+#define INSERT_METHOD 479
+#define INSTALL_SYM 480
+#define INTERVAL_SYM 481
+#define INTO 482
+#define INT_SYM 483
+#define INVOKER_SYM 484
+#define IN_SYM 485
+#define IO_SYM 486
+#define IPC_SYM 487
+#define IS 488
+#define ISOLATION 489
+#define ISSUER_SYM 490
+#define ITERATE_SYM 491
+#define JOIN_SYM 492
+#define KEYS 493
+#define KEY_BLOCK_SIZE 494
+#define KEY_SYM 495
+#define KILL_SYM 496
+#define LANGUAGE_SYM 497
+#define LAST_SYM 498
+#define LE 499
+#define LEADING 500
+#define LEAVES 501
+#define LEAVE_SYM 502
+#define LEFT 503
+#define LESS_SYM 504
+#define LEVEL_SYM 505
+#define LEX_HOSTNAME 506
+#define LIKE 507
+#define LIMIT 508
+#define LINEAR_SYM 509
+#define LINES 510
+#define LINESTRING 511
+#define LIST_SYM 512
+#define LOAD 513
+#define LOCAL_SYM 514
+#define LOCATOR_SYM 515
+#define LOCKS_SYM 516
+#define LOCK_SYM 517
+#define LOGFILE_SYM 518
+#define LOGS_SYM 519
+#define LONGBLOB 520
+#define LONGTEXT 521
+#define LONG_NUM 522
+#define LONG_SYM 523
+#define LOOP_SYM 524
+#define LOW_PRIORITY 525
+#define LT 526
+#define MASTER_CONNECT_RETRY_SYM 527
+#define MASTER_HOST_SYM 528
+#define MASTER_LOG_FILE_SYM 529
+#define MASTER_LOG_POS_SYM 530
+#define MASTER_PASSWORD_SYM 531
+#define MASTER_PORT_SYM 532
+#define MASTER_SERVER_ID_SYM 533
+#define MASTER_SSL_CAPATH_SYM 534
+#define MASTER_SSL_CA_SYM 535
+#define MASTER_SSL_CERT_SYM 536
+#define MASTER_SSL_CIPHER_SYM 537
+#define MASTER_SSL_KEY_SYM 538
+#define MASTER_SSL_SYM 539
+#define MASTER_SSL_VERIFY_SERVER_CERT_SYM 540
+#define MASTER_SYM 541
+#define MASTER_USER_SYM 542
+#define MASTER_HEARTBEAT_PERIOD_SYM 543
+#define MATCH 544
+#define MAX_CONNECTIONS_PER_HOUR 545
+#define MAX_QUERIES_PER_HOUR 546
+#define MAX_ROWS 547
+#define MAX_SIZE_SYM 548
+#define MAX_SYM 549
+#define MAX_UPDATES_PER_HOUR 550
+#define MAX_USER_CONNECTIONS_SYM 551
+#define MAX_VALUE_SYM 552
+#define MEDIUMBLOB 553
+#define MEDIUMINT 554
+#define MEDIUMTEXT 555
+#define MEDIUM_SYM 556
+#define MEMORY_SYM 557
+#define MERGE_SYM 558
+#define MESSAGE_TEXT_SYM 559
+#define MICROSECOND_SYM 560
+#define MIGRATE_SYM 561
+#define MINUTE_MICROSECOND_SYM 562
+#define MINUTE_SECOND_SYM 563
+#define MINUTE_SYM 564
+#define MIN_ROWS 565
+#define MIN_SYM 566
+#define MODE_SYM 567
+#define MODIFIES_SYM 568
+#define MODIFY_SYM 569
+#define MOD_SYM 570
+#define MONTH_SYM 571
+#define MULTILINESTRING 572
+#define MULTIPOINT 573
+#define MULTIPOLYGON 574
+#define MUTEX_SYM 575
+#define MYSQL_ERRNO_SYM 576
+#define NAMES_SYM 577
+#define NAME_SYM 578
+#define NATIONAL_SYM 579
+#define NATURAL 580
+#define NCHAR_STRING 581
+#define NCHAR_SYM 582
+#define NDBCLUSTER_SYM 583
+#define NE 584
+#define NEG 585
+#define NEW_SYM 586
+#define NEXT_SYM 587
+#define NODEGROUP_SYM 588
+#define NONE_SYM 589
+#define NOT2_SYM 590
+#define NOT_SYM 591
+#define NOW_SYM 592
+#define NO_SYM 593
+#define NO_WAIT_SYM 594
+#define NO_WRITE_TO_BINLOG 595
+#define NULL_SYM 596
+#define NUM 597
+#define NUMERIC_SYM 598
+#define NVARCHAR_SYM 599
+#define OFFSET_SYM 600
+#define OLD_PASSWORD 601
+#define ON 602
+#define ONE_SHOT_SYM 603
+#define ONE_SYM 604
+#define OPEN_SYM 605
+#define OPTIMIZE 606
+#define OPTIONS_SYM 607
+#define OPTION 608
+#define OPTIONALLY 609
+#define OR2_SYM 610
+#define ORDER_SYM 611
+#define OR_OR_SYM 612
+#define OR_SYM 613
+#define OUTER 614
+#define OUTFILE 615
+#define OUT_SYM 616
+#define OWNER_SYM 617
+#define PACK_KEYS_SYM 618
+#define PAGE_SYM 619
+#define PARAM_MARKER 620
+#define PARSER_SYM 621
+#define PARTIAL 622
+#define PARTITIONING_SYM 623
+#define PARTITIONS_SYM 624
+#define PARTITION_SYM 625
+#define PASSWORD 626
+#define PHASE_SYM 627
+#define PLUGINS_SYM 628
+#define PLUGIN_SYM 629
+#define POINT_SYM 630
+#define POLYGON 631
+#define PORT_SYM 632
+#define POSITION_SYM 633
+#define PRECISION 634
+#define PREPARE_SYM 635
+#define PRESERVE_SYM 636
+#define PREV_SYM 637
+#define PRIMARY_SYM 638
+#define PRIVILEGES 639
+#define PROCEDURE_SYM 640
+#define PROCESS 641
+#define PROCESSLIST_SYM 642
+#define PROFILE_SYM 643
+#define PROFILES_SYM 644
+#define PURGE 645
+#define QUARTER_SYM 646
+#define QUERY_SYM 647
+#define QUICK 648
+#define RANGE_SYM 649
+#define READS_SYM 650
+#define READ_ONLY_SYM 651
+#define READ_SYM 652
+#define READ_WRITE_SYM 653
+#define REAL 654
+#define REBUILD_SYM 655
+#define RECOVER_SYM 656
+#define REDOFILE_SYM 657
+#define REDO_BUFFER_SIZE_SYM 658
+#define REDUNDANT_SYM 659
+#define REFERENCES 660
+#define REGEXP 661
+#define RELAY 662
+#define RELAYLOG_SYM 663
+#define RELAY_LOG_FILE_SYM 664
+#define RELAY_LOG_POS_SYM 665
+#define RELAY_THREAD 666
+#define RELEASE_SYM 667
+#define RELOAD 668
+#define REMOVE_SYM 669
+#define RENAME 670
+#define REORGANIZE_SYM 671
+#define REPAIR 672
+#define REPEATABLE_SYM 673
+#define REPEAT_SYM 674
+#define REPLACE 675
+#define REPLICATION 676
+#define REQUIRE_SYM 677
+#define RESET_SYM 678
+#define RESIGNAL_SYM 679
+#define RESOURCES 680
+#define RESTORE_SYM 681
+#define RESTRICT 682
+#define RESUME_SYM 683
+#define RETURNS_SYM 684
+#define RETURN_SYM 685
+#define REVOKE 686
+#define RIGHT 687
+#define ROLLBACK_SYM 688
+#define ROLLUP_SYM 689
+#define ROUTINE_SYM 690
+#define ROWS_SYM 691
+#define ROW_FORMAT_SYM 692
+#define ROW_SYM 693
+#define RTREE_SYM 694
+#define SAVEPOINT_SYM 695
+#define SCHEDULE_SYM 696
+#define SCHEMA_NAME_SYM 697
+#define SECOND_MICROSECOND_SYM 698
+#define SECOND_SYM 699
+#define SECURITY_SYM 700
+#define SELECT_SYM 701
+#define SENSITIVE_SYM 702
+#define SEPARATOR_SYM 703
+#define SERIALIZABLE_SYM 704
+#define SERIAL_SYM 705
+#define SESSION_SYM 706
+#define SERVER_SYM 707
+#define SERVER_OPTIONS 708
+#define SET 709
+#define SET_VAR 710
+#define SHARE_SYM 711
+#define SHIFT_LEFT 712
+#define SHIFT_RIGHT 713
+#define SHOW 714
+#define SHUTDOWN 715
+#define SIGNAL_SYM 716
+#define SIGNED_SYM 717
+#define SIMPLE_SYM 718
+#define SLAVE 719
+#define SLOW 720
+#define SMALLINT 721
+#define SNAPSHOT_SYM 722
+#define SOCKET_SYM 723
+#define SONAME_SYM 724
+#define SOUNDS_SYM 725
+#define SOURCE_SYM 726
+#define SPATIAL_SYM 727
+#define SPECIFIC_SYM 728
+#define SQLEXCEPTION_SYM 729
+#define SQLSTATE_SYM 730
+#define SQLWARNING_SYM 731
+#define SQL_BIG_RESULT 732
+#define SQL_BUFFER_RESULT 733
+#define SQL_CACHE_SYM 734
+#define SQL_CALC_FOUND_ROWS 735
+#define SQL_NO_CACHE_SYM 736
+#define SQL_SMALL_RESULT 737
+#define SQL_SYM 738
+#define SQL_THREAD 739
+#define SSL_SYM 740
+#define STARTING 741
+#define STARTS_SYM 742
+#define START_SYM 743
+#define STATUS_SYM 744
+#define STDDEV_SAMP_SYM 745
+#define STD_SYM 746
+#define STOP_SYM 747
+#define STORAGE_SYM 748
+#define STRAIGHT_JOIN 749
+#define STRING_SYM 750
+#define SUBCLASS_ORIGIN_SYM 751
+#define SUBDATE_SYM 752
+#define SUBJECT_SYM 753
+#define SUBPARTITIONS_SYM 754
+#define SUBPARTITION_SYM 755
+#define SUBSTRING 756
+#define SUM_SYM 757
+#define SUPER_SYM 758
+#define SUSPEND_SYM 759
+#define SWAPS_SYM 760
+#define SWITCHES_SYM 761
+#define SYSDATE 762
+#define TABLES 763
+#define TABLESPACE 764
+#define TABLE_REF_PRIORITY 765
+#define TABLE_SYM 766
+#define TABLE_CHECKSUM_SYM 767
+#define TABLE_NAME_SYM 768
+#define TEMPORARY 769
+#define TEMPTABLE_SYM 770
+#define TERMINATED 771
+#define TEXT_STRING 772
+#define TEXT_SYM 773
+#define THAN_SYM 774
+#define THEN_SYM 775
+#define TIMESTAMP 776
+#define TIMESTAMP_ADD 777
+#define TIMESTAMP_DIFF 778
+#define TIME_SYM 779
+#define TINYBLOB 780
+#define TINYINT 781
+#define TINYTEXT 782
+#define TO_SYM 783
+#define TRAILING 784
+#define TRANSACTION_SYM 785
+#define TRIGGERS_SYM 786
+#define TRIGGER_SYM 787
+#define TRIM 788
+#define TRUE_SYM 789
+#define TRUNCATE_SYM 790
+#define TYPES_SYM 791
+#define TYPE_SYM 792
+#define UDF_RETURNS_SYM 793
+#define ULONGLONG_NUM 794
+#define UNCOMMITTED_SYM 795
+#define UNDEFINED_SYM 796
+#define UNDERSCORE_CHARSET 797
+#define UNDOFILE_SYM 798
+#define UNDO_BUFFER_SIZE_SYM 799
+#define UNDO_SYM 800
+#define UNICODE_SYM 801
+#define UNINSTALL_SYM 802
+#define UNION_SYM 803
+#define UNIQUE_SYM 804
+#define UNKNOWN_SYM 805
+#define UNLOCK_SYM 806
+#define UNSIGNED 807
+#define UNTIL_SYM 808
+#define UPDATE_SYM 809
+#define UPGRADE_SYM 810
+#define USAGE 811
+#define USER 812
+#define USE_FRM 813
+#define USE_SYM 814
+#define USING 815
+#define UTC_DATE_SYM 816
+#define UTC_TIMESTAMP_SYM 817
+#define UTC_TIME_SYM 818
+#define VALUES 819
+#define VALUE_SYM 820
+#define VARBINARY 821
+#define VARCHAR 822
+#define VARIABLES 823
+#define VARIANCE_SYM 824
+#define VARYING 825
+#define VAR_SAMP_SYM 826
+#define VIEW_SYM 827
+#define WAIT_SYM 828
+#define WARNINGS 829
+#define WEEK_SYM 830
+#define WHEN_SYM 831
+#define WHERE 832
+#define WHILE_SYM 833
+#define WITH 834
+#define WITH_CUBE_SYM 835
+#define WITH_ROLLUP_SYM 836
+#define WORK_SYM 837
+#define WRAPPER_SYM 838
+#define WRITE_SYM 839
+#define X509_SYM 840
+#define XA_SYM 841
+#define XML_SYM 842
+#define XOR 843
+#define YEAR_MONTH_SYM 844
+#define YEAR_SYM 845
+#define ZEROFILL 846
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 1676 of yacc.c  */
+#line 724 "/home/bzr/mkindahl/w4877-trunk-20100323/sql/sql_yacc.yy"
+
+  int  num;
+  ulong ulong_num;
+  ulonglong ulonglong_number;
+  longlong longlong_number;
+  LEX_STRING lex_str;
+  LEX_STRING *lex_str_ptr;
+  LEX_SYMBOL symbol;
+  Table_ident *table;
+  char *simple_string;
+  Item *item;
+  Item_num *item_num;
+  List *item_list;
+  List *string_list;
+  String *string;
+  Key_part_spec *key_part;
+  TABLE_LIST *table_list;
+  udf_func *udf;
+  LEX_USER *lex_user;
+  struct sys_var_with_base variable;
+  enum enum_var_type var_type;
+  Key::Keytype key_type;
+  enum ha_key_alg key_alg;
+  handlerton *db_type;
+  enum row_type row_type;
+  enum ha_rkey_function ha_rkey_mode;
+  enum enum_tx_isolation tx_isolation;
+  enum Cast_target cast_type;
+  enum Item_udftype udf_type;
+  CHARSET_INFO *charset;
+  thr_lock_type lock_type;
+  interval_type interval, interval_time_st;
+  timestamp_type date_time_type;
+  st_select_lex *select_lex;
+  chooser_compare_func_creator boolfunc2creator;
+  struct sp_cond_type *spcondtype;
+  struct { int vars, conds, hndlrs, curs; } spblock;
+  sp_name *spname;
+  LEX *lex;
+  sp_head *sphead;
+  struct p_elem_val *p_elem_value;
+  enum index_hint_type index_hint;
+  enum enum_filetype filetype;
+  enum Foreign_key::fk_option m_fk_option;
+  Diag_condition_item_name diag_condition_item_name;
+
+
+
+/* Line 1676 of yacc.c  */
+#line 1283 "/home/bzr/mkindahl/w4877-trunk-20100323/sql/sql_yacc.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+
+
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index ea9605687d3..207e72404ef 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -35,7 +35,14 @@
 #define YYMAXDEPTH 3200                        /* Because of 64K stack */
 #define Lex (YYTHD->lex)
 #define Select Lex->current_select
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "sql_parse.h"                        /* comp_*_creator */
+#include "sql_table.h"                        /* primary_key_name */
+#include "sql_partition.h"  /* mem_alloc_error, partition_info, HASH_PARTITION */
+#include "sql_acl.h"                          /* *_ACL */
+#include "password.h"       /* my_make_scrambled_password_323, my_make_scrambled_password */
+#include "sql_class.h"      /* Key_part_spec, enum_filetype, Diag_condition_item_name */
 #include "slave.h"
 #include "lex_symbol.h"
 #include "item_create.h"
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index d7ab102b225..a0e2f39f8dc 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -15,7 +15,13 @@
 
 /* Some useful string utility functions used by the MySQL server */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "strfunc.h"
+#include "sql_class.h"
+#include "typelib.h"                            // TYPELIB
+#include "m_ctype.h"                            // my_charset_latin1
+#include "mysqld.h"                             // system_charset_info
 
 /*
   Return bitmap for strings used in a set
diff --git a/sql/strfunc.h b/sql/strfunc.h
new file mode 100644
index 00000000000..f1eb83ff0de
--- /dev/null
+++ b/sql/strfunc.h
@@ -0,0 +1,51 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef STRFUNC_INCLUDED
+#define STRFUNC_INCLUDED
+
+#include "my_global.h"                          /* ulonglong, uint */
+
+typedef struct charset_info_st CHARSET_INFO;
+typedef struct st_mysql_lex_string LEX_STRING;
+typedef struct st_typelib TYPELIB;
+
+ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs,
+		   char **err_pos, uint *err_len, bool *set_warning);
+ulonglong find_set_from_flags(TYPELIB *lib, uint default_name,
+                              ulonglong cur_set, ulonglong default_set,
+                              const char *str, uint length, CHARSET_INFO *cs,
+                              char **err_pos, uint *err_len, bool *set_warning);
+uint find_type(const TYPELIB *lib, const char *find, uint length,
+               bool part_match);
+uint find_type2(const TYPELIB *lib, const char *find, uint length,
+                CHARSET_INFO *cs);
+void unhex_type2(TYPELIB *lib);
+uint check_word(TYPELIB *lib, const char *val, const char *end,
+		const char **end_of_word);
+int find_string_in_array(LEX_STRING * const haystack, LEX_STRING * const needle,
+                         CHARSET_INFO * const cs);
+char *flagset_to_string(THD *thd, LEX_STRING *result, ulonglong set,
+                        const char *lib[]);
+char *set_to_string(THD *thd, LEX_STRING *result, ulonglong set,
+                    const char *lib[]);
+
+/*
+  These functions were protected by INNODB_COMPATIBILITY_HOOKS
+ */
+uint strconvert(CHARSET_INFO *from_cs, const char *from,
+                CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
+
+#endif /* STRFUNC_INCLUDED */
diff --git a/sql/structs.h b/sql/structs.h
index 6d2cf54d693..5ffcc4dc62e 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -17,10 +17,18 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 
+
 /* The old structures from unireg */
 
+#include "sql_plugin.h"                         /* plugin_ref */
+#include "sql_const.h"                          /* MAX_REFLENGTH */
+#include "my_time.h"                   /* enum_mysql_timestamp_type */
+#include "thr_lock.h"                  /* thr_lock_type */
+#include "my_base.h"                   /* ha_rows, ha_key_alg */
+
 struct TABLE;
 class Field;
+
 class THD;
 
 typedef struct st_date_time_format {
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index e14286210b4..9fcf968ff31 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -27,6 +27,8 @@
   (for example in storage/myisam/ha_myisam.cc) !
 */
 
+#include "sql_priv.h"
+#include "sql_class.h"                          // set_var.h: THD
 #include "sys_vars.h"
 
 #include "events.h"
@@ -34,11 +36,25 @@
 #include "slave.h"
 #include "rpl_mi.h"
 #include "transaction.h"
+#include "mysqld.h"
+#include "lock.h"
+#include "sql_time.h"                       // known_date_time_formats
+#include "sql_acl.h" // SUPER_ACL,
+                     // mysql_user_table_is_in_short_password_format
+#include "derror.h"  // read_texts
+#include "sql_base.h"                           // close_cached_tables
 
 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
 #include "../storage/perfschema/pfs_server.h"
 #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
+/*
+  This forward declaration is needed because including sql_base.h
+  causes further includes.  [TODO] Eliminate this forward declaration
+  and include a file with the prototype instead.
+*/
+extern void close_thread_tables(THD *thd);
+
 /*
   The rule for this file: everything should be 'static'. When a sys_var
   variable or a function from this file is - in very rare cases - needed
diff --git a/sql/sys_vars.h b/sql/sys_vars.h
index ccc36c72786..c4855ef4fd3 100644
--- a/sql/sys_vars.h
+++ b/sql/sys_vars.h
@@ -26,6 +26,8 @@
 #include 
 #include 
 #include "keycaches.h"
+#include "strfunc.h"
+#include "tztime.h"     // my_tz_find, my_tz_SYSTEM, struct Time_zone
 
 /*
   a set of mostly trivial (as in f(X)=X) defines below to make system variable
diff --git a/sql/sys_vars_shared.h b/sql/sys_vars_shared.h
index a8ef9034715..644cc10c853 100644
--- a/sql/sys_vars_shared.h
+++ b/sql/sys_vars_shared.h
@@ -1,3 +1,6 @@
+#ifndef SYS_VARS_SHARED_INCLUDED
+#define SYS_VARS_SHARED_INCLUDED
+
 /* Copyright (C) 2002-2006 MySQL AB, 2009-2010 Sun Microsystems, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -22,7 +25,7 @@
   classes in the sys_var hierarchy (sql_plugin.cc)
 */
 
-#include 
+#include 
 #include "set_var.h"
 
 extern bool throw_bounds_warning(THD *thd, const char *name,
@@ -79,3 +82,5 @@ public:
   ~AutoRLock() { if (lock) lock->unlock(); }
 };
 
+
+#endif /* SYS_VARS_SHARED_INCLUDED */
diff --git a/sql/table.cc b/sql/table.cc
index 94f3037a81b..d624c25877f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -16,8 +16,20 @@
 
 /* Some general useful functions */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"                    // REQUIRED: for other includes
+#include "table.h"
+#include "frm_crypt.h"           // get_crypt_for_frm
+#include "key.h"                                // find_ref_key
+#include "sql_table.h"                          // build_table_filename,
+                                                // primary_key_name
 #include "sql_trigger.h"
+#include "sql_parse.h"                          // free_items
+#include "strfunc.h"                            // unhex_type2
+#include "sql_partition.h"       // mysql_unpack_partition,
+                                 // fix_partition_func, partition_info
+#include "sql_acl.h"             // *_ACL, acl_getroot_no_password
+#include "sql_base.h"            // release_table_share
 #include 
 #include "my_md5.h"
 
diff --git a/sql/table.h b/sql/table.h
index 3832e7c9555..f626ac6ca59 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -17,8 +17,16 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include "sql_plist.h"
+#include "sql_list.h"                           /* Sql_alloc */
 #include "mdl.h"
 
+#ifndef MYSQL_CLIENT
+
+#include "hash.h"                               /* HASH */
+#include "handler.h"                /* row_type, ha_choice, handler */
+#include "mysql_com.h"              /* enum_field_types */
+#include "thr_lock.h"                  /* thr_lock_type */
+
 /* Structs that defines the TABLE */
 
 class Item;				/* Needed by ORDER */
@@ -30,11 +38,144 @@ class st_select_lex;
 class partition_info;
 class COND_EQUAL;
 class Security_context;
+class TABLE_LIST;
 class ACL_internal_schema_access;
 class ACL_internal_table_access;
+class TABLE_LIST;
+class Field;
+
+/*
+  Used to identify NESTED_JOIN structures within a join (applicable only to
+  structures that have not been simplified away and embed more the one
+  element)
+*/
+typedef ulonglong nested_join_map;
+
+
+#define tmp_file_prefix "#sql"			/**< Prefix for tmp tables */
+#define tmp_file_prefix_length 4
+#define TMP_TABLE_KEY_EXTRA 8
+
+/**
+  Enumerate possible types of a table from re-execution
+  standpoint.
+  TABLE_LIST class has a member of this type.
+  At prepared statement prepare, this member is assigned a value
+  as of the current state of the database. Before (re-)execution
+  of a prepared statement, we check that the value recorded at
+  prepare matches the type of the object we obtained from the
+  table definition cache.
+
+  @sa check_and_update_table_version()
+  @sa Execute_observer
+  @sa Prepared_statement::reprepare()
+*/
+
+enum enum_table_ref_type
+{
+  /** Initial value set by the parser */
+  TABLE_REF_NULL= 0,
+  TABLE_REF_VIEW,
+  TABLE_REF_BASE_TABLE,
+  TABLE_REF_I_S_TABLE,
+  TABLE_REF_TMP_TABLE
+};
+
+
+/**
+  Opening modes for open_temporary_table and open_table_from_share
+*/
+
+enum open_table_mode
+{
+  OTM_OPEN= 0,
+  OTM_CREATE= 1,
+  OTM_ALTER= 2
+};
+
 
 /*************************************************************************/
 
+/**
+ Object_creation_ctx -- interface for creation context of database objects
+ (views, stored routines, events, triggers). Creation context -- is a set
+ of attributes, that should be fixed at the creation time and then be used
+ each time the object is parsed or executed.
+*/
+
+class Object_creation_ctx
+{
+public:
+  Object_creation_ctx *set_n_backup(THD *thd);
+
+  void restore_env(THD *thd, Object_creation_ctx *backup_ctx);
+
+protected:
+  Object_creation_ctx() {}
+  virtual Object_creation_ctx *create_backup_ctx(THD *thd) const = 0;
+
+  virtual void change_env(THD *thd) const = 0;
+
+public:
+  virtual ~Object_creation_ctx()
+  { }
+};
+
+/*************************************************************************/
+
+/**
+ Default_object_creation_ctx -- default implementation of
+ Object_creation_ctx.
+*/
+
+class Default_object_creation_ctx : public Object_creation_ctx
+{
+public:
+  CHARSET_INFO *get_client_cs()
+  {
+    return m_client_cs;
+  }
+
+  CHARSET_INFO *get_connection_cl()
+  {
+    return m_connection_cl;
+  }
+
+protected:
+  Default_object_creation_ctx(THD *thd);
+
+  Default_object_creation_ctx(CHARSET_INFO *client_cs,
+                              CHARSET_INFO *connection_cl);
+
+protected:
+  virtual Object_creation_ctx *create_backup_ctx(THD *thd) const;
+
+  virtual void change_env(THD *thd) const;
+
+protected:
+  /**
+    client_cs stores the value of character_set_client session variable.
+    The only character set attribute is used.
+
+    Client character set is included into query context, because we save
+    query in the original character set, which is client character set. So,
+    in order to parse the query properly we have to switch client character
+    set on parsing.
+  */
+  CHARSET_INFO *m_client_cs;
+
+  /**
+    connection_cl stores the value of collation_connection session
+    variable. Both character set and collation attributes are used.
+
+    Connection collation is included into query context, becase it defines
+    the character set and collation of text literals in internal
+    representation of query (item-objects).
+  */
+  CHARSET_INFO *m_connection_cl;
+};
+
+
 /**
  View_creation_ctx -- creation context of view objects.
 */
@@ -164,15 +305,6 @@ enum tmp_table_type
   INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE
 };
 
-/** Event on which trigger is invoked. */
-enum trg_event_type
-{
-  TRG_EVENT_INSERT= 0,
-  TRG_EVENT_UPDATE= 1,
-  TRG_EVENT_DELETE= 2,
-  TRG_EVENT_MAX
-};
-
 enum frm_type_enum
 {
   FRMTYPE_ERROR= 0,
@@ -1859,4 +1991,82 @@ size_t max_row_length(TABLE *table, const uchar *data);
 
 void init_mdl_requests(TABLE_LIST *table_list);
 
+int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
+                          uint db_stat, uint prgflag, uint ha_open_flags,
+                          TABLE *outparam, bool is_create_table);
+TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
+                               uint key_length);
+void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
+                          uint key_length,
+                          const char *table_name, const char *path);
+void free_table_share(TABLE_SHARE *share);
+int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
+void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
+void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
+bool check_and_convert_db_name(LEX_STRING *db, bool preserve_lettercase);
+bool check_db_name(LEX_STRING *db);
+bool check_column_name(const char *name);
+bool check_table_name(const char *name, uint length);
+int rename_file_ext(const char * from,const char * to,const char * ext);
+char *get_field(MEM_ROOT *mem, Field *field);
+bool get_field(MEM_ROOT *mem, Field *field, class String *res);
+
+int closefrm(TABLE *table, bool free_share);
+int read_string(File file, uchar* *to, size_t length);
+void free_blobs(TABLE *table);
+void free_field_buffers_larger_than(TABLE *table, uint32 size);
+int set_zone(int nr,int min_zone,int max_zone);
+ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
+ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
+		     const char *newname);
+ulong next_io_size(ulong pos);
+void append_unescaped(String *res, const char *pos, uint length);
+File create_frm(THD *thd, const char *name, const char *db,
+                const char *table, uint reclength, uchar *fileinfo,
+  		HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
+char *fn_rext(char *name);
+
+/* performance schema */
+extern LEX_STRING PERFORMANCE_SCHEMA_DB_NAME;
+
+extern LEX_STRING GENERAL_LOG_NAME;
+extern LEX_STRING SLOW_LOG_NAME;
+
+/* information schema */
+extern LEX_STRING INFORMATION_SCHEMA_NAME;
+extern LEX_STRING MYSQL_SCHEMA_NAME;
+
+inline bool is_infoschema_db(const char *name, size_t len)
+{
+  return (INFORMATION_SCHEMA_NAME.length == len &&
+          !my_strcasecmp(system_charset_info,
+                         INFORMATION_SCHEMA_NAME.str, name));
+}
+
+inline bool is_infoschema_db(const char *name)
+{
+  return !my_strcasecmp(system_charset_info,
+                        INFORMATION_SCHEMA_NAME.str, name);
+}
+
+TYPELIB *typelib(MEM_ROOT *mem_root, List &strings);
+
+/**
+  return true if the table was created explicitly.
+*/
+inline bool is_user_table(TABLE * table)
+{
+  const char *name= table->s->table_name.str;
+  return strncmp(name, tmp_file_prefix, tmp_file_prefix_length);
+}
+
+inline void mark_as_null_row(TABLE *table)
+{
+  table->null_row=1;
+  table->status|=STATUS_NULL_ROW;
+  bfill(table->null_flags,table->s->null_bytes,255);
+}
+
+#endif /* MYSQL_CLIENT */
+
 #endif /* TABLE_INCLUDED */
diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc
index ed17f7968c0..638f3bbb9f1 100644
--- a/sql/thr_malloc.cc
+++ b/sql/thr_malloc.cc
@@ -16,7 +16,10 @@
 
 /* Mallocs for used in threads */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "thr_malloc.h"
+#include "sql_class.h"
 
 extern "C" {
   void sql_alloc_error_handler(void)
diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h
new file mode 100644
index 00000000000..a655884b8b4
--- /dev/null
+++ b/sql/thr_malloc.h
@@ -0,0 +1,36 @@
+/* Copyright 2006-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
+
+#ifndef THR_MALLOC_INCLUDED
+#define THR_MALLOC_INCLUDED
+
+#include "my_global.h"                          // uint, size_t
+
+typedef struct charset_info_st CHARSET_INFO;
+typedef struct st_mem_root MEM_ROOT;
+
+void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size);
+void *sql_alloc(size_t);
+void *sql_calloc(size_t);
+char *sql_strdup(const char *str);
+char *sql_strmake(const char *str, size_t len);
+void *sql_memdup(const void * ptr, size_t size);
+void sql_element_free(void *ptr);
+char *sql_strmake_with_convert(const char *str, size_t arg_length,
+			       CHARSET_INFO *from_cs,
+			       size_t max_res_length,
+			       CHARSET_INFO *to_cs, size_t *result_length);
+
+#endif /* THR_MALLOC_INCLUDED */
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 8d9b4943404..ff4eabc2b0f 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -18,7 +18,7 @@
 #pragma implementation                         // gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "transaction.h"
 #include "rpl_handler.h"
 
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 7d88b7276f2..b23456b5465 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -20,7 +20,7 @@
 */
 
 /*
-  We should not include mysql_priv.h in mysql_tzinfo_to_sql utility since
+  We should not include sql_priv.h in mysql_tzinfo_to_sql utility since
   it creates unsolved link dependencies on some platforms.
 */
 
@@ -30,7 +30,12 @@
 
 #include 
 #if !defined(TZINFO2SQL) && !defined(TESTTIME)
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "tztime.h"
+#include "sql_time.h"                           // localtime_to_TIME
+#include "sql_base.h"                           // open_system_tables_for_read,
+                                                // close_system_tables
 #else
 #include 
 #include "tztime.h"
@@ -41,6 +46,15 @@
 #include 
 #include 
 #include 
+#include "lock.h"                               // MYSQL_LOCK_IGNORE_FLUSH,
+                                                // MYSQL_LOCK_IGNORE_TIMEOUT
+
+/*
+  This forward declaration is needed because including sql_base.h
+  causes further includes.  [TODO] Eliminate this forward declaration
+  and include a file with the prototype instead.
+*/
+extern void close_thread_tables(THD *thd);
 
 /*
   Now we don't use abbreviations in server but we will do this in future.
diff --git a/sql/tztime.h b/sql/tztime.h
index 9990e91f17b..f3fea485152 100644
--- a/sql/tztime.h
+++ b/sql/tztime.h
@@ -21,8 +21,17 @@
 #pragma interface			/* gcc class interface */
 #endif
 
+#include "my_time.h"                            /* my_time_t */
+#include "mysql_time.h"                         /* MYSQL_TIME */
+#include "sql_list.h"                           /* Sql_alloc */
+#include "sql_string.h"                         /* String */
+
+class THD;
+
 #if !defined(TESTTIME) && !defined(TZINFO2SQL)
 
+class THD;
+
 /**
   This class represents abstract time zone and provides 
   basic interface for MYSQL_TIME <-> my_time_t conversion.
diff --git a/sql/uniques.cc b/sql/uniques.cc
index f7c290ae61d..7b5a6d1ce4f 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -30,9 +30,12 @@
   deletes in disk order.
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "sql_sort.h"
-
+#include "queues.h"                             // QUEUE
+#include "my_tree.h"                            // element_count
+#include "sql_class.h"                          // Unique
 
 int unique_write_to_file(uchar* key, element_count count, Unique *unique)
 {
diff --git a/sql/unireg.cc b/sql/unireg.cc
index c7d2f2f5b5b..dbe4e8712ea 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -23,7 +23,11 @@
     str is a (long) to record position where 0 is the first position.
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_partition.h"                      // struct partition_info
+#include "sql_table.h"                          // check_duplicate_warning
+#include "sql_class.h"                  // THD, Internal_error_handler
 #include 
 #include 
 
diff --git a/sql/unireg.h b/sql/unireg.h
index 9932be7ae74..dbbeea077a9 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -17,8 +17,13 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 
+#include "my_global.h"                          /* ulonglong */
+#include "mysql_version.h"                      /* FRM_VER */
+
 /*  Extra functions used by unireg library */
 
+typedef struct st_ha_create_information HA_CREATE_INFO;
+
 #ifndef NO_ALARM_LOOP
 #define NO_ALARM_LOOP		/* lib5 and popen can't use alarm */
 #endif
@@ -52,71 +57,6 @@
 
 
 #define ERRMAPP 1				/* Errormap f|r my_error */
-#define LIBLEN FN_REFLEN-FN_LEN			/* Max l{ngd p} dev */
-/* extra 4+4 bytes for slave tmp tables */
-#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
-#define MAX_ALIAS_NAME 256
-#define MAX_FIELD_NAME 34			/* Max colum name length +2 */
-#define MAX_SYS_VAR_LENGTH 32
-#define MAX_KEY MAX_INDEXES                     /* Max used keys */
-#define MAX_REF_PARTS 16			/* Max parts used as ref */
-#define MAX_KEY_LENGTH 3072			/* max possible key */
-#if SIZEOF_OFF_T > 4
-#define MAX_REFLENGTH 8				/* Max length for record ref */
-#else
-#define MAX_REFLENGTH 4				/* Max length for record ref */
-#endif
-#define MAX_HOSTNAME  61			/* len+1 in mysql.user */
-
-#define MAX_MBWIDTH		3		/* Max multibyte sequence */
-#define MAX_FIELD_CHARLENGTH	255
-#define MAX_FIELD_VARCHARLENGTH	65535
-#define MAX_FIELD_BLOBLENGTH UINT_MAX32     /* cf field_blob::get_length() */
-#define CONVERT_IF_BIGGER_TO_BLOB 512		/* Used for CREATE ... SELECT */
-
-/* Max column width +1 */
-#define MAX_FIELD_WIDTH		(MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
-
-#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
-
-#define MAX_DATE_WIDTH		10	/* YYYY-MM-DD */
-#define MAX_TIME_WIDTH		23	/* -DDDDDD HH:MM:SS.###### */
-#define MAX_DATETIME_FULL_WIDTH 29	/* YYYY-MM-DD HH:MM:SS.###### AM */
-#define MAX_DATETIME_WIDTH	19	/* YYYY-MM-DD HH:MM:SS */
-#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
-
-#define MAX_TABLES	(sizeof(table_map)*8-3)	/* Max tables in join */
-#define PARAM_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-3))
-#define OUTER_REF_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-2))
-#define RAND_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-1))
-#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
-                           RAND_TABLE_BIT)
-#define MAX_FIELDS	4096			/* Limit in the .frm file */
-#define MAX_PARTITIONS  1024
-
-#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
-
-#define MAX_SORT_MEMORY 2048*1024
-#define MIN_SORT_MEMORY 32*1024
-
-/* Memory allocated when parsing a statement / saving a statement */
-#define MEM_ROOT_BLOCK_SIZE       8192
-#define MEM_ROOT_PREALLOC         8192
-#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
-#define TRANS_MEM_ROOT_PREALLOC   4096
-
-#define DEFAULT_ERROR_COUNT	64
-#define EXTRA_RECORDS	10			/* Extra records in sort */
-#define SCROLL_EXTRA	5			/* Extra scroll-rows. */
-#define FIELD_NAME_USED ((uint) 32768)		/* Bit set if fieldname used */
-#define FORM_NAME_USED	((uint) 16384)		/* Bit set if formname used */
-#define FIELD_NR_MASK	16383			/* To get fieldnumber */
-#define FERR		-1			/* Error from my_functions */
-#define CREATE_MODE	0			/* Default mode on new files */
-#define NAMES_SEP_CHAR	'\377'			/* Char to sep. names */
-
-#define READ_RECORD_BUFFER	(uint) (IO_SIZE*8) /* Pointer_buffer_size */
-#define DISK_BUFFER_SIZE	(uint) (IO_SIZE*16) /* Size of diskbuffer */
 
 #define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
 #define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
@@ -206,7 +146,6 @@
 #define TE_INFO_LENGTH 3
 #define MTYP_NOEMPTY_BIT 128
 
-#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
 /*
   Minimum length pattern before Turbo Boyer-Moore is used
   for SELECT "text" LIKE "%pattern%", excluding the two
@@ -228,5 +167,18 @@
 
 #include "mysqld_error.h"
 #include "structs.h"				/* All structs we need */
+#include "sql_list.h"                           /* List<> */
+#include "field.h"                              /* Create_field */
 
+bool mysql_create_frm(THD *thd, const char *file_name,
+                      const char *db, const char *table,
+		      HA_CREATE_INFO *create_info,
+		      List &create_field,
+		      uint key_count,KEY *key_info,handler *db_type);
+int rea_create_table(THD *thd, const char *path,
+                     const char *db, const char *table_name,
+                     HA_CREATE_INFO *create_info,
+  		     List &create_field,
+                     uint key_count,KEY *key_info,
+                     handler *file);
 #endif
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index f95a7252f2f..e63ec33465e 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -17,8 +17,9 @@
 #pragma implementation        // gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "probes_mysql.h"
+#include "sql_class.h"                          // SSV
 #include 
 
 #include "ha_archive.h"
diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc
index e10054a79f2..7ec60aad88a 100644
--- a/storage/blackhole/ha_blackhole.cc
+++ b/storage/blackhole/ha_blackhole.cc
@@ -19,9 +19,11 @@
 #endif
 
 #define MYSQL_SERVER 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "probes_mysql.h"
 #include "ha_blackhole.h"
+#include "sql_class.h"                          // THD, SYSTEM_THREAD_SLAVE_SQL
 
 /* Static declarations for handlerton */
 
diff --git a/storage/blackhole/ha_blackhole.h b/storage/blackhole/ha_blackhole.h
index 289e449be10..9de3c22c614 100644
--- a/storage/blackhole/ha_blackhole.h
+++ b/storage/blackhole/ha_blackhole.h
@@ -17,6 +17,10 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "thr_lock.h"                           /* THR_LOCK */
+#include "handler.h"                            /* handler */
+#include "table.h"                              /* TABLE_SHARE */
+
 /*
   Shared structure for correct LOCK operation
 */
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc
index cefb1577b16..6ab40e023d7 100644
--- a/storage/csv/ha_tina.cc
+++ b/storage/csv/ha_tina.cc
@@ -45,8 +45,10 @@ TODO:
 #pragma implementation        // gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_class.h"                          // SSV
 #include 
+#include 
 #include "ha_tina.h"
 #include "probes_mysql.h"
 
diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc
index 937f1fb292a..44ca2df026f 100644
--- a/storage/csv/transparent_file.cc
+++ b/storage/csv/transparent_file.cc
@@ -17,8 +17,10 @@
 #pragma implementation        // gcc: Class implementation
 #endif
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include 
 #include "transparent_file.h"
+#include "my_sys.h"          // MY_WME, MY_ALLOW_ZERO_PTR, MY_SEEK_SET
 
 Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE)
 { 
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index fb143f0b8d4..2fbb17e46bd 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -91,11 +91,11 @@
 #pragma implementation        // gcc: Class implementation
 #endif
 
-#define MYSQL_SERVER 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_class.h"           // MYSQL_HANDLERTON_INTERFACE_VERSION
 #include "ha_example.h"
 #include "probes_mysql.h"
-#include 
+#include "sql_plugin.h"
 
 static handler *example_create_handler(handlerton *hton,
                                        TABLE_SHARE *table, 
diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h
index 0c04249b6eb..12e088f5f05 100644
--- a/storage/example/ha_example.h
+++ b/storage/example/ha_example.h
@@ -35,6 +35,11 @@
 #pragma interface			/* gcc class implementation */
 #endif
 
+#include "my_global.h"                   /* ulonglong */
+#include "thr_lock.h"                    /* THR_LOCK, THR_LOCK_DATA */
+#include "handler.h"                     /* handler */
+#include "my_base.h"                     /* ha_rows */
+
 /** @brief
   EXAMPLE_SHARE is a structure that will be shared among all open handlers.
   This example implements the minimum of what you will probably need.
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 824290aa07c..5534c520604 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -372,7 +372,10 @@
 
 
 #define MYSQL_SERVER 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "sql_servers.h"         // FOREIGN_SERVER, get_server_by_name
+#include "sql_class.h"           // SSV
+#include "sql_analyse.h"         // append_escaped
 #include 
 
 #ifdef USE_PRAGMA_IMPLEMENTATION
@@ -383,6 +386,7 @@
 #include "probes_mysql.h"
 
 #include "m_string.h"
+#include "key.h"                                // key_copy
 
 #include 
 
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 4d01b9fd1c9..3abffc7087f 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -19,11 +19,12 @@
 #endif
 
 #define MYSQL_SERVER 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "probes_mysql.h"
-#include 
+#include "sql_plugin.h"
 #include "ha_heap.h"
 #include "heapdef.h"
+#include "sql_base.h"                    // enum_tdc_remove_table_type
 
 static handler *heap_create_handler(handlerton *hton,
                                     TABLE_SHARE *table, 
diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h
index 22722129f4c..7185fbc7720 100644
--- a/storage/heap/ha_heap.h
+++ b/storage/heap/ha_heap.h
@@ -21,6 +21,7 @@
 /* class for the the heap handler */
 
 #include 
+#include "sql_class.h"                          /* THD */
 
 class ha_heap: public handler
 {
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 77c223a67ab..3debf2805b6 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -61,11 +61,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #pragma implementation				// gcc: Class implementation
 #endif
 
-#include 
+#include  // explain_filename, nz2, EXPLAIN_PARTITIONS_AS_COMMENT,
+                       // EXPLAIN_FILENAME_MAX_EXTRA_LENGTH
 
+#include                             // PROCESS_ACL
 #include 
 #include 
 #include 
+#include 
 
 /** @file ha_innodb.cc */
 
@@ -106,7 +109,6 @@ extern "C" {
 #include "ha_innodb.h"
 #include "i_s.h"
 
-#ifndef MYSQL_SERVER
 # ifndef MYSQL_PLUGIN_IMPORT
 #  define MYSQL_PLUGIN_IMPORT /* nothing */
 # endif /* MYSQL_PLUGIN_IMPORT */
@@ -116,7 +118,6 @@ extern "C" {
 but we need it here */
 bool check_global_access(THD *thd, ulong want_access);
 #endif /* MYSQL_VERSION_ID < 50124 */
-#endif /* MYSQL_SERVER */
 
 /** to protect innobase_open_files */
 static pthread_mutex_t innobase_share_mutex;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index a5008991400..99c1d37b04c 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -21,8 +21,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA
 Smart ALTER TABLE
 *******************************************************/
 
-#include 
+#include 
 #include 
+#include                             // SQLCOM_CREATE_INDEX
+#include 
 
 extern "C" {
 #include "log0log.h"
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 524fe696de2..7d8b4a8dd40 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -23,8 +23,8 @@ InnoDB INFORMATION SCHEMA tables interface to MySQL.
 Created July 18, 2007 Vasil Dimov
 *******************************************************/
 
-#include 
 #include 
+#include                             // PROCESS_ACL
 
 #include 
 #include 
@@ -32,7 +32,8 @@ Created July 18, 2007 Vasil Dimov
 #include 
 #include 
 #include "i_s.h"
-#include 
+#include 
+#include 
 
 extern "C" {
 #include "trx0i_s.h"
diff --git a/storage/innobase/handler/mysql_addons.cc b/storage/innobase/handler/mysql_addons.cc
index eae1fe9fbc2..ae6306e5db9 100644
--- a/storage/innobase/handler/mysql_addons.cc
+++ b/storage/innobase/handler/mysql_addons.cc
@@ -36,7 +36,7 @@ Created November 07, 2007 Vasil Dimov
 #define MYSQL_SERVER
 #endif /* MYSQL_SERVER */
 
-#include 
+#include 
 
 #include "mysql_addons.h"
 #include "univ.i"
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 933347006fc..a831335cbb9 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -19,9 +19,10 @@
 #endif
 
 #define MYSQL_SERVER 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "probes_mysql.h"
-#include 
+#include "key.h"                                // key_copy
+#include "sql_plugin.h"
 #include 
 #include 
 #include 
@@ -29,6 +30,8 @@
 #include 
 #include "myisamdef.h"
 #include "rt_index.h"
+#include "sql_table.h"                          // tablename_to_filename
+#include "sql_class.h"                          // THD
 
 ulonglong myisam_recover_options;
 static ulong opt_myisam_block_size;
diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h
index 2f41670b934..f08150215a6 100644
--- a/storage/myisam/ha_myisam.h
+++ b/storage/myisam/ha_myisam.h
@@ -22,6 +22,11 @@
 
 #include 
 #include 
+#include "handler.h"                            /* handler */
+#include "table.h"                              /* TABLE_SHARE */
+
+struct TABLE_SHARE;
+typedef struct st_ha_create_information HA_CREATE_INFO;
 
 #define HA_RECOVER_DEFAULT	1	/* Automatic recover active */
 #define HA_RECOVER_BACKUP	2	/* Make a backupfile on recover */
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index a153530ae80..6b7e60b126c 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -90,14 +90,19 @@
 #endif
 
 #define MYSQL_SERVER 1
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
+#include "sql_cache.h"                          // query_cache_*
+#include "sql_show.h"                           // append_identifier
+#include "sql_table.h"                         // build_table_filename
 #include "probes_mysql.h"
 #include 
 #include 
 #include "../myisam/ha_myisam.h"
 #include "ha_myisammrg.h"
 #include "myrg_def.h"
-
+#include "thr_malloc.h"                         // int_sql_alloc
+#include "sql_class.h"                          // THD
 
 static handler *myisammrg_create_handler(handlerton *hton,
                                          TABLE_SHARE *table,
diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc
index 68e1f3f3a11..588ba5edec1 100644
--- a/storage/perfschema/ha_perfschema.cc
+++ b/storage/perfschema/ha_perfschema.cc
@@ -18,7 +18,8 @@
   Performance schema storage engine (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "ha_perfschema.h"
 #include "mysql/plugin.h"
 #include "pfs_engine_table.h"
diff --git a/storage/perfschema/ha_perfschema.h b/storage/perfschema/ha_perfschema.h
index 146b258ff47..92cc0476e73 100644
--- a/storage/perfschema/ha_perfschema.h
+++ b/storage/perfschema/ha_perfschema.h
@@ -16,6 +16,8 @@
 #ifndef HA_PERFSCHEMA_H
 #define HA_PERFSCHEMA_H
 
+#include "handler.h"                            /* class handler */
+
 #ifdef USE_PRAGMA_INTERFACE
 #pragma interface /* gcc class implementation */
 #endif
diff --git a/storage/perfschema/pfs.h b/storage/perfschema/pfs.h
index 7af59ffce57..13d43cfce76 100644
--- a/storage/perfschema/pfs.h
+++ b/storage/perfschema/pfs.h
@@ -23,7 +23,8 @@
 
 #define HAVE_PSI_1
 
-#include 
+#include 
+#include 
 #include 
 
 extern struct PSI_bootstrap PFS_bootstrap;
diff --git a/storage/perfschema/pfs_check.cc b/storage/perfschema/pfs_check.cc
index 5d3746d371c..4ef4b8bdbc6 100644
--- a/storage/perfschema/pfs_check.cc
+++ b/storage/perfschema/pfs_check.cc
@@ -23,7 +23,7 @@
 */
 
 #include "my_global.h"
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "pfs_server.h"
 #include "pfs_engine_table.h"
 
diff --git a/storage/perfschema/pfs_column_values.cc b/storage/perfschema/pfs_column_values.cc
index 3143cd97e5d..6da1e04e63a 100644
--- a/storage/perfschema/pfs_column_values.cc
+++ b/storage/perfschema/pfs_column_values.cc
@@ -19,7 +19,7 @@
   schema tables (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "pfs_column_values.h"
 
 LEX_STRING PERFORMANCE_SCHEMA_str=
diff --git a/storage/perfschema/pfs_column_values.h b/storage/perfschema/pfs_column_values.h
index 6cd2e8687d1..0172ddd1d18 100644
--- a/storage/perfschema/pfs_column_values.h
+++ b/storage/perfschema/pfs_column_values.h
@@ -16,6 +16,8 @@
 #ifndef PFS_COLUMN_VALUES_H
 #define PFS_COLUMN_VALUES_H
 
+#include "m_string.h"                           /* LEX_STRING */
+
 /**
   @file storage/perfschema/pfs_column_values.h
   Literal values for columns used in the
diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc
index d0f5315ff36..857b8a66de7 100644
--- a/storage/perfschema/pfs_engine_table.cc
+++ b/storage/perfschema/pfs_engine_table.cc
@@ -18,7 +18,7 @@
   Performance schema tables (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "pfs_engine_table.h"
 
 #include "table_events_waits.h"
@@ -37,6 +37,9 @@
 #include "pfs_column_values.h"
 #include "pfs_instr.h"
 
+#include "sql_base.h"                           // close_thread_tables
+#include "lock.h"                               // MYSQL_LOCK_IGNORE_TIMEOUT
+
 /**
   @addtogroup Performance_schema_engine
   @{
diff --git a/storage/perfschema/pfs_engine_table.h b/storage/perfschema/pfs_engine_table.h
index 6a826c9da7d..b4c7a4ee866 100644
--- a/storage/perfschema/pfs_engine_table.h
+++ b/storage/perfschema/pfs_engine_table.h
@@ -16,6 +16,7 @@
 #ifndef PFS_ENGINE_TABLE_H
 #define PFS_ENGINE_TABLE_H
 
+#include "sql_acl.h"                            /* struct ACL_* */
 /**
   @file storage/perfschema/pfs_engine_table.h
   Performance schema tables (declarations).
diff --git a/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc
index fbaac621dfb..fb40db02ca3 100644
--- a/storage/perfschema/pfs_instr.cc
+++ b/storage/perfschema/pfs_instr.cc
@@ -18,8 +18,10 @@
   Performance schema instruments (implementation).
 */
 
+#include 
+
 #include "my_global.h"
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "my_sys.h"
 #include "pfs_stat.h"
 #include "pfs_instr.h"
diff --git a/storage/perfschema/pfs_instr.h b/storage/perfschema/pfs_instr.h
index a150a13fb75..a509d054d69 100644
--- a/storage/perfschema/pfs_instr.h
+++ b/storage/perfschema/pfs_instr.h
@@ -21,7 +21,7 @@
   Performance schema instruments (declarations).
 */
 
-#include 
+#include 
 #include "pfs_lock.h"
 #include "pfs_instr_class.h"
 #include "pfs_events_waits.h"
diff --git a/storage/perfschema/pfs_instr_class.h b/storage/perfschema/pfs_instr_class.h
index 0a58095d612..4de9958033b 100644
--- a/storage/perfschema/pfs_instr_class.h
+++ b/storage/perfschema/pfs_instr_class.h
@@ -16,6 +16,8 @@
 #ifndef PFS_INSTR_CLASS_H
 #define PFS_INSTR_CLASS_H
 
+#include "mysql_com.h"                          /* NAME_LEN */
+
 /**
   @file storage/perfschema/pfs_instr_class.h
   Performance schema instruments meta data (declarations).
@@ -36,7 +38,7 @@
 */
 #define PFS_MAX_FULL_PREFIX_NAME_LENGTH 32
 
-#include 
+#include 
 #include 
 #include "pfs_lock.h"
 #include "pfs_stat.h"
diff --git a/storage/perfschema/pfs_server.cc b/storage/perfschema/pfs_server.cc
index 66b8a7fb22b..a1216c6ac30 100644
--- a/storage/perfschema/pfs_server.cc
+++ b/storage/perfschema/pfs_server.cc
@@ -21,7 +21,7 @@
 #include "my_global.h"
 #include "my_sys.h"
 #include "mysys_err.h"
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "pfs_server.h"
 #include "pfs.h"
 #include "pfs_global.h"
diff --git a/storage/perfschema/table_all_instr.cc b/storage/perfschema/table_all_instr.cc
index e6cd7897f6f..18c0fcfafc6 100644
--- a/storage/perfschema/table_all_instr.cc
+++ b/storage/perfschema/table_all_instr.cc
@@ -18,7 +18,8 @@
   Abstract tables for all instruments (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "my_global.h"
 #include "table_all_instr.h"
 #include "pfs_global.h"
 
diff --git a/storage/perfschema/table_events_waits.cc b/storage/perfschema/table_events_waits.cc
index 3a12578597e..cb565373bd8 100644
--- a/storage/perfschema/table_events_waits.cc
+++ b/storage/perfschema/table_events_waits.cc
@@ -18,7 +18,7 @@
   Table EVENTS_WAITS_xxx (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "table_events_waits.h"
 #include "pfs_instr_class.h"
 #include "pfs_instr.h"
diff --git a/storage/perfschema/table_events_waits_summary.cc b/storage/perfschema/table_events_waits_summary.cc
index c3d678d374c..0eca9f6722e 100644
--- a/storage/perfschema/table_events_waits_summary.cc
+++ b/storage/perfschema/table_events_waits_summary.cc
@@ -18,7 +18,8 @@
   Table EVENTS_WAITS_SUMMARY_BY_xxx (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "pfs_instr_class.h"
 #include "pfs_column_types.h"
 #include "pfs_column_values.h"
diff --git a/storage/perfschema/table_file_instances.cc b/storage/perfschema/table_file_instances.cc
index b6bc7ecbcf3..3de5cbe4b47 100644
--- a/storage/perfschema/table_file_instances.cc
+++ b/storage/perfschema/table_file_instances.cc
@@ -18,7 +18,8 @@
   Table FILE_INSTANCES (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "pfs_instr.h"
 #include "pfs_column_types.h"
 #include "pfs_column_values.h"
diff --git a/storage/perfschema/table_file_summary.cc b/storage/perfschema/table_file_summary.cc
index 0db4e08625a..16942e73916 100644
--- a/storage/perfschema/table_file_summary.cc
+++ b/storage/perfschema/table_file_summary.cc
@@ -18,7 +18,8 @@
   Table FILE_SUMMARY_BY_xxx (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "pfs_instr_class.h"
 #include "pfs_column_types.h"
 #include "pfs_column_values.h"
diff --git a/storage/perfschema/table_performance_timers.cc b/storage/perfschema/table_performance_timers.cc
index ab4e72b89fa..7a20e7e18e0 100644
--- a/storage/perfschema/table_performance_timers.cc
+++ b/storage/perfschema/table_performance_timers.cc
@@ -18,7 +18,8 @@
   Table PERFORMANCE_TIMERS (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "my_global.h"
 #include "table_performance_timers.h"
 #include "pfs_timer.h"
 #include "pfs_global.h"
diff --git a/storage/perfschema/table_processlist.cc b/storage/perfschema/table_processlist.cc
index d0707b9df60..7518882ccea 100644
--- a/storage/perfschema/table_processlist.cc
+++ b/storage/perfschema/table_processlist.cc
@@ -18,7 +18,7 @@
   Table PROCESSLIST (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "table_processlist.h"
 #include "pfs_instr_class.h"
 #include "pfs_instr.h"
diff --git a/storage/perfschema/table_setup_consumers.cc b/storage/perfschema/table_setup_consumers.cc
index f23dca8a675..ff74e7d3f28 100644
--- a/storage/perfschema/table_setup_consumers.cc
+++ b/storage/perfschema/table_setup_consumers.cc
@@ -18,7 +18,7 @@
   Table SETUP_CONSUMERS (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "table_setup_consumers.h"
 #include "pfs_instr.h"
 #include "pfs_events_waits.h"
diff --git a/storage/perfschema/table_setup_instruments.cc b/storage/perfschema/table_setup_instruments.cc
index 6756e780d78..095299c4b69 100644
--- a/storage/perfschema/table_setup_instruments.cc
+++ b/storage/perfschema/table_setup_instruments.cc
@@ -18,7 +18,8 @@
   Table SETUP_INSTRUMENTS (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "pfs_instr_class.h"
 #include "pfs_column_types.h"
 #include "pfs_column_values.h"
diff --git a/storage/perfschema/table_setup_objects.cc b/storage/perfschema/table_setup_objects.cc
index 53a80782da0..b75bece83bd 100644
--- a/storage/perfschema/table_setup_objects.cc
+++ b/storage/perfschema/table_setup_objects.cc
@@ -18,7 +18,8 @@
   Table SETUP_OBJECTS (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "pfs_instr_class.h"
 #include "pfs_column_types.h"
 #include "pfs_column_values.h"
diff --git a/storage/perfschema/table_setup_timers.cc b/storage/perfschema/table_setup_timers.cc
index 2d57adb3a85..98e27808e0a 100644
--- a/storage/perfschema/table_setup_timers.cc
+++ b/storage/perfschema/table_setup_timers.cc
@@ -18,7 +18,7 @@
   Table SETUP_TIMERS (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
 #include "table_setup_timers.h"
 #include "pfs_column_values.h"
 #include "pfs_timer.h"
diff --git a/storage/perfschema/table_sync_instances.cc b/storage/perfschema/table_sync_instances.cc
index a783b5b817b..c76c62cc9fd 100644
--- a/storage/perfschema/table_sync_instances.cc
+++ b/storage/perfschema/table_sync_instances.cc
@@ -19,7 +19,8 @@
   and COND_INSTANCES (implementation).
 */
 
-#include "mysql_priv.h"
+#include "sql_priv.h"
+#include "unireg.h"
 #include "pfs_instr.h"
 #include "pfs_column_types.h"
 #include "pfs_column_values.h"
diff --git a/storage/perfschema/unittest/pfs-t.cc b/storage/perfschema/unittest/pfs-t.cc
index 2b64aec3416..012c6e7d87a 100644
--- a/storage/perfschema/unittest/pfs-t.cc
+++ b/storage/perfschema/unittest/pfs-t.cc
@@ -13,13 +13,17 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #include "stub_print_error.h"
 
 /* test helpers, to simulate the setup */
diff --git a/storage/perfschema/unittest/pfs_instr-oom-t.cc b/storage/perfschema/unittest/pfs_instr-oom-t.cc
index d7810eedb04..4ea2e038b24 100644
--- a/storage/perfschema/unittest/pfs_instr-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_instr-oom-t.cc
@@ -13,7 +13,8 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/storage/perfschema/unittest/pfs_instr-t.cc b/storage/perfschema/unittest/pfs_instr-t.cc
index f85de601579..4e73276b467 100644
--- a/storage/perfschema/unittest/pfs_instr-t.cc
+++ b/storage/perfschema/unittest/pfs_instr-t.cc
@@ -13,12 +13,15 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+
 void test_no_instruments()
 {
   int rc;
diff --git a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
index 53100571323..9cab0d18b33 100644
--- a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
@@ -13,7 +13,8 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/storage/perfschema/unittest/pfs_instr_class-t.cc b/storage/perfschema/unittest/pfs_instr_class-t.cc
index 0a1e0c2d0b1..5d7e0bf734f 100644
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc
@@ -13,7 +13,9 @@
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#include 
+#include 
+#include 
+#include                              // strncpy
 #include 
 #include 
 #include 
diff --git a/storage/perfschema/unittest/pfs_timer-t.cc b/storage/perfschema/unittest/pfs_timer-t.cc
index 8fa29306982..a649257e0c5 100644
--- a/storage/perfschema/unittest/pfs_timer-t.cc
+++ b/storage/perfschema/unittest/pfs_timer-t.cc
@@ -14,7 +14,9 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include 
+#include 
 #include 
+#include "my_sys.h"
 #include 
 
 void test_timers()