From 2cd53fefa16a06959d04e02158b67b93dd2292c0 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Wed, 15 Aug 2001 13:10:34 -0500
Subject: [PATCH 01/51] DocTOC Appendixes Complete!

---
 Docs/manual.texi | 1655 +++++++++++++++++++++++++++-------------------
 1 file changed, 983 insertions(+), 672 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index b594e296805..596126a43aa 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -118,13 +118,13 @@ distribution for that version.
 * Clients::                     MySQL client tools and APIs
 * Extending MySQL::             
 * Problems::                    Problems
-* Environment variables::       MySQL environment variables
 * Users::                       Some MySQL users
 * MySQL customer usage::        
 * Contrib::                     Contributed programs
 * Credits::                     Contributors to MySQL
 * News::                        MySQL change history
 * Porting::                     Comments on porting to other systems
+* Environment variables::       MySQL environment variables
 * Regexp::                      Description of MySQL regular expression syntax
 * Unireg::                      What is Unireg?
 * GPL license::                 GNU General Public License
@@ -36498,7 +36498,7 @@ transaction.
 * InnoDB Next-key locking::     
 * InnoDB Locks set::            
 * InnoDB Deadlock detection::   
-* InnoDB Consistent read example::
+* InnoDB Consistent read example::  
 @end menu
 
 
@@ -36694,7 +36694,7 @@ locks. But that does not put transaction integerity into danger.
 @end itemize
 
 
-@node InnoDB Deadlock detection, InnoDB Consistent read example , InnoDB Locks set, InnoDB transaction model
+@node InnoDB Deadlock detection, InnoDB Consistent read example, InnoDB Locks set, InnoDB transaction model
 @subsubsection Deadlock detection and rollback
 
 InnoDB automatically detects a deadlock of transactions and rolls
@@ -42766,7 +42766,7 @@ do that.  Just specify the @code{--with-debug} options to @code{configure}!
 
 
 
-@node Problems, Environment variables, Extending MySQL, Top
+@node Problems, Users, Extending MySQL, Top
 @appendix Problems and Common Errors
 
 @cindex problems, common errors
@@ -42774,26 +42774,11 @@ do that.  Just specify the @code{--with-debug} options to @code{configure}!
 
 @menu
 * What is crashing::            How to determine what is causing problems
-* Crashing::                    What to do if MySQL keeps crashing
-* Link errors::                 Problems when linking with the MySQL client library
 * Common errors::               Some common errors when using MySQL
-* Full disk::                   How MySQL handles a full disk
-* Temporary files::             Where MySQL stores temporary files
-* Problems with mysql.sock::    How to protect @file{/tmp/mysql.sock}
-* Changing MySQL user::         How to run MySQL as a normal user
-* Resetting permissions::       How to reset a forgotten password.
-* File permissions ::           Problems with file permissions
-* Not enough file handles::     File not found
-* Using DATE::                  Problems using @code{DATE} columns
-* Timezone problems::           Timezone problems
-* Case sensitivity::            Case sensitivity in searches
-* Problems with NULL::          Problems with @code{NULL} values
-* Problems with alias::         Problems with @code{alias}
-* Deleting from related tables::  Deleting rows from related tables
-* No matching rows::            Solving problems with no matching rows
-* ALTER TABLE problems::        Problems with @code{ALTER TABLE}.
-* Change column order::         How to change the order of columns in a table
-* Temporary table problems::    
+* Installation Issues::         
+* Administration Issues::       
+* Query Issues::                
+* Table Definition Issues::     
 @end menu
 
 This chapter lists some common problems and error messages that users have
@@ -42802,7 +42787,7 @@ to do to solve it.  You will also find proper solutions to some common
 problems.
 
 
-@node What is crashing, Crashing, Problems, Problems
+@node What is crashing, Common errors, Problems, Problems
 @appendixsec How to Determine What Is Causing Problems
 
 When you run into problems, the first thing you should do is to find out
@@ -42900,260 +42885,7 @@ When sending a bug report, you should of follow the outlines
 described in this manual. @xref{Asking questions}.
 
 
-@node Crashing, Link errors, What is crashing, Problems
-@appendixsec What to Do if MySQL Keeps Crashing
-
-@cindex crash, repeated
-
-All MySQL versions are tested on many platforms before they are
-released.  This doesn't mean that there aren't any bugs in
-MySQL, but it means if there are bugs, they are very few and can be
-hard to find.  If you have a problem, it will always help if you try to
-find out exactly what crashes your system, as you will have a much better
-chance of getting this fixed quickly.
-
-First, you should try to find out whether the problem is that the
-@code{mysqld} daemon dies or whether your problem has to do with your
-client.  You can check how long your @code{mysqld} server has been up by
-executing @code{mysqladmin version}.  If @code{mysqld} has died, you may
-find the reason for this in the file
-@file{mysql-data-directory/`hostname`.err}. @xref{Error log}.
-
-Many crashes of MySQL are caused by corrupted index / data
-files.  MySQL will update the data on disk, with the
-@code{write()} system call, after every SQL statement and before the
-client is notified about the result. (This is not true if you are running
-with @code{delayed_key_writes}, in which case only the data is written.)
-This means that the data is safe even if @code{mysqld} crashes, as the OS will
-ensure that the not flushed data is written to disk.  You can force
-MySQL to sync everything to disk after every SQL command by
-starting @code{mysqld} with @code{--flush}.
-
-The above means that normally you shouldn't get corrupted tables unless:
-
-@itemize @bullet
-@item
-Someone/something killed @code{mysqld} or the machine in the middle
-of an update.
-@item
-You have found a bug in @code{mysqld} that caused it to die in the
-middle of an update.
-@item
-Someone is manipulating the data/index files outside of @strong{mysqld}
-without locking the table properly.
-@item
-If you are running many @code{mysqld} servers on the same data on a
-system that doesn't support good file system locks (normally handled by
-the @code{lockd} daemon ) or if you are running
-multiple servers with @code{--skip-locking}
-@item
-You have a crashed index/data file that contains very wrong data that
-got @code{mysqld} confused.
-@item
-You have found a bug in the data storage code. This isn't that likely,
-but it's at least possible.  In this case you can try to change the file
-type to another database handler by using @code{ALTER TABLE} on a
-repaired copy of the table!
-@end itemize
-
-Because it is very difficult to know why something is crashing, first try to
-check whether or not things that work for others crash for you.  Please try
-the following things:
-
-@itemize @bullet
-@item
-Take down the @code{mysqld} daemon with @code{mysqladmin shutdown}, run
-@code{myisamchk --silent --force */*.MYI} on all tables, and restart the
-@code{mysqld} daemon.  This will ensure that you are running from a clean
-state.  @xref{MySQL Database Administration}.
-
-@item
-Use @code{mysqld --log} and try to determine from the information in the log
-whether or not some specific query kills the server. About 95% of all bugs are
-related to a particular query!  Normally this is one of the last queries in
-the log file just before MySQL restarted. @xref{Query log}.
-If you can repeatadly kill MySQL with one of the queries, even
-when you have checked all tables just before doing the query, then you
-have been able to locate the bug and should do a bug report for this!
-@xref{Bug reports}.
-
-@item
-Try to make a test case that we can use to reproduce the problem.
-@xref{Reproduceable test case}.
-
-@item
-Try running the included mysql-test test and the MySQL
-benchmarks.  @xref{MySQL test suite}.  They should test MySQL
-rather well.  You can also add code that to the benchmarks to simulates
-your application!  The benchmarks can be found in the @file{bench}
-directory in the source distribution or, for a binary distribution, in
-the @file{sql-bench} directory under your MySQL installation
-directory.
-
-@item
-Try @code{fork_test.pl} and @code{fork2_test.pl}.
-
-@item
-If you configure MySQL for debugging, it will be much easier to
-gather information about possible errors if something goes wrong.
-Reconfigure MySQL with the @code{--with-debug} option or
-@code{--with-debug=full} to @code{configure} and then recompile.
-@xref{Debugging server}.
-
-@item
-Configuring MySQL for debugging causes a safe memory allocator to be
-included that can find some errors. It also provides a lot of output about
-what is happening.
-
-@item
-Have you applied the latest patches for your operating system?
-
-@item
-Use the @code{--skip-locking} option to @code{mysqld}.  On some systems, the
-@code{lockd} lock manager does not work properly; the @code{--skip-locking}
-option tells @code{mysqld} not to use external locking.  (This means that you
-cannot run 2 @code{mysqld} servers on the same data and that you must be
-careful if you use @code{myisamchk}, but it may be instructive to try the
-option as a test.)
-
-@item
-Have you tried @code{mysqladmin -u root processlist} when @code{mysqld}
-appears to be running but not responding?  Sometimes @code{mysqld} is not
-comatose even though you might think so.  The problem may be that all
-connections are in use, or there may be some internal lock problem.
-@code{mysqladmin processlist} will usually be able to make a connection even
-in these cases, and can provide useful information about the current number
-of connections and their status.
-
-@item
-Run the command @code{mysqladmin -i 5 status} or @code{mysqladmin -i 5
--r status} or in a separate window to produce statistics while you run
-your other queries.
-
-@item
-Try the following:
-@enumerate
-@item
-Start @code{mysqld} from @code{gdb} (or in another debugger).
-@xref{Using gdb on mysqld}.
-
-@item
-Run your test scripts.
-
-@item
-Print the backtrace and the local variables at the 3 lowest levels. In gdb you
-can do this with the following commands when @code{mysqld} has crashed inside
-gdb:
-
-@example
-backtrace
-info local
-up
-info local
-up
-info local
-@end example
-
-With gdb you can also examine which threads exist with @code{info
-threads} and switch to a specific thread with @code{thread #}, where
-@code{#} is the thread id.
-@end enumerate
-
-@item
-Try to simulate your application with a Perl script to force
-MySQL to crash or misbehave.
-
-@item
-Send a normal bug report. @xref{Bug reports}. Be even more detailed
-than usual.  Because MySQL works for many people, it may be that the
-crash results from something that exists only on your computer (for example,
-an error that is related to your particular system libraries).
-@item
-If you have a problem with tables with dynamic-length rows and you are
-not using @code{BLOB/TEXT} columns (but only @code{VARCHAR} columns), you
-can try to change all @code{VARCHAR} to @code{CHAR} with @code{ALTER
-TABLE}.  This will force MySQL to use fixed-size rows.
-Fixed-size rows take a little extra space, but are much more tolerant to
-corruption!
-
-The current dynamic row code has been in use at MySQL AB for at
-least 3 years without any problems, but by nature dynamic-length rows are
-more prone to errors, so it may be a good idea to try the above to see if
-it helps!
-@end itemize
-
-
-@node Link errors, Common errors, Crashing, Problems
-@appendixsec Problems When Linking with the MySQL Client Library
-
-@cindex linking, errors
-@cindex errors, linking
-@cindex problems, linking
-
-If you are linking your program and you get errors for unreferenced
-symbols that start with @code{mysql_}, like the following:
-
-@example
-/tmp/ccFKsdPa.o: In function `main':
-/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
-/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
-/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
-/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
-/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
-@end example
-
-you should be able to solve this by adding @code{-Lpath-to-the-mysql-library
--lmysqlclient} @strong{LAST} on your link line.
-
-If you get @code{undefined reference} errors for the @code{uncompress}
-or @code{compress} function, add @code{-lz} @strong{LAST} on your link
-line and try again!
-
-If you get @code{undefined reference} errors for functions that should
-exist on your system, like @code{connect}, check the man page for the
-function in question, for which libraries you should add to the link
-line!
-
-If you get @code{undefined reference} errors for functions that don't
-exist on your system, like the following:
-
-@example
-mf_format.o(.text+0x201): undefined reference to `__lxstat'
-@end example
-
-it usually means that your library is compiled on a system that is not
-100 % compatible with yours.  In this case you should download the
-latest MySQL source distribution and compile this yourself.
-@xref{Installing source}.
-
-If you are trying to run a program and you then get errors for
-unreferenced symbols that start with @code{mysql_} or that the
-@code{mysqlclient} library can't be found, this means that your system
-can't find the share @code{libmysqlclient.so} library.
-
-The fix for this is to tell your system to search after shared
-libraries where the library is located by one of the following methods:
-
-@itemize @bullet
-@item
-Add the path to the directory where you have @code{libmysqlclient.so} the
-@code{LD_LIBRARY_PATH} environment variable.
-@item
-Add the path to the directory where you have @code{libmysqlclient.so} the
-@code{LD_LIBRARY} environment variable.
-@item
-Copy @code{libmysqlclient.so} to some place that is searched by your system,
-like @file{/lib}, and update the shared library information by executing
-@code{ldconfig}.
-@end itemize
-
-Another way to solve this problem is to link your program statically, with
-@code{-static}, or by removing the dynamic MySQL libraries
-before linking your code. In the second case you should be
-sure that no other programs are using the dynamic libraries!
-
-
-@node Common errors, Full disk, Link errors, Problems
+@node Common errors, Installation Issues, What is crashing, Problems
 @appendixsec Some Common Errors When Using MySQL
 
 @cindex errors, list of
@@ -43174,6 +42906,7 @@ sure that no other programs are using the dynamic libraries!
 * Ignoring user::               @code{Ignoring user} error
 * Cannot find table::           @code{Table 'xxx' doesn't exist} error
 * Cannot initialize character set::  
+* Not enough file handles::     
 @end menu
 
 
@@ -43412,6 +43145,7 @@ the thread library is on a given platform. Linux or Solaris should be
 able to support 500-1000 simultaneous connections, depending on how much
 RAM you have and what your clients are doing.
 
+
 @node Non-transactional tables, Out of memory, Too many connections, Common errors
 @appendixsubsec @code{Some non-transactional changed tables couldn't be rolled back} Error
 
@@ -43678,7 +43412,7 @@ You can check which tables you have in the current database with
 @code{SHOW TABLES}. @xref{SHOW, , @code{SHOW}}.
 
 
-@node Cannot initialize character set,  , Cannot find table, Common errors
+@node Cannot initialize character set, Not enough file handles, Cannot find table, Common errors
 @appendixsubsec @code{Can@'t initialize character set xxx} error.
 
 @cindex multibyte character sets
@@ -43726,8 +43460,500 @@ to be.
 @end itemize
 
 
-@node Full disk, Temporary files, Common errors, Problems
-@appendixsec How MySQL Handles a Full Disk
+@node Not enough file handles,  , Cannot initialize character set, Common errors
+@appendixsubsec File Not Found
+
+If you get @code{ERROR '...' not found (errno: 23)}, @code{Can't open
+file: ... (errno: 24)}, or any other error with @code{errno 23} or
+@code{errno 24} from MySQL, it means that you haven't allocated
+enough file descriptors for MySQL.  You can use the
+@code{perror} utility to get a description of what the error number
+means:
+
+@example
+shell> perror 23
+File table overflow
+shell> perror 24
+Too many open files
+shell> perror 11
+Resource temporarily unavailable
+@end example
+
+The problem here is that @code{mysqld} is trying to keep open too many
+files simultaneously.  You can either tell @code{mysqld} not to open so
+many files at once or increase the number of file descriptors
+available to @code{mysqld}.
+
+To tell @code{mysqld} to keep open fewer files at a time, you can make
+the table cache smaller by using the @code{-O table_cache=32} option to
+@code{safe_mysqld} (the default value is 64). Reducing the value of
+@code{max_connections} will also reduce the number of open files (the
+default value is 90).
+
+@tindex ulimit
+To change the number of file descriptors available to @code{mysqld}, you
+can use the option @code{--open-files-limit=#} to @code{safe_mysqld} or
+@code{-O open-files-limit=#} to @code{mysqld}. @xref{SHOW VARIABLES}.
+The easiest way to do that is to add the option to your option file.
+@xref{Option files}.  If you have an old @code{mysqld} version that
+doesn't support this, you can edit the @code{safe_mysqld} script.  There
+is a commented-out line @code{ulimit -n 256} in the script.  You can
+remove the @code{'#'} character to uncomment this line, and change the
+number 256 to affect the number of file descriptors available to
+@code{mysqld}.
+
+@code{ulimit} (and @code{open-files-limit}) can increase the number of
+file descriptors, but only up to the limit imposed by the operating
+system. There is also a 'hard' limit that can only be overrided if you
+start @code{safe_mysqld} or @code{mysqld} as root (Just remember that
+you need to also use the @code{--user=..} option in this case).  If you
+need to increase the OS limit on the number of file descriptors
+available to each process, consult the documentation for your operating
+system.
+
+Note that if you run the @code{tcsh} shell, @code{ulimit} will not work!
+@code{tcsh} will also report incorrect values when you ask for the current
+limits!  In this case you should start @code{safe_mysqld} with @code{sh}!
+
+
+@node Installation Issues, Administration Issues, Common errors, Problems
+@appendixsec Installation Related Issues
+
+
+@menu
+* Link errors::                 
+* Changing MySQL user::         
+* File permissions ::           
+@end menu
+
+@node Link errors, Changing MySQL user, Installation Issues, Installation Issues
+@appendixsubsec Problems When Linking with the MySQL Client Library
+
+@cindex linking, errors
+@cindex errors, linking
+@cindex problems, linking
+
+If you are linking your program and you get errors for unreferenced
+symbols that start with @code{mysql_}, like the following:
+
+@example
+/tmp/ccFKsdPa.o: In function `main':
+/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
+/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
+/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
+/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
+/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
+@end example
+
+you should be able to solve this by adding @code{-Lpath-to-the-mysql-library
+-lmysqlclient} @strong{LAST} on your link line.
+
+If you get @code{undefined reference} errors for the @code{uncompress}
+or @code{compress} function, add @code{-lz} @strong{LAST} on your link
+line and try again!
+
+If you get @code{undefined reference} errors for functions that should
+exist on your system, like @code{connect}, check the man page for the
+function in question, for which libraries you should add to the link
+line!
+
+If you get @code{undefined reference} errors for functions that don't
+exist on your system, like the following:
+
+@example
+mf_format.o(.text+0x201): undefined reference to `__lxstat'
+@end example
+
+it usually means that your library is compiled on a system that is not
+100 % compatible with yours.  In this case you should download the
+latest MySQL source distribution and compile this yourself.
+@xref{Installing source}.
+
+If you are trying to run a program and you then get errors for
+unreferenced symbols that start with @code{mysql_} or that the
+@code{mysqlclient} library can't be found, this means that your system
+can't find the share @code{libmysqlclient.so} library.
+
+The fix for this is to tell your system to search after shared
+libraries where the library is located by one of the following methods:
+
+@itemize @bullet
+@item
+Add the path to the directory where you have @code{libmysqlclient.so} the
+@code{LD_LIBRARY_PATH} environment variable.
+@item
+Add the path to the directory where you have @code{libmysqlclient.so} the
+@code{LD_LIBRARY} environment variable.
+@item
+Copy @code{libmysqlclient.so} to some place that is searched by your system,
+like @file{/lib}, and update the shared library information by executing
+@code{ldconfig}.
+@end itemize
+
+Another way to solve this problem is to link your program statically, with
+@code{-static}, or by removing the dynamic MySQL libraries
+before linking your code. In the second case you should be
+sure that no other programs are using the dynamic libraries!
+
+
+@node Changing MySQL user, File permissions , Link errors, Installation Issues
+@appendixsubsec How to Run MySQL As a Normal User
+
+@cindex starting, @code{mysqld}
+@cindex @code{mysqld}, starting
+
+The MySQL server @code{mysqld} can be started and run by any user.
+In order to change @code{mysqld} to run as a Unix user @code{user_name}, you must
+do the following:
+
+@enumerate
+@item
+Stop the server if it's running (use @code{mysqladmin shutdown}).
+
+@item
+Change the database directories and files so that @code{user_name} has
+privileges to read and write files in them (you may need to do this as
+the Unix @code{root} user):
+
+@example
+shell> chown -R user_name /path/to/mysql/datadir
+@end example
+
+If directories or files within the MySQL data directory are
+symlinks, you'll also need to follow those links and change the directories
+and files they point to.  @code{chown -R} may not follow symlinks for
+you.
+
+@item
+Start the server as user @code{user_name}, or, if you are using
+MySQL Version 3.22 or later, start @code{mysqld} as the Unix @code{root}
+user and use the @code{--user=user_name} option.  @code{mysqld} will switch
+to run as the Unix user @code{user_name} before accepting any connections.
+
+@item
+To start the server as the given user name automatically at system
+startup time, add a @code{user} line that specifies the user name to
+the @code{[mysqld]} group of the @file{/etc/my.cnf} option file or the
+@file{my.cnf} option file in the server's data directory. For example:
+
+@example
+[mysqld]
+user=user_name
+@end example
+@end enumerate
+
+At this point, your @code{mysqld} process should be running fine and dandy as
+the Unix user @code{user_name}. One thing hasn't changed, though: the
+contents of the permissions tables. By default (right after running the
+permissions table install script @code{mysql_install_db}), the MySQL
+user @code{root} is the only user with permission to access the @code{mysql}
+database or to create or drop databases.  Unless you have changed those
+permissions, they still hold. This shouldn't stop you from accessing
+MySQL as the MySQL @code{root} user when you're logged in
+as a Unix user other than @code{root}; just specify the @code{-u root} option
+to the client program.
+
+Note that accessing MySQL as @code{root}, by supplying @code{-u
+root} on the command line, has @emph{nothing} to do with MySQL running
+as the Unix @code{root} user, or, indeed, as another Unix user. The access
+permissions and user names of MySQL are completely separate from
+Unix user names. The only connection with Unix user names is that if you
+don't provide a @code{-u} option when you invoke a client program, the client
+will try to connect using your Unix login name as your MySQL user
+name.
+
+If your Unix box itself isn't secured, you should probably at least put a
+password on the MySQL @code{root} users in the access tables.
+Otherwise, any user with an account on that machine can run @code{mysql -u
+root db_name} and do whatever he likes.
+
+
+@node File permissions ,  , Changing MySQL user, Installation Issues
+@appendixsubsec Problems with File Permissions
+
+@cindex files, permissions
+@cindex error mesaages, can't find file
+@cindex files, not found message
+
+If you have problems with file permissions, for example, if @code{mysql}
+issues the following error message when you create a table:
+
+@example
+ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)
+@end example
+
+@tindex UMASK environment variable
+@tindex Environment variable, UMASK
+then the environment variable @code{UMASK} might be set incorrectly when
+@code{mysqld} starts up.  The default umask value is @code{0660}. You can
+change this behavior by starting @code{safe_mysqld} as follows:
+
+@example
+shell> UMASK=384  # = 600 in octal
+shell> export UMASK
+shell> /path/to/safe_mysqld &
+@end example
+
+@tindex UMASK_DIR environment variable
+@tindex Environment variable, UMASK_DIR
+By default MySQL will create database and @code{RAID}
+directories with permission type 0700.  You can modify this behavior by
+setting the @code{UMASK_DIR} variable. If you set this, new
+directories are created with the combined @code{UMASK} and
+@code{UMASK_DIR}. For example, if you want to give group access to
+all new directories, you can do:
+
+@example
+shell> UMASK_DIR=504  # = 770 in octal
+shell> export UMASK_DIR
+shell> /path/to/safe_mysqld &
+@end example
+
+In MySQL Version 3.23.25 and above, MySQL assumes that the
+value for @code{UMASK} and @code{UMASK_DIR} is in octal if it starts
+with a zero.
+
+@xref{Environment variables}.
+
+
+@node Administration Issues, Query Issues, Installation Issues, Problems
+@appendixsec Administration Related Issues
+
+
+@menu
+* Crashing::                    
+* Resetting permissions::       
+* Full disk::                   
+* Temporary files::             
+* Problems with mysql.sock::    
+* Timezone problems::           
+@end menu
+
+@node Crashing, Resetting permissions, Administration Issues, Administration Issues
+@appendixsubsec What To Do If MySQL Keeps Crashing
+
+@cindex crash, repeated
+
+All MySQL versions are tested on many platforms before they are
+released.  This doesn't mean that there aren't any bugs in
+MySQL, but it means if there are bugs, they are very few and can be
+hard to find.  If you have a problem, it will always help if you try to
+find out exactly what crashes your system, as you will have a much better
+chance of getting this fixed quickly.
+
+First, you should try to find out whether the problem is that the
+@code{mysqld} daemon dies or whether your problem has to do with your
+client.  You can check how long your @code{mysqld} server has been up by
+executing @code{mysqladmin version}.  If @code{mysqld} has died, you may
+find the reason for this in the file
+@file{mysql-data-directory/`hostname`.err}. @xref{Error log}.
+
+Many crashes of MySQL are caused by corrupted index / data
+files.  MySQL will update the data on disk, with the
+@code{write()} system call, after every SQL statement and before the
+client is notified about the result. (This is not true if you are running
+with @code{delayed_key_writes}, in which case only the data is written.)
+This means that the data is safe even if @code{mysqld} crashes, as the OS will
+ensure that the not flushed data is written to disk.  You can force
+MySQL to sync everything to disk after every SQL command by
+starting @code{mysqld} with @code{--flush}.
+
+The above means that normally you shouldn't get corrupted tables unless:
+
+@itemize @bullet
+@item
+Someone/something killed @code{mysqld} or the machine in the middle
+of an update.
+@item
+You have found a bug in @code{mysqld} that caused it to die in the
+middle of an update.
+@item
+Someone is manipulating the data/index files outside of @strong{mysqld}
+without locking the table properly.
+@item
+If you are running many @code{mysqld} servers on the same data on a
+system that doesn't support good file system locks (normally handled by
+the @code{lockd} daemon ) or if you are running
+multiple servers with @code{--skip-locking}
+@item
+You have a crashed index/data file that contains very wrong data that
+got @code{mysqld} confused.
+@item
+You have found a bug in the data storage code. This isn't that likely,
+but it's at least possible.  In this case you can try to change the file
+type to another database handler by using @code{ALTER TABLE} on a
+repaired copy of the table!
+@end itemize
+
+Because it is very difficult to know why something is crashing, first try to
+check whether or not things that work for others crash for you.  Please try
+the following things:
+
+@itemize @bullet
+@item
+Take down the @code{mysqld} daemon with @code{mysqladmin shutdown}, run
+@code{myisamchk --silent --force */*.MYI} on all tables, and restart the
+@code{mysqld} daemon.  This will ensure that you are running from a clean
+state.  @xref{MySQL Database Administration}.
+
+@item
+Use @code{mysqld --log} and try to determine from the information in the log
+whether or not some specific query kills the server. About 95% of all bugs are
+related to a particular query!  Normally this is one of the last queries in
+the log file just before MySQL restarted. @xref{Query log}.
+If you can repeatadly kill MySQL with one of the queries, even
+when you have checked all tables just before doing the query, then you
+have been able to locate the bug and should do a bug report for this!
+@xref{Bug reports}.
+
+@item
+Try to make a test case that we can use to reproduce the problem.
+@xref{Reproduceable test case}.
+
+@item
+Try running the included mysql-test test and the MySQL
+benchmarks.  @xref{MySQL test suite}.  They should test MySQL
+rather well.  You can also add code that to the benchmarks to simulates
+your application!  The benchmarks can be found in the @file{bench}
+directory in the source distribution or, for a binary distribution, in
+the @file{sql-bench} directory under your MySQL installation
+directory.
+
+@item
+Try @code{fork_test.pl} and @code{fork2_test.pl}.
+
+@item
+If you configure MySQL for debugging, it will be much easier to
+gather information about possible errors if something goes wrong.
+Reconfigure MySQL with the @code{--with-debug} option or
+@code{--with-debug=full} to @code{configure} and then recompile.
+@xref{Debugging server}.
+
+@item
+Configuring MySQL for debugging causes a safe memory allocator to be
+included that can find some errors. It also provides a lot of output about
+what is happening.
+
+@item
+Have you applied the latest patches for your operating system?
+
+@item
+Use the @code{--skip-locking} option to @code{mysqld}.  On some systems, the
+@code{lockd} lock manager does not work properly; the @code{--skip-locking}
+option tells @code{mysqld} not to use external locking.  (This means that you
+cannot run 2 @code{mysqld} servers on the same data and that you must be
+careful if you use @code{myisamchk}, but it may be instructive to try the
+option as a test.)
+
+@item
+Have you tried @code{mysqladmin -u root processlist} when @code{mysqld}
+appears to be running but not responding?  Sometimes @code{mysqld} is not
+comatose even though you might think so.  The problem may be that all
+connections are in use, or there may be some internal lock problem.
+@code{mysqladmin processlist} will usually be able to make a connection even
+in these cases, and can provide useful information about the current number
+of connections and their status.
+
+@item
+Run the command @code{mysqladmin -i 5 status} or @code{mysqladmin -i 5
+-r status} or in a separate window to produce statistics while you run
+your other queries.
+
+@item
+Try the following:
+@enumerate
+@item
+Start @code{mysqld} from @code{gdb} (or in another debugger).
+@xref{Using gdb on mysqld}.
+
+@item
+Run your test scripts.
+
+@item
+Print the backtrace and the local variables at the 3 lowest levels. In gdb you
+can do this with the following commands when @code{mysqld} has crashed inside
+gdb:
+
+@example
+backtrace
+info local
+up
+info local
+up
+info local
+@end example
+
+With gdb you can also examine which threads exist with @code{info
+threads} and switch to a specific thread with @code{thread #}, where
+@code{#} is the thread id.
+@end enumerate
+
+@item
+Try to simulate your application with a Perl script to force
+MySQL to crash or misbehave.
+
+@item
+Send a normal bug report. @xref{Bug reports}. Be even more detailed
+than usual.  Because MySQL works for many people, it may be that the
+crash results from something that exists only on your computer (for example,
+an error that is related to your particular system libraries).
+@item
+If you have a problem with tables with dynamic-length rows and you are
+not using @code{BLOB/TEXT} columns (but only @code{VARCHAR} columns), you
+can try to change all @code{VARCHAR} to @code{CHAR} with @code{ALTER
+TABLE}.  This will force MySQL to use fixed-size rows.
+Fixed-size rows take a little extra space, but are much more tolerant to
+corruption!
+
+The current dynamic row code has been in use at MySQL AB for at
+least 3 years without any problems, but by nature dynamic-length rows are
+more prone to errors, so it may be a good idea to try the above to see if
+it helps!
+@end itemize
+
+
+@node Resetting permissions, Full disk, Crashing, Administration Issues
+@appendixsubsec How to Reset a Forgotten Password
+
+@cindex passwords, forgotten
+@cindex passwords, resetting
+@cindex root user, password resetting
+
+If you have forgotten the @code{root} user password for MySQL, you
+can restore it with the following procedure:
+
+@enumerate
+@item
+Take down the @code{mysqld} server by sending a @code{kill} (not @code{kill
+-9}) to the @code{mysqld} server.  The pid is stored in a @code{.pid}
+file, which is normally in the MySQL database directory:
+
+@example
+kill `cat /mysql-data-directory/hostname.pid`
+@end example
+
+You must be either the Unix @code{root} user or the same user the server
+runs as to do this.
+
+@item
+Restart @code{mysqld} with the @code{--skip-grant-tables} option.
+@item
+Connect to the @code{mysqld} server with @code{mysql -h hostname mysql} and change
+the password with a @code{GRANT} command. @xref{GRANT,,@code{GRANT}}.
+You can also do this with
+@code{mysqladmin -h hostname -u user password 'new password'}
+@item
+Load the privilege tables with: @code{mysqladmin -h hostname
+flush-privileges} or with the SQL command @code{FLUSH PRIVILEGES}.
+@end enumerate
+
+Note that after you started @code{mysqld} with @code{--skip-grant-tables},
+any usage of @code{GRANT} commands will give you an @code{Unknown command}
+error until you have executed @code{FLUSH PRIVILEGES}.
+
+
+@node Full disk, Temporary files, Resetting permissions, Administration Issues
+@appendixsubsec How MySQL Handles a Full Disk
 
 @cindex full disk
 @cindex disk full
@@ -43801,8 +44027,8 @@ it will remove the big temporary files and mark the table as crashed
 unchanged).
 
 
-@node Temporary files, Problems with mysql.sock, Full disk, Problems
-@appendixsec Where MySQL Stores Temporary Files
+@node Temporary files, Problems with mysql.sock, Full disk, Administration Issues
+@appendixsubsec Where MySQL Stores Temporary Files
 
 MySQL uses the value of the @code{TMPDIR} environment variable as
 the pathname of the directory in which to store temporary files.  If you don't
@@ -43838,8 +44064,8 @@ tables. These are not hidden and have names of the form @file{SQL_*}.
 the original table.
 
 
-@node  Problems with mysql.sock, Changing MySQL user, Temporary files, Problems
-@appendixsec How to Protect @file{/tmp/mysql.sock} from Being Deleted
+@node  Problems with mysql.sock, Timezone problems, Temporary files, Administration Issues
+@appendixsubsec How to Protect @file{/tmp/mysql.sock} from Being Deleted
 
 @cindex @code{mysql.sock}, protection
 @cindex deletion, @code{mysql.sock}
@@ -43860,224 +44086,70 @@ You can check if the @code{sticky} bit is set by executing @code{ls -ld /tmp}.
 If the last permission bit is @code{t}, the bit is set.
 
 
-@node Changing MySQL user, Resetting permissions, Problems with mysql.sock, Problems
-@appendixsec How to Run MySQL As a Normal User
+@node Timezone problems,  , Problems with mysql.sock, Administration Issues
+@appendixsubsec Time Zone Problems
 
-@cindex starting, @code{mysqld}
-@cindex @code{mysqld}, starting
+@cindex timezone problems
+@cindex problems, timezone
 
-The MySQL server @code{mysqld} can be started and run by any user.
-In order to change @code{mysqld} to run as a Unix user @code{user_name}, you must
-do the following:
-
-@enumerate
-@item
-Stop the server if it's running (use @code{mysqladmin shutdown}).
-
-@item
-Change the database directories and files so that @code{user_name} has
-privileges to read and write files in them (you may need to do this as
-the Unix @code{root} user):
-
-@example
-shell> chown -R user_name /path/to/mysql/datadir
-@end example
-
-If directories or files within the MySQL data directory are
-symlinks, you'll also need to follow those links and change the directories
-and files they point to.  @code{chown -R} may not follow symlinks for
-you.
-
-@item
-Start the server as user @code{user_name}, or, if you are using
-MySQL Version 3.22 or later, start @code{mysqld} as the Unix @code{root}
-user and use the @code{--user=user_name} option.  @code{mysqld} will switch
-to run as the Unix user @code{user_name} before accepting any connections.
-
-@item
-To start the server as the given user name automatically at system
-startup time, add a @code{user} line that specifies the user name to
-the @code{[mysqld]} group of the @file{/etc/my.cnf} option file or the
-@file{my.cnf} option file in the server's data directory. For example:
-
-@example
-[mysqld]
-user=user_name
-@end example
-@end enumerate
-
-At this point, your @code{mysqld} process should be running fine and dandy as
-the Unix user @code{user_name}. One thing hasn't changed, though: the
-contents of the permissions tables. By default (right after running the
-permissions table install script @code{mysql_install_db}), the MySQL
-user @code{root} is the only user with permission to access the @code{mysql}
-database or to create or drop databases.  Unless you have changed those
-permissions, they still hold. This shouldn't stop you from accessing
-MySQL as the MySQL @code{root} user when you're logged in
-as a Unix user other than @code{root}; just specify the @code{-u root} option
-to the client program.
-
-Note that accessing MySQL as @code{root}, by supplying @code{-u
-root} on the command line, has @emph{nothing} to do with MySQL running
-as the Unix @code{root} user, or, indeed, as another Unix user. The access
-permissions and user names of MySQL are completely separate from
-Unix user names. The only connection with Unix user names is that if you
-don't provide a @code{-u} option when you invoke a client program, the client
-will try to connect using your Unix login name as your MySQL user
-name.
-
-If your Unix box itself isn't secured, you should probably at least put a
-password on the MySQL @code{root} users in the access tables.
-Otherwise, any user with an account on that machine can run @code{mysql -u
-root db_name} and do whatever he likes.
-
-
-@node Resetting permissions, File permissions , Changing MySQL user, Problems
-@appendixsec How to Reset a Forgotten Password
-
-@cindex passwords, forgotten
-@cindex passwords, resetting
-@cindex root user, password resetting
-
-If you have forgotten the @code{root} user password for MySQL, you
-can restore it with the following procedure:
-
-@enumerate
-@item
-Take down the @code{mysqld} server by sending a @code{kill} (not @code{kill
--9}) to the @code{mysqld} server.  The pid is stored in a @code{.pid}
-file, which is normally in the MySQL database directory:
-
-@example
-kill `cat /mysql-data-directory/hostname.pid`
-@end example
-
-You must be either the Unix @code{root} user or the same user the server
-runs as to do this.
-
-@item
-Restart @code{mysqld} with the @code{--skip-grant-tables} option.
-@item
-Connect to the @code{mysqld} server with @code{mysql -h hostname mysql} and change
-the password with a @code{GRANT} command. @xref{GRANT,,@code{GRANT}}.
-You can also do this with
-@code{mysqladmin -h hostname -u user password 'new password'}
-@item
-Load the privilege tables with: @code{mysqladmin -h hostname
-flush-privileges} or with the SQL command @code{FLUSH PRIVILEGES}.
-@end enumerate
-
-Note that after you started @code{mysqld} with @code{--skip-grant-tables},
-any usage of @code{GRANT} commands will give you an @code{Unknown command}
-error until you have executed @code{FLUSH PRIVILEGES}.
-
-
-@node File permissions , Not enough file handles, Resetting permissions, Problems
-@appendixsec Problems with File Permissions
-
-@cindex files, permissions
-@cindex error mesaages, can't find file
-@cindex files, not found message
-
-If you have problems with file permissions, for example, if @code{mysql}
-issues the following error message when you create a table:
-
-@example
-ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)
-@end example
-
-@tindex UMASK environment variable
-@tindex Environment variable, UMASK
-then the environment variable @code{UMASK} might be set incorrectly when
-@code{mysqld} starts up.  The default umask value is @code{0660}. You can
-change this behavior by starting @code{safe_mysqld} as follows:
-
-@example
-shell> UMASK=384  # = 600 in octal
-shell> export UMASK
-shell> /path/to/safe_mysqld &
-@end example
-
-@tindex UMASK_DIR environment variable
-@tindex Environment variable, UMASK_DIR
-By default MySQL will create database and @code{RAID}
-directories with permission type 0700.  You can modify this behavior by
-setting the @code{UMASK_DIR} variable. If you set this, new
-directories are created with the combined @code{UMASK} and
-@code{UMASK_DIR}. For example, if you want to give group access to
-all new directories, you can do:
-
-@example
-shell> UMASK_DIR=504  # = 770 in octal
-shell> export UMASK_DIR
-shell> /path/to/safe_mysqld &
-@end example
-
-In MySQL Version 3.23.25 and above, MySQL assumes that the
-value for @code{UMASK} and @code{UMASK_DIR} is in octal if it starts
-with a zero.
+@tindex TZ environment variable
+@tindex Environment variable, TZ
 
+If you have a problem with @code{SELECT NOW()} returning values in GMT and
+not your local time, you have to set the @code{TZ} environment variable to
+your current time zone.  This should be done for the environment in which
+the server runs, for example, in @code{safe_mysqld} or @code{mysql.server}.
 @xref{Environment variables}.
 
 
-@node Not enough file handles, Using DATE, File permissions , Problems
-@appendixsec File Not Found
-
-If you get @code{ERROR '...' not found (errno: 23)}, @code{Can't open
-file: ... (errno: 24)}, or any other error with @code{errno 23} or
-@code{errno 24} from MySQL, it means that you haven't allocated
-enough file descriptors for MySQL.  You can use the
-@code{perror} utility to get a description of what the error number
-means:
-
-@example
-shell> perror 23
-File table overflow
-shell> perror 24
-Too many open files
-shell> perror 11
-Resource temporarily unavailable
-@end example
-
-The problem here is that @code{mysqld} is trying to keep open too many
-files simultaneously.  You can either tell @code{mysqld} not to open so
-many files at once or increase the number of file descriptors
-available to @code{mysqld}.
-
-To tell @code{mysqld} to keep open fewer files at a time, you can make
-the table cache smaller by using the @code{-O table_cache=32} option to
-@code{safe_mysqld} (the default value is 64). Reducing the value of
-@code{max_connections} will also reduce the number of open files (the
-default value is 90).
-
-@tindex ulimit
-To change the number of file descriptors available to @code{mysqld}, you
-can use the option @code{--open-files-limit=#} to @code{safe_mysqld} or
-@code{-O open-files-limit=#} to @code{mysqld}. @xref{SHOW VARIABLES}.
-The easiest way to do that is to add the option to your option file.
-@xref{Option files}.  If you have an old @code{mysqld} version that
-doesn't support this, you can edit the @code{safe_mysqld} script.  There
-is a commented-out line @code{ulimit -n 256} in the script.  You can
-remove the @code{'#'} character to uncomment this line, and change the
-number 256 to affect the number of file descriptors available to
-@code{mysqld}.
-
-@code{ulimit} (and @code{open-files-limit}) can increase the number of
-file descriptors, but only up to the limit imposed by the operating
-system. There is also a 'hard' limit that can only be overrided if you
-start @code{safe_mysqld} or @code{mysqld} as root (Just remember that
-you need to also use the @code{--user=..} option in this case).  If you
-need to increase the OS limit on the number of file descriptors
-available to each process, consult the documentation for your operating
-system.
-
-Note that if you run the @code{tcsh} shell, @code{ulimit} will not work!
-@code{tcsh} will also report incorrect values when you ask for the current
-limits!  In this case you should start @code{safe_mysqld} with @code{sh}!
+@node Query Issues, Table Definition Issues, Administration Issues, Problems
+@appendixsec Query Related Issues
 
 
-@node Using DATE, Timezone problems, Not enough file handles, Problems
-@appendixsec Problems Using @code{DATE} Columns
+@menu
+* Case sensitivity::            
+* Using DATE::                  
+* Problems with NULL::          
+* Problems with alias::         
+* Deleting from related tables::  
+* No matching rows::            
+@end menu
+
+@node Case sensitivity, Using DATE, Query Issues, Query Issues
+@appendixsubsec Case Sensitivity in Searches
+
+@cindex case sensitivity, in searches
+@cindex searching, and case-sensitivity
+@cindex Chinese
+@cindex Big5 Chinese character encoding
+
+By default, MySQL searches are case-insensitive (although there are
+some character sets that are never case insensitive, such as @code{czech}).
+That means that if you search with @code{col_name LIKE 'a%'}, you will get all
+column values that start with @code{A} or @code{a}. If you want to make this
+search case-sensitive, use something like @code{INDEX(col_name, "A")=0} to
+check a prefix. Or use @code{STRCMP(col_name, "A") = 0} if the column value
+must be exactly @code{"A"}.
+
+Simple comparison operations (@code{>=, >, = , < , <=}, sorting and
+grouping) are based on each character's ``sort value''. Characters with
+the same sort value (like E, e and �) are treated as the same character!
+
+In older MySQL versions @code{LIKE} comparisons where done on
+the uppercase value of each character (E == e but E <> �).  In newer
+MySQL versions @code{LIKE} works just like the other comparison
+operators.
+
+If you want a column always to be treated in case-sensitive fashion,
+declare it as @code{BINARY}. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
+
+If you are using Chinese data in the so-called big5 encoding, you want to
+make all character columns @code{BINARY}. This works because the sorting
+order of big5 encoding characters is based on the order of ASCII codes.
+
+
+@node Using DATE, Problems with NULL, Case sensitivity, Query Issues
+@appendixsubsec Problems Using @code{DATE} Columns
 
 @findex DATE
 
@@ -44145,57 +44217,8 @@ issue and we think it is up to the application to check the dates, and not
 the server.
 
 
-@node Timezone problems, Case sensitivity, Using DATE, Problems
-@appendixsec Time Zone Problems
-
-@cindex timezone problems
-@cindex problems, timezone
-
-@tindex TZ environment variable
-@tindex Environment variable, TZ
-
-If you have a problem with @code{SELECT NOW()} returning values in GMT and
-not your local time, you have to set the @code{TZ} environment variable to
-your current time zone.  This should be done for the environment in which
-the server runs, for example, in @code{safe_mysqld} or @code{mysql.server}.
-@xref{Environment variables}.
-
-
-@node Case sensitivity, Problems with NULL, Timezone problems, Problems
-@appendixsec Case Sensitivity in Searches
-
-@cindex case sensitivity, in searches
-@cindex searching, and case-sensitivity
-@cindex Chinese
-@cindex Big5 Chinese character encoding
-
-By default, MySQL searches are case-insensitive (although there are
-some character sets that are never case insensitive, such as @code{czech}).
-That means that if you search with @code{col_name LIKE 'a%'}, you will get all
-column values that start with @code{A} or @code{a}. If you want to make this
-search case-sensitive, use something like @code{INDEX(col_name, "A")=0} to
-check a prefix. Or use @code{STRCMP(col_name, "A") = 0} if the column value
-must be exactly @code{"A"}.
-
-Simple comparison operations (@code{>=, >, = , < , <=}, sorting and
-grouping) are based on each character's ``sort value''. Characters with
-the same sort value (like E, e and �) are treated as the same character!
-
-In older MySQL versions @code{LIKE} comparisons where done on
-the uppercase value of each character (E == e but E <> �).  In newer
-MySQL versions @code{LIKE} works just like the other comparison
-operators.
-
-If you want a column always to be treated in case-sensitive fashion,
-declare it as @code{BINARY}. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
-
-If you are using Chinese data in the so-called big5 encoding, you want to
-make all character columns @code{BINARY}. This works because the sorting
-order of big5 encoding characters is based on the order of ASCII codes.
-
-
-@node Problems with NULL, Problems with alias, Case sensitivity, Problems
-@appendixsec Problems with @code{NULL} Values
+@node Problems with NULL, Problems with alias, Using DATE, Query Issues
+@appendixsubsec Problems with @code{NULL} Values
 
 @cindex @code{NULL} values, vs. empty values
 
@@ -44273,8 +44296,8 @@ current date and time is inserted.  If you insert @code{NULL} into an
 @code{AUTO_INCREMENT} column, the next number in the sequence is inserted.
 
 
-@node Problems with alias, Deleting from related tables, Problems with NULL, Problems
-@appendixsec Problems with @code{alias}
+@node Problems with alias, Deleting from related tables, Problems with NULL, Query Issues
+@appendixsubsec Problems with @code{alias}
 
 @tindex alias
 
@@ -44302,8 +44325,8 @@ be included in the @code{GROUP BY} part while @code{HAVING} is used to
 decide which rows from the result set should be used.
 
 
-@node Deleting from related tables, No matching rows, Problems with alias, Problems
-@appendixsec Deleting Rows from Related Tables
+@node Deleting from related tables, No matching rows, Problems with alias, Query Issues
+@appendixsubsec Deleting Rows from Related Tables
 
 @cindex deleting, rows
 @cindex rows, deleting
@@ -44331,8 +44354,9 @@ id's per query if the @code{related_column} is an index.  If the
 @code{related_column} isn't an index, the speed is independent of the
 number of arguments in the @code{IN} clause.
 
-@node No matching rows, ALTER TABLE problems, Deleting from related tables, Problems
-@appendixsec Solving Problems with No Matching Rows
+
+@node No matching rows,  , Deleting from related tables, Query Issues
+@appendixsubsec Solving Problems with No Matching Rows
 
 @cindex no matching rows
 @cindex rows, matching problems
@@ -44387,8 +44411,18 @@ Post the test file using @code{mysqlbug} to @email{mysql@@lists.mysql.com}.
 @end enumerate
 
 
-@node ALTER TABLE problems, Change column order, No matching rows, Problems
-@appendixsec Problems with @code{ALTER TABLE}.
+@node Table Definition Issues,  , Query Issues, Problems
+@appendixsec Table Definition Related Issues
+
+
+@menu
+* ALTER TABLE problems::        
+* Change column order::         
+* Temporary table problems::    
+@end menu
+
+@node ALTER TABLE problems, Change column order, Table Definition Issues, Table Definition Issues
+@appendixsubsec Problems with @code{ALTER TABLE}.
 
 @tindex ALTER TABLE
 
@@ -44426,8 +44460,8 @@ of course), MySQL may leave the old table as @file{B-xxx}, but a
 simple rename on the system level should get your data back.
 
 
-@node Change column order, Temporary table problems, ALTER TABLE problems, Problems
-@appendixsec How To Change the Order of Columns in a Table
+@node Change column order, Temporary table problems, ALTER TABLE problems, Table Definition Issues
+@appendixsubsec How To Change the Order of Columns in a Table
 
 @cindex reordering, columns
 @cindex columns, changing
@@ -44471,8 +44505,8 @@ Drop or rename @code{old_table}.
 @end enumerate
 
 
-@node Temporary table problems,  , Change column order, Problems
-@appendixsec TEMPORARY TABLE problems
+@node Temporary table problems,  , Change column order, Table Definition Issues
+@appendixsubsec TEMPORARY TABLE problems
 
 @cindex temporary tables, problems
 
@@ -44501,93 +44535,11 @@ We plan to fix the above in 4.0.
 
 
 
+@node Users, MySQL customer usage, Problems, Top
+@appendix Some MySQL Users
 
-@page
-@cindex environment variables, list of
-@node Environment variables, Users, Problems, Top
-@appendix  Environment Variables
-
-Here is a list of all the environment variables that are used directly or
-indirectly by MySQL. Most of these can also be found in other
-places in this manual.
-
-Note that any options on the command line will take precedence over
-values specified in configuration files and environment variables, and
-values in configuration files take precedence over values in environment
-variables.
-
-In many cases it's preferable to use a configure file instead of environment
-variables to modify the behavior of MySQL. @xref{Option files}.
-
-@tindex CCX environment variable
-@tindex Environment variable, CCX
-@tindex CC environment variable
-@tindex Environment variable, CC
-@tindex CFLAGS environment variable
-@tindex Environment variable, CFLAGS
-@tindex CXXFLAGS environment variable
-@tindex Environment variable, CXXFLAGS
-@tindex DBI_USER environment variable
-@tindex Environment variable, DBI_USER
-@tindex DBI_TRACE environment variable
-@tindex Environment variable, DBI_TRACE
-@tindex HOME environment variable
-@tindex Environment variable, HOME
-@tindex LD_RUN_PATH environment variable
-@tindex Environment variable, LD_RUN_PATH
-@tindex MYSQL_DEBUG environment variable
-@tindex Environment variable, MYSQL_DEBUG
-@tindex MYSQL_HISTFILE environment variable
-@tindex Environment variable, MYSQL_HISTFILE
-@tindex MYSQL_HOST environment variable
-@tindex Environment variable, MYSQL_HOST
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_TCP_PORT
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex PATH environment variable
-@tindex Environment variable, PATH
-@tindex TMPDIR environment variable
-@tindex Environment variable, TMPDIR
-@tindex TZ environment variable
-@tindex Environment variable, TZ
-@tindex UMASK_DIR environment variable
-@tindex Environment variable, UMASK_DIR
-@tindex UMASK environment variable
-@tindex Environment variable, UMASK
-@tindex USER environment variable
-@tindex Environment variable, USER
-
-@multitable @columnfractions .2 .8
-@item @code{CCX}  @tab Set this to your C++ compiler when running configure.
-@item @code{CC}  @tab Set this to your C compiler when running configure.
-@item @code{CFLAGS} @tab Flags for your C compiler when running configure.
-@item @code{CXXFLAGS} @tab Flags for your C++ compiler when running configure.
-@item @code{DBI_USER} @tab The default user name for Perl DBI.
-@item @code{DBI_TRACE} @tab Used when tracing Perl DBI.
-@item @code{HOME} @tab The default path for the @code{mysql} history file is @file{$HOME/.mysql_history}.
-@item @code{LD_RUN_PATH} @tab Used to specify where your @code{libmysqlclient.so} is.
-@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging.
-@item @code{MYSQL_HISTFILE} @tab The path to the @code{mysql} history file.
-@item @code{MYSQL_HOST} @tab Default host name used by the @code{mysql} command-line prompt.
-@item @code{MYSQL_PWD} @tab The default password when connecting to @code{mysqld}. Note that use of this is insecure!
-@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port.
-@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}.
-@item @code{PATH} @tab Used by the shell to finds the MySQL programs.
-@item @code{TMPDIR} @tab The directory where temporary tables/files are created.
-@item @code{TZ} @tab This should be set to your local time zone. @xref{Timezone problems}.
-@item @code{UMASK_DIR} @tab The user-directory creation mask when creating directories. Note that this is ANDed with @code{UMASK}!
-@item @code{UMASK} @tab The user-file creation mask when creating files.
-@item @code{USER} @tab The default user on Windows to use when connecting to @code{mysqld}.
-@end multitable
-
-@page
 @cindex users, of MySQL
 @cindex news sites
-@node Users, MySQL customer usage, Environment variables, Top
-@appendix Some MySQL Users
 
 This appendix lists some users of MySQL that have given us permission
 to list them in our documentation.  It is by far not a complete list, but
@@ -45002,10 +44954,15 @@ Washington's Eastside residents and businesses}
 Send any additions to this list to @email{webmaster@@mysql.com}.
 
 @page
-@cindex MySQL usage
+
+
+
+
 @node MySQL customer usage, Contrib, Users, Top
 @appendix MySQL customer usage
 
+@cindex MySQL usage
+
 The section 'Some MySQL Users' contains a lot of different links to
 MySQL users but doesn't provide that much information about how
 they are using MySQL.  @xref{Users}. This manual section is to
@@ -45036,11 +44993,16 @@ that contain up to 2,000 million rows in a validation regression database.
 @end itemize
 
 @page
-@cindex contributed programs
-@cindex programs, contributed
+
+
+
+
 @node Contrib, Credits, MySQL customer usage, Top
 @appendix Contributed Programs
 
+@cindex contributed programs
+@cindex programs, contributed
+
 Many users of MySQL have contributed @emph{very} useful support
 tools and add-ons.
 
@@ -45849,21 +45811,26 @@ Patches to add logging to MySQL for WU-ftpd 2.6.0. By
 Previous versions of things found here that you probably won't be
 interested in.
 @end itemize
-
 @page
+
+
+
+
 @node Credits, News, Contrib, Top
 @appendix Credits
 
+@cindex developers, list of
+
 This appendix lists the developers, contributors, and supporters that have
 helped to make MySQL what it is today.
 
-@cindex developers, list of
 @menu
 * Developers::                  
 * Contributors::                
 * Supporters::                  
 @end menu
 
+
 @node Developers, Contributors, Credits, Credits
 @appendixsec Developers at MySQL AB
 
@@ -46053,10 +46020,12 @@ Erik Granberg - Handles MySQL partners (and a lot of other stuff).
 Allan Larsson (The BOSS for TCX DataKonsult AB).
 @end table
 
-@cindex contributors, list of
+
 @node Contributors, Supporters, Developers, Credits
 @appendixsec Contributors to MySQL
 
+@cindex contributors, list of
+
 Contributors to the MySQL distribution are listed here, in
 somewhat random order:
 
@@ -46287,10 +46256,12 @@ ODBC and VisualC++ interface questions.
 @code{DBD}, Linux, some SQL syntax questions.
 @end table
 
-@cindex contributing companies, list of
+
 @node Supporters,  , Contributors, Credits
 @appendixsec Supporters to MySQL
 
+@cindex contributing companies, list of
+
 The following companies has helped us finance development of
 MySQL by either paying us for developing a new feature,
 developed a MySQL feature themselves or by giving us hardware for
@@ -46313,9 +46284,16 @@ Development on the embedded @code{mysqld} version.
 @code{--skip-show-variables}
 @end table
 
+
+
+
 @node News, Porting, Credits, Top
 @appendix MySQL change history
 
+@cindex ChangeLog
+@cindex changes, log
+@cindex log, changes
+
 This appendix lists the changes from version to version in the MySQL
 source code.
 
@@ -46334,6 +46312,7 @@ this means that the version has not yet been released!
 * News-3.19.x::                 Changes in release 3.19.x
 @end menu
 
+
 @node News-4.0.x, News-3.23.x, News, News
 @appendixsec Changes in release 4.0.x (Development; Alpha)
 
@@ -46346,9 +46325,12 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
 * News-4.0.0::                  Changes in release 4.0.0
 @end menu
 
+
 @node News-4.0.0,  , News-4.0.x, News-4.0.x
 @appendixsubsec Changes in release 4.0.0
 
+@cindex changes, version 4.0
+
 @itemize @bullet
 @item
 Multi-table @code{DELETE}.
@@ -46394,9 +46376,12 @@ Optimized queries of type:
 @code{SELECT DISTINCT * from table_name ORDER by key_part1 LIMIT #}
 @end itemize
 
+
 @node News-3.23.x, News-3.22.x, News-4.0.x, News
 @appendixsec Changes in release 3.23.x  (Stable)
 
+@cindex changes, version 3.23
+
 The 3.23 release has several major features that are not
 present in previous versions.  We have added three new
 table types:
@@ -46479,8 +46464,10 @@ not yet 100% confident in this code.
 * News-3.23.0::                 Changes in release 3.23.0
 @end menu
 
+
 @node News-3.23.41, News-3.23.40, News-3.23.x, News-3.23.x
 @appendixsubsec Changes in release 3.23.41
+
 @itemize @bullet
 @item
 Added option @code{--sql-mode=option[,option[,option]]}.
@@ -46523,8 +46510,10 @@ Fixed bug in @code{SELECT DISTINCT ... HAVING} that casued error message
 @code{Can't find record in '#...}
 @end itemize
 
+
 @node News-3.23.40, News-3.23.39, News-3.23.41, News-3.23.x
 @appendixsubsec Changes in release 3.23.40
+
 @itemize @bullet
 @item
 Fixed problem with @code{--low-priority-updates} and @code{INSERT}'s.
@@ -46577,8 +46566,10 @@ Removed all documentation referring to the @code{GEMINI} table
 type. @code{GEMINI} is not released under an Open Source license.
 @end itemize
 
+
 @node News-3.23.39, News-3.23.38, News-3.23.40, News-3.23.x
 @appendixsubsec Changes in release 3.23.39
+
 @itemize @bullet
 @item
 The @code{AUTO_INCREMENT} sequence wasn't reset when dropping
@@ -46618,8 +46609,10 @@ Fixed problem with @code{MERGE} tables and big tables (> 4G) when using
 @code{ORDER BY}.
 @end itemize
 
+
 @node News-3.23.38, News-3.23.37, News-3.23.39, News-3.23.x
 @appendixsubsec Changes in release 3.23.38
+
 @itemize @bullet
 @item
 Fixed a bug when @code{SELECT} from @code{MERGE} table
@@ -46668,8 +46661,10 @@ when @code{to_table} was empty.
 Fixed bug with @code{LOCK TABLE} and BDB tables.
 @end itemize
 
+
 @node News-3.23.37, News-3.23.36, News-3.23.38, News-3.23.x
 @appendixsubsec Changes in release 3.23.37
+
 @itemize @bullet
 @item
 Fixed a bug when using @code{MATCH} in @code{HAVING} clause.
@@ -46732,8 +46727,10 @@ fixed with  @code{myisamchk -r} or @code{REPAIR TABLE} !
 Added @code{--skip-safemalloc} option to @code{mysqld}.
 @end itemize
 
+
 @node News-3.23.36, News-3.23.35, News-3.23.37, News-3.23.x
 @appendixsubsec Changes in release 3.23.36
+
 @itemize @bullet
 @item
 Fixed a bug that allowed you to use database names containing a @samp{.}
@@ -46771,8 +46768,10 @@ allow concurrent inserts as this could make the binary log hard to repeat.
 Changed some macros to be able to use fast mutex with glibc 2.2.
 @end itemize
 
+
 @node News-3.23.35, News-3.23.34a, News-3.23.36, News-3.23.x
 @appendixsubsec Changes in release 3.23.35
+
 @itemize @bullet
 @item
 Fixed newly introduced bug in @code{ORDER BY}.
@@ -46788,16 +46787,20 @@ Tuned @code{SHOW ANALYZE} for small tables.
 Fixed handling of arguments in the benchmark script @file{run-all-tests}.
 @end itemize
 
+
 @node News-3.23.34a, News-3.23.34, News-3.23.35, News-3.23.x
 @appendixsubsec Changes in release 3.23.34a
+
 @itemize @bullet
 @item
 Added extra files to the distribution to allow @code{INNOBASE} support 
 to be compiled.
 @end itemize
 
+
 @node News-3.23.34, News-3.23.33, News-3.23.34a, News-3.23.x
 @appendixsubsec Changes in release 3.23.34
+
 @itemize @bullet
 @item
 Added the @code{INNOBASE} table handler and the @code{BDB} table handler
@@ -46869,8 +46872,10 @@ Fixed a deadlock in the @code{SET} code, when one ran @code{SET @@foo=bar},
 where @code{bar} is a column reference, an error was not properly generated.
 @end itemize
 
+
 @node News-3.23.33, News-3.23.32, News-3.23.34, News-3.23.x
 @appendixsubsec Changes in release 3.23.33
+
 @itemize @bullet
 @item
 Fixed that DNS lookups are not using the same mutex as the hostname
@@ -46958,8 +46963,10 @@ memory, as it's being allocated to the directory entry cache instead of
 the disk cache.
 @end itemize
 
+
 @node News-3.23.32, News-3.23.31, News-3.23.33, News-3.23.x
 @appendixsubsec Changes in release 3.23.32
+
 @itemize @bullet
 @item
 Changed code to get around compiler bug in Compaq C++ on OSF1, that broke
@@ -46998,8 +47005,10 @@ Fixed a bug which caused a core dump on the slave when replicating
 Added @code{MASTER_POS_WAIT()}.
 @end itemize
 
+
 @node News-3.23.31, News-3.23.30, News-3.23.32, News-3.23.x
 @appendixsubsec Changes in release 3.23.31
+
 @itemize @bullet
 @item
 The test suite now tests all reachable BDB interface code.  During
@@ -47052,8 +47061,10 @@ Fixed @code{safe_mysqld} and @code{mysql.server} to also read the
 Added @code{Threads_created} status variable to @code{mysqld}.
 @end itemize
 
+
 @node News-3.23.30, News-3.23.29, News-3.23.31, News-3.23.x
 @appendixsubsec Changes in release 3.23.30
+
 @itemize @bullet
 @item
 Added @code{SHOW OPEN TABLES} command.
@@ -47113,8 +47124,10 @@ name @code{UNOPENED} in error messages.
 Fixed bug when running two simultaneous @code{SHOW LOGS} queries.
 @end itemize
 
+
 @node News-3.23.29, News-3.23.28, News-3.23.30, News-3.23.x
 @appendixsubsec Changes in release 3.23.29
+
 @itemize @bullet
 @item
 Configure updates for Tru64, large file support, and better TCP wrapper
@@ -47240,8 +47253,10 @@ Added @code{connect_timeout} as an alias for @code{timeout} for option files
 read by @code{mysql_options()}.
 @end itemize
 
+
 @node News-3.23.28, News-3.23.27, News-3.23.29, News-3.23.x
 @appendixsubsec Changes in release 3.23.28
+
 @itemize @bullet
 @item
 Added new options @code{--pager[=...]}, @code{--no-pager},
@@ -47360,8 +47375,10 @@ set it to 0 instead of 4 and hit the magic number in the master binlog.
 new table with the rows in a specific order.
 @end itemize
 
+
 @node News-3.23.27, News-3.23.26, News-3.23.28, News-3.23.x
 @appendixsubsec Changes in release 3.23.27
+
 @itemize @bullet
 @item
 Fixed a bug where the automatic repair of MyISAM tables sometimes failed
@@ -47378,8 +47395,10 @@ Added the latin5 (turkish) character set.
 Small portability fixes.
 @end itemize
 
+
 @node News-3.23.26, News-3.23.25, News-3.23.27, News-3.23.x
 @appendixsubsec Changes in release 3.23.26
+
 @itemize @bullet
 @item
 Fixed @code{<>} to work properly with @code{NULL}.
@@ -47452,8 +47471,10 @@ Changed to use @code{mkstemp()} instead of @code{tempnam()}. Based
 on a patch from John Jones.
 @end itemize
 
+
 @node News-3.23.25, News-3.23.24, News-3.23.26, News-3.23.x
 @appendixsubsec Changes in release 3.23.25
+
 @itemize @bullet
 @item
 Fixed that @code{databasename} works as second argument to @code{mysqlhotcopy}.
@@ -47540,8 +47561,10 @@ Fixed @code{CHECK TABLE} to work on Windows.
 Added file mutexes to make @code{pwrite()} safe on Windows.
 @end itemize
 
+
 @node News-3.23.24, News-3.23.23, News-3.23.25, News-3.23.x
 @appendixsubsec Changes in release 3.23.24
+
 @itemize @bullet
 @item
 Added @code{mysqld} variable @code{created_tmp_disk_tables}.
@@ -47563,8 +47586,10 @@ Fixed problem with BDB tables and reading on a unique (not primary) key.
 Restored the win1251 character set (it's now only marked deprecated).
 @end itemize
 
+
 @node News-3.23.23, News-3.23.22, News-3.23.24, News-3.23.x
 @appendixsubsec Changes in release 3.23.23
+
 @itemize @bullet
 @item
 Changed sort order for 'German';  All tables created with 'German' sortorder
@@ -47671,8 +47696,10 @@ Full text search via the @code{MATCH} function and @code{FULLTEXT} index type.
 (For MyISAM files).  This makes @code{FULLTEXT} a reserved word.
 @end itemize
 
+
 @node News-3.23.22, News-3.23.21, News-3.23.23, News-3.23.x
 @appendixsubsec Changes in release 3.23.22
+
 @itemize @bullet
 @item
 Fixed that @code{lex_hash.h} is created properly for each MySQL
@@ -47713,8 +47740,10 @@ get bigger than 64M.
 Added @code{SHOW MASTER STATUS} and @code{SHOW SLAVE STATUS}.
 @end itemize
 
+
 @node News-3.23.21, News-3.23.20, News-3.23.22, News-3.23.x
 @appendixsubsec Changes in release 3.23.21
+
 @itemize @bullet
 @item
 Added @code{mysql_character_set_name(MYSQL *mysql)} function to the
@@ -47755,8 +47784,10 @@ a feature.
 @code{MATCH} and @code{AGAINST} are now reserved words.
 @end itemize
 
+
 @node News-3.23.20, News-3.23.19, News-3.23.21, News-3.23.x
 @appendixsubsec Changes in release 3.23.20
+
 @itemize @bullet
 @item
 Fixed bug in 3.23.19; @code{DELETE FROM tbl_name} removed the .frm file.
@@ -47764,8 +47795,10 @@ Fixed bug in 3.23.19; @code{DELETE FROM tbl_name} removed the .frm file.
 Added @code{SHOW CREATE TABLE}.
 @end itemize
 
+
 @node News-3.23.19, News-3.23.18, News-3.23.20, News-3.23.x
 @appendixsubsec Changes in release 3.23.19
+
 @itemize @bullet
 @item
 Changed copyright for all files to GPL for the server code and utilities and
@@ -47803,8 +47836,10 @@ Fixed core dump bug when using @code{ORDER BY} on a @code{CONV()} expression.
 @item Fixed big/little endian problem in the replication
 @end itemize
 
+
 @node News-3.23.18, News-3.23.17, News-3.23.19, News-3.23.x
 @appendixsubsec Changes in release 3.23.18
+
 @itemize @bullet
 @item
 Fixed a problem from 3.23.17 when choosing character set on the client side.
@@ -47823,8 +47858,10 @@ Fixed a problem when locking the same table with both a @code{READ} and a
 Fixed problem with myisamchk and @code{RAID} tables.
 @end itemize
 
+
 @node News-3.23.17, News-3.23.16, News-3.23.18, News-3.23.x
 @appendixsubsec Changes in release 3.23.17
+
 @itemize @bullet
 @item
 Fixed a bug in @code{find_in_set()} when the first argument was @code{NULL}.
@@ -47880,8 +47917,10 @@ Fixed a race condition in @code{INSERT DELAYED} code when doing
 Added deadlock detection sanity checks to @code{INSERT DELAYED}
 @end itemize
 
+
 @node News-3.23.16, News-3.23.15, News-3.23.17, News-3.23.x
 @appendixsubsec Changes in release 3.23.16
+
 @itemize @bullet
 @item
 Added option @code{TYPE=QUICK} to @code{CHECK} and @code{REPAIR}.
@@ -47909,8 +47948,10 @@ restrict which databases get replicated
 Added @code{SQL_LOG_BIN} option
 @end itemize
 
+
 @node News-3.23.15, News-3.23.14, News-3.23.16, News-3.23.x
 @appendixsubsec Changes in release 3.23.15
+
 @itemize @bullet
 @item
 To start @code{mysqld} as @code{root}, you must now use the @code{--user=root} option.
@@ -47979,8 +48020,10 @@ Changed @code{RAID_CHUNKSIZE} to be in 1024 byte increments.
 Fixed coredump in LOAD_FILE(NULL).
 @end itemize
 
+
 @node News-3.23.14, News-3.23.13, News-3.23.15, News-3.23.x
 @appendixsubsec Changes in release 3.23.14
+
 @itemize @bullet
 @item
 Fixed a bug in @code{CONCAT()} where one of the arguments was a function
@@ -48025,8 +48068,10 @@ When running in ANSI mode, don't allow columns to be used that aren't in
 the @code{GROUP BY} part.
 @end itemize
 
+
 @node News-3.23.13, News-3.23.12, News-3.23.14, News-3.23.x
 @appendixsubsec Changes in release 3.23.13
+
 @itemize @bullet
 @item
 Fixed problem when doing locks on the same table more than 2 times in
@@ -48051,8 +48096,10 @@ Added @code{print_defaults} to the @file{.rpm} files. Removed @code{mysqlbug}
 from the client @file{.rpm} file.
 @end itemize
 
+
 @node News-3.23.12, News-3.23.11, News-3.23.13, News-3.23.x
 @appendixsubsec Changes in release 3.23.12
+
 @itemize @bullet
 @item
 Fixed bug in @code{MyISAM} involving @code{REPLACE ... SELECT ...} which could
@@ -48098,8 +48145,10 @@ join parameters in @code{SELECT}.
 @code{DELETE} and @code{RENAME} should now work on @code{RAID} tables.
 @end itemize
 
+
 @node News-3.23.11, News-3.23.10, News-3.23.12, News-3.23.x
 @appendixsubsec Changes in release 3.23.11
+
 @itemize @bullet
 @item
 Allow the @code{ALTER TABLE tbl_name ADD (field_list)} syntax.
@@ -48145,16 +48194,20 @@ Added back blocking of @code{SIGPIPE} when compiling with @code{--thread-safe-cl
 to make things safe for old clients.
 @end itemize
 
+
 @node News-3.23.10, News-3.23.9, News-3.23.11, News-3.23.x
 @appendixsubsec Changes in release 3.23.10
+
 @itemize @bullet
 @item
 Fixed bug in 3.23.9 where memory wasn't properly freed when doing
 @code{LOCK TABLES}.
 @end itemize
 
+
 @node News-3.23.9, News-3.23.8, News-3.23.10, News-3.23.x
 @appendixsubsec Changes in release 3.23.9
+
 @itemize @bullet
 @item
 Fixed problem that affected queries that did arithmetic on group functions.
@@ -48214,8 +48267,10 @@ when @code{key_column} could contain @code{NULL} values.
 Fixed problem with 8-bit characters as separators in @code{LOAD DATA INFILE}.
 @end itemize
 
+
 @node News-3.23.8, News-3.23.7, News-3.23.9, News-3.23.x
 @appendixsubsec Changes in release 3.23.8
+
 @itemize @bullet
 @item
 Fixed problem when handling indexfiles larger than 8G.
@@ -48252,8 +48307,10 @@ Fixed core dump if you got a crashed table where an @code{ENUM} field value
 was too big.
 @end itemize
 
+
 @node News-3.23.7, News-3.23.6, News-3.23.8, News-3.23.x
 @appendixsubsec Changes in release 3.23.7
+
 @itemize @bullet
 @item
 Fixed workaround under Linux to avoid problems with @code{pthread_mutex_timedwait},
@@ -48307,6 +48364,7 @@ Changed the argument to @code{mysql_data_seek()} from @code{ulong} to
 @code{ulonglong}.
 @end itemize
 
+
 @node News-3.23.6, News-3.23.5, News-3.23.7, News-3.23.x
 @appendixsubsec Changes in release 3.23.6
 
@@ -48362,6 +48420,7 @@ Changed function @code{CHAR_LENGTH()} to be multi-byte character safe.
 Added function @code{ORD(string)}.
 @end itemize
 
+
 @node News-3.23.5, News-3.23.4, News-3.23.6, News-3.23.x
 @appendixsubsec Changes in release 3.23.5
 
@@ -48421,6 +48480,7 @@ Added bit operator @code{~} (negation).
 Fixed problem with @code{UDF} functions.
 @end itemize
 
+
 @node News-3.23.4, News-3.23.3, News-3.23.5, News-3.23.x
 @appendixsubsec Changes in release 3.23.4
 
@@ -48457,6 +48517,7 @@ Some configure issues to fix problems with big file system detection.
 @code{REGEXP} is now case insensitive if you use non-binary strings.
 @end itemize
 
+
 @node News-3.23.3, News-3.23.2, News-3.23.4, News-3.23.x
 @appendixsubsec Changes in release 3.23.3
 
@@ -48498,6 +48559,7 @@ Added @code{CASE} construct.
 New function @code{COALESCE()}.
 @end itemize
 
+
 @node News-3.23.2, News-3.23.1, News-3.23.3, News-3.23.x
 @appendixsubsec Changes in release 3.23.2
 
@@ -48564,6 +48626,7 @@ New functions @code{EXPORT_SET()} and @code{MD5()}.
 Support for the GB2312 Chinese character set.
 @end itemize
 
+
 @node News-3.23.1, News-3.23.0, News-3.23.2, News-3.23.x
 @appendixsubsec Changes in release 3.23.1
 
@@ -48572,6 +48635,7 @@ Support for the GB2312 Chinese character set.
 Fixed some compilation problems.
 @end itemize
 
+
 @node News-3.23.0,  , News-3.23.1, News-3.23.x
 @appendixsubsec Changes in release 3.23.0
 
@@ -48718,9 +48782,12 @@ New @code{CREATE TABLE} options: @code{PACK_KEYS} and @code{CHECKSUM}.
 Added @code{mysqld} option @code{--default-table-type}.
 @end itemize
 
+
 @node News-3.22.x, News-3.21.x, News-3.23.x, News
 @appendixsec Changes in release 3.22.x (Older; Still supported)
 
+@cindex changes, version 3.22
+
 The 3.22 version has faster and safer connect code than version 3.21, as well
 as a lot of new nice enhancements.  The reason for not including these changes
 As there aren't really any MAJOR changes, upgrading from 3.21 to 3.22 should
@@ -48765,8 +48832,10 @@ be very easy and painless.  @xref{Upgrading-from-3.21}.
 * News-3.22.0::                 Changes in release 3.22.0
 @end menu
 
+
 @node News-3.22.35, News-3.22.34, News-3.22.x, News-3.22.x
 @appendixsubsec Changes in release 3.22.35
+
 @itemize @bullet
 @item
 Fixed problem with @code{STD()}.
@@ -48779,8 +48848,10 @@ Fixed a bug core dump when using a @code{LEFT JOIN}/@code{STRAIGHT_JOIN}
 on a table with only one row.
 @end itemize
 
+
 @node News-3.22.34, News-3.22.33, News-3.22.35, News-3.22.x
 @appendixsubsec Changes in release 3.22.34
+
 @itemize @bullet
 @item
 Fixed problem with @code{GROUP BY} on @code{TINYBLOB} columns;  This
@@ -48790,8 +48861,10 @@ Had to do total recompile of the Windows binary version as VC++ didn't
 compile all relevant files for 3.22.33 :(
 @end itemize
 
+
 @node News-3.22.33, News-3.22.32, News-3.22.34, News-3.22.x
 @appendixsubsec Changes in release 3.22.33
+
 @itemize @bullet
 @item
 Fixed problems in Windows when locking tables with @code{LOCK TABLE}
@@ -48799,8 +48872,10 @@ Fixed problems in Windows when locking tables with @code{LOCK TABLE}
 Quicker kill of @code{SELECT DISTINCT} queries.
 @end itemize
 
+
 @node News-3.22.32, News-3.22.31, News-3.22.33, News-3.22.x
 @appendixsubsec Changes in release 3.22.32
+
 @itemize @bullet
 @item
 Fixed problem when storing numbers in timestamps.
@@ -48820,6 +48895,7 @@ Fixed a bug in the @code{ISAM} code when deleting rows on tables with
 packed indexes.
 @end itemize
 
+
 @node News-3.22.31, News-3.22.30, News-3.22.32, News-3.22.x
 @appendixsubsec Changes in release 3.22.31
 
@@ -48846,6 +48922,7 @@ Fixed critical problem with the @code{WITH GRANT OPTION} option.
 Fixed non-critical Y2K problem when writing short date to log files.
 @end itemize
 
+
 @node News-3.22.29, News-3.22.28, News-3.22.30, News-3.22.x
 @appendixsubsec Changes in release 3.22.29
 
@@ -48872,9 +48949,9 @@ distribution.
 Fixed problem when doing @code{ORDER BY} on a reference key.
 @item
 Fixed that @code{INSERT DELAYED} doesn't update timestamps that are given.
-
 @end itemize
 
+
 @node News-3.22.28, News-3.22.27, News-3.22.29, News-3.22.x
 @appendixsubsec Changes in release 3.22.28
 
@@ -48888,6 +48965,7 @@ Fixed core dump problem when using @code{CONCAT()} in a @code{WHERE} clause.
 Fixed problem with @code{AVG()} and @code{STD()} with @code{NULL} values.
 @end itemize
 
+
 @node News-3.22.27, News-3.22.26, News-3.22.28, News-3.22.x
 @appendixsubsec Changes in release 3.22.27
 
@@ -48902,6 +48980,7 @@ Fixed problem when sorting on big blob columns.
 @code{ROUND()} will now work on Windows.
 @end itemize
 
+
 @node News-3.22.26, News-3.22.25, News-3.22.27, News-3.22.x
 @appendixsubsec Changes in release 3.22.26
 
@@ -48929,6 +49008,7 @@ Fixed range optimizer bug in
 Fixed bug in compression key handling in ISAM.
 @end itemize
 
+
 @node News-3.22.25, News-3.22.24, News-3.22.26, News-3.22.x
 @appendixsubsec Changes in release 3.22.25
 
@@ -48937,6 +49017,7 @@ Fixed bug in compression key handling in ISAM.
 Fixed some small problems with the installation.
 @end itemize
 
+
 @node News-3.22.24, News-3.22.23, News-3.22.25, News-3.22.x
 @appendixsubsec Changes in release 3.22.24
 
@@ -48956,6 +49037,7 @@ Changed @file{configure} to not use big file handling on Linux as this
 crashes some RedHat 6.0 systems
 @end itemize
 
+
 @node News-3.22.23, News-3.22.22, News-3.22.24, News-3.22.x
 @appendixsubsec Changes in release 3.22.23
 
@@ -48983,6 +49065,7 @@ Fixed @code{isamchk} to detect a new error condition.
 Fixed bug in @code{NATURAL LEFT JOIN}.
 @end itemize
 
+
 @node News-3.22.22, News-3.22.21, News-3.22.23, News-3.22.x
 @appendixsubsec Changes in release 3.22.22
 
@@ -49008,6 +49091,7 @@ with VC++ 5.0.
 New installation setup for MySQL-Windows.
 @end itemize
 
+
 @node News-3.22.21, News-3.22.20, News-3.22.22, News-3.22.x
 @appendixsubsec Changes in release 3.22.21
 
@@ -49032,6 +49116,7 @@ Changed to use @code{TCP_NODELAY} also on Linux (Should give faster TCP/IP
 connections).
 @end itemize
 
+
 @node News-3.22.20, News-3.22.19, News-3.22.21, News-3.22.x
 @appendixsubsec Changes in release 3.22.20
 
@@ -49044,6 +49129,7 @@ The update log didn't have newlines on some operating systems.
 @code{INSERT DELAYED} had some garbage at end in the update log.
 @end itemize
 
+
 @node News-3.22.19, News-3.22.18, News-3.22.20, News-3.22.x
 @appendixsubsec Changes in release 3.22.19
 
@@ -49057,6 +49143,7 @@ Fixed problem with queries that needed temporary tables with @code{BLOB}
 columns.
 @end itemize
 
+
 @node News-3.22.18, News-3.22.17, News-3.22.19, News-3.22.x
 @appendixsubsec Changes in release 3.22.18
 
@@ -49073,6 +49160,7 @@ Fixed problem that a @code{VARCHAR} column compared with @code{CHAR} column
 didn't use keys efficiently.
 @end itemize
 
+
 @node News-3.22.17, News-3.22.16, News-3.22.18, News-3.22.x
 @appendixsubsec Changes in release 3.22.17
 
@@ -49087,6 +49175,7 @@ Using @code{LEFT JOIN} on tables that had circular dependencies caused
 @code{mysqld} to hang forever.
 @end itemize
 
+
 @node News-3.22.16, News-3.22.15, News-3.22.17, News-3.22.x
 @appendixsubsec Changes in release 3.22.16
 
@@ -49109,6 +49198,7 @@ platforms, this function is written in optimized assembler.
 Added the @code{MODIFY} keyword to @code{ALTER TABLE}.
 @end itemize
 
+
 @node News-3.22.15, News-3.22.14, News-3.22.16, News-3.22.x
 @appendixsubsec Changes in release 3.22.15
 
@@ -49149,6 +49239,7 @@ name as an alias.
 Added @code{BENCHMARK(loop_count,expression)} function to time expressions.
 @end itemize
 
+
 @node News-3.22.14, News-3.22.13, News-3.22.15, News-3.22.x
 @appendixsubsec Changes in release 3.22.14
 
@@ -49176,6 +49267,7 @@ work with pipes on Windows.
 support aggregate UDF functions in future MySQL releases.
 @end itemize
 
+
 @node News-3.22.13, News-3.22.12, News-3.22.14, News-3.22.x
 @appendixsubsec Changes in release 3.22.13
 
@@ -49193,6 +49285,7 @@ Changed the implementation of @code{pthread_cond()} on the Windows version.
 @code{get_lock()} now correctly times out on Windows!
 @end itemize
 
+
 @node News-3.22.12, News-3.22.11, News-3.22.13, News-3.22.x
 @appendixsubsec Changes in release 3.22.12
 
@@ -49230,6 +49323,7 @@ without quotes in the context of the @code{GRANT}, @code{REVOKE} and
 Fix for @code{isamchk} for tables which need big temporary files.
 @end itemize
 
+
 @node News-3.22.11, News-3.22.10, News-3.22.12, News-3.22.x
 @appendixsubsec Changes in release 3.22.11
 
@@ -49276,6 +49370,7 @@ work as expected.
 New function @code{MAKE_SET()}.
 @end itemize
 
+
 @node News-3.22.10, News-3.22.9, News-3.22.11, News-3.22.x
 @appendixsubsec Changes in release 3.22.10
 
@@ -49333,6 +49428,7 @@ Added @code{extended-status} command to @code{mysqladmin} which will show the
 new status variables.
 @end itemize
 
+
 @node News-3.22.9, News-3.22.8, News-3.22.10, News-3.22.x
 @appendixsubsec Changes in release 3.22.9
 
@@ -49366,6 +49462,7 @@ This will flush all tables to disk after each update.  This makes things
 much safer on NT/Win98 but also @strong{MUCH} slower.
 @end itemize
 
+
 @node News-3.22.8, News-3.22.7, News-3.22.9, News-3.22.x
 @appendixsubsec Changes in release 3.22.8
 
@@ -49406,6 +49503,7 @@ log file.
 Added patches for UNIXWARE 7.
 @end itemize
 
+
 @node News-3.22.7, News-3.22.6, News-3.22.8, News-3.22.x
 @appendixsubsec Changes in release 3.22.7
 
@@ -49452,6 +49550,7 @@ The lexical analyzer now uses ``perfect hashing'' for faster parsing of SQL
 statements.
 @end itemize
 
+
 @node News-3.22.6, News-3.22.5, News-3.22.7, News-3.22.x
 @appendixsubsec Changes in release 3.22.6
 
@@ -49471,6 +49570,7 @@ MySQL-NT can now use named pipes, which means that you can now use
 MySQL-NT without having to install TCP/IP.
 @end itemize
 
+
 @node News-3.22.5, News-3.22.4, News-3.22.6, News-3.22.x
 @appendixsubsec Changes in release 3.22.5
 
@@ -49586,6 +49686,7 @@ Lots of new benchmarks.
 A new C API chapter and lots of other improvements in the manual.
 @end itemize
 
+
 @node News-3.22.4, News-3.22.3, News-3.22.5, News-3.22.x
 @appendixsubsec Changes in release 3.22.4
 
@@ -49637,6 +49738,7 @@ Changed name of user-specific configuration file from @file{my.cnf} to
 Added @code{DATE_ADD()} and @code{DATE_SUB()} functions.
 @end itemize
 
+
 @node News-3.22.3, News-3.22.2, News-3.22.4, News-3.22.x
 @appendixsubsec Changes in release 3.22.3
 
@@ -49651,6 +49753,7 @@ Added @code{--compress} option to all MySQL clients.
 Changed @code{byte} to @code{char} in @file{mysql.h} and @file{mysql_com.h}.
 @end itemize
 
+
 @node News-3.22.2, News-3.22.1, News-3.22.3, News-3.22.x
 @appendixsubsec Changes in release 3.22.2
 
@@ -49693,6 +49796,7 @@ The server/client protocol now supports compression.
 All bug fixes from MySQL Version 3.21.32.
 @end itemize
 
+
 @node News-3.22.1, News-3.22.0, News-3.22.2, News-3.22.x
 @appendixsubsec Changes in release 3.22.1
 
@@ -49732,6 +49836,7 @@ Fixed incorrect result from @code{FORMAT(-100,2)}.
 fashion; changed to be case insensitive.
 @end itemize
 
+
 @node News-3.22.0,  , News-3.22.1, News-3.22.x
 @appendixsubsec Changes in release 3.22.0
 
@@ -49841,9 +49946,12 @@ Added @code{--enable-assembler} option to @code{configure}, for x86 machines
 most important string functions for more speed!
 @end itemize
 
+
 @node News-3.21.x, News-3.20.x, News-3.22.x, News
 @appendixsec Changes in release 3.21.x
 
+@cindex changes, version 3.21
+
 Version 3.21 is quite old now, and should be avoided if possible.  This
 information is kept here for historical purposes only.
 
@@ -49885,6 +49993,7 @@ information is kept here for historical purposes only.
 * News-3.21.0::                 Changes in release 3.21.0
 @end menu
 
+
 @node News-3.21.33, News-3.21.32, News-3.21.x, News-3.21.x
 @appendixsubsec Changes in release 3.21.33
 
@@ -49902,6 +50011,7 @@ avoid race conditions.
 @code{INSERT INTO TABLE (timestamp_column) VALUES (NULL);} didn't set timestamp.
 @end itemize
 
+
 @node News-3.21.32, News-3.21.31, News-3.21.33, News-3.21.x
 @appendixsubsec Changes in release 3.21.32
 
@@ -49932,8 +50042,10 @@ Fixed a bug in the range optimizer that wrote
 @code{Use_count: Wrong count for ...} in the error log file.
 @end itemize
 
+
 @node News-3.21.31, News-3.21.30, News-3.21.32, News-3.21.x
 @appendixsubsec Changes in release 3.21.31
+
 @itemize @bullet
 @item
 Fixed a sign extension problem for the @code{TINYINT} type on Irix.
@@ -49950,8 +50062,10 @@ Fixed problems with @code{DATE_FORMAT()} and incorrect dates.
 it more easily in the future.
 @end itemize
 
+
 @node News-3.21.30, News-3.21.29, News-3.21.31, News-3.21.x
 @appendixsubsec Changes in release 3.21.30
+
 @itemize @bullet
 @item
 @code{mysql} now returns an exit code > 0 if the query returned an error.
@@ -49997,8 +50111,10 @@ When comparing a field = field, where one of the fields was a part key,
 only the length of the part key was compared.
 @end itemize
 
+
 @node News-3.21.29, News-3.21.28, News-3.21.30, News-3.21.x
 @appendixsubsec Changes in release 3.21.29
+
 @itemize @bullet
 @item
 @code{LOCK TABLES} + @code{DELETE from tbl_name} never removed locks properly.
@@ -50019,8 +50135,10 @@ Fixed bug on Alpha when using integer keys. (Other keys worked on Alpha).
 Fixed bug in @code{WEEK("XXXX-xx-01")}.
 @end itemize
 
+
 @node News-3.21.28, News-3.21.27, News-3.21.29, News-3.21.x
 @appendixsubsec Changes in release 3.21.28
+
 @itemize @bullet
 @item
 Fixed socket permission (clients couldn't connect to Unix socket on Linux).
@@ -50029,8 +50147,10 @@ Fixed bug in record caches; for some queries, you could get
 @code{Error from table handler: #} on some operating systems.
 @end itemize
 
+
 @node News-3.21.27, News-3.21.26, News-3.21.28, News-3.21.x
 @appendixsubsec Changes in release 3.21.27
+
 @itemize @bullet
 @item
 Added user level lock functions @code{GET_LOCK(string,timeout)},
@@ -50061,8 +50181,10 @@ Ignore users with old (8-byte) password on startup if not using
 case of the matched values, not of the found values. (Minor problem.)
 @end itemize
 
+
 @node News-3.21.26, News-3.21.25, News-3.21.27, News-3.21.x
 @appendixsubsec Changes in release 3.21.26
+
 @itemize @bullet
 @item
 @code{FROM_DAYS(0)} now returns "0000-00-00".
@@ -50088,8 +50210,10 @@ Added a retry loop around @code{accept()} to possibly fix some problems on some
 Linux machines.
 @end itemize
 
+
 @node News-3.21.25, News-3.21.24, News-3.21.26, News-3.21.x
 @appendixsubsec Changes in release 3.21.25
+
 @itemize @bullet
 @item
 Changed @code{typedef 'string'} to @code{typedef 'my_string'} for better
@@ -50106,8 +50230,10 @@ Affects @code{DISTINCT}, @code{ORDER BY} and @code{GROUP BY} on 64-bit
 processors.
 @end itemize
 
+
 @node News-3.21.24, News-3.21.23, News-3.21.25, News-3.21.x
 @appendixsubsec Changes in release 3.21.24
+
 @itemize @bullet
 @item
 Dynamic loadable functions. Based on source from Alexis Mikhailov.
@@ -50136,8 +50262,10 @@ support.
 Upgraded @code{DBI} to 0.93.
 @end itemize
 
+
 @node News-3.21.23, News-3.21.22, News-3.21.24, News-3.21.x
 @appendixsubsec Changes in release 3.21.23
+
 @itemize @bullet
 @item
 The following symbols are now reserved words:
@@ -50177,8 +50305,10 @@ All standard MySQL clients are now ported to MySQL-Windows.
 MySQL can now be started as a service on NT.
 @end itemize
 
+
 @node News-3.21.22, News-3.21.21a, News-3.21.23, News-3.21.x
 @appendixsubsec Changes in release 3.21.22
+
 @itemize @bullet
 @item
 Starting with this version, all MySQL distributions will be
@@ -50224,15 +50354,19 @@ Ported to OpenBSD 2.1.
 New Dutch error messages.
 @end itemize
 
+
 @node News-3.21.21a, News-3.21.21, News-3.21.22, News-3.21.x
 @appendixsubsec Changes in release 3.21.21a
+
 @itemize @bullet
 @item
 Configure changes for some operating systems.
 @end itemize
 
+
 @node News-3.21.21, News-3.21.20, News-3.21.21a, News-3.21.x
 @appendixsubsec Changes in release 3.21.21
+
 @itemize @bullet
 @item
 Fixed optimizer bug when using
@@ -50243,8 +50377,10 @@ Added command @code{SHOW STATUS}.
 Removed @file{manual.ps} from the source distribution to make it smaller.
 @end itemize
 
+
 @node News-3.21.20, News-3.21.19, News-3.21.21, News-3.21.x
 @appendixsubsec Changes in release 3.21.20
+
 @itemize @bullet
 @item
 Changed the maximum table name and column name lengths from 32 to 64.
@@ -50263,8 +50399,10 @@ Solaris 2.6: Fixed @code{configure} bugs and increased maximum table size
 from 2G to 4G.
 @end itemize
 
+
 @node News-3.21.19, News-3.21.18, News-3.21.20, News-3.21.x
 @appendixsubsec Changes in release 3.21.19
+
 @itemize @bullet
 @item
 Upgraded @code{DBD} to 1823. This version implements @code{mysql_use_result} in
@@ -50279,8 +50417,10 @@ Configure fixes (@file{Docs} directory).
 Added function @code{REVERSE()} (by Zeev Suraski).
 @end itemize
 
+
 @node News-3.21.18, News-3.21.17, News-3.21.19, News-3.21.x
 @appendixsubsec Changes in release 3.21.18
+
 @itemize @bullet
 @item
 Issue error message if client C functions are called in wrong order.
@@ -50304,8 +50444,10 @@ Fixed a couple of problems with the update log.
 @code{ORDER BY} was slow when used with key ranges.
 @end itemize
 
+
 @node News-3.21.17, News-3.21.16, News-3.21.18, News-3.21.x
 @appendixsubsec Changes in release 3.21.17
+
 @itemize @bullet
 @item
 Changed documentation string of @code{--with-unix-socket-path} to avoid
@@ -50336,6 +50478,7 @@ Optimized key block caching. This will be quicker than the old algorithm when
 using bigger key caches.
 @end itemize
 
+
 @node News-3.21.16, News-3.21.15, News-3.21.17, News-3.21.x
 @appendixsubsec Changes in release 3.21.16
 
@@ -50358,6 +50501,7 @@ Allow empty strings as default values for @code{BLOB} and @code{TEXT}, to
 be compatible with @code{mysqldump}.
 @end itemize
 
+
 @node News-3.21.15, News-3.21.14b, News-3.21.16, News-3.21.x
 @appendixsubsec Changes in release 3.21.15
 
@@ -50424,6 +50568,7 @@ Stack checking and @code{bison} memory overrun checking to make MySQL
 safer with weird queries.
 @end itemize
 
+
 @node News-3.21.14b, News-3.21.14a, News-3.21.15, News-3.21.x
 @appendixsubsec Changes in release 3.21.14b
 
@@ -50432,6 +50577,7 @@ safer with weird queries.
 Fixed a couple of small @code{configure} problems on some platforms.
 @end itemize
 
+
 @node News-3.21.14a, News-3.21.13, News-3.21.14b, News-3.21.x
 @appendixsubsec Changes in release 3.21.14a
 
@@ -50479,6 +50625,7 @@ Added lots of limit checks to make it safer when running with too little
 memory or when doing weird queries.
 @end itemize
 
+
 @node News-3.21.13, News-3.21.12, News-3.21.14a, News-3.21.x
 @appendixsubsec Changes in release 3.21.13
 
@@ -50507,6 +50654,7 @@ New multi-user test @file{tests/fork_test.pl} to put some strain on the
 thread library.
 @end itemize
 
+
 @node News-3.21.12, News-3.21.11, News-3.21.13, News-3.21.x
 @appendixsubsec Changes in release 3.21.12
 
@@ -50571,6 +50719,7 @@ that matches many rows.
 Added Russian error messages.
 @end itemize
 
+
 @node News-3.21.11, News-3.21.10, News-3.21.12, News-3.21.x
 @appendixsubsec Changes in release 3.21.11
 
@@ -50605,6 +50754,7 @@ Fixed problem with @code{ORDER BY}/@code{GROUP BY} because of bug in @code{gcc}.
 Fixed problem with @code{INSERT ... SELECT ... GROUP BY}.
 @end itemize
 
+
 @node News-3.21.10, News-3.21.9, News-3.21.11, News-3.21.x
 @appendixsubsec Changes in release 3.21.10
 
@@ -50634,6 +50784,7 @@ Fixed a couple of bugs in the range optimizer. Now the new range benchmark
 @code{test-select} works.
 @end itemize
 
+
 @node News-3.21.9, News-3.21.8, News-3.21.10, News-3.21.x
 @appendixsubsec Changes in release 3.21.9
 
@@ -50650,6 +50801,7 @@ Most things ported to FSU Pthreads, which should allow MySQL to
 run on SCO. @xref{SCO}.
 @end itemize
 
+
 @node News-3.21.8, News-3.21.7, News-3.21.9, News-3.21.x
 @appendixsubsec Changes in release 3.21.8
 
@@ -50695,6 +50847,7 @@ Added machine-dependent files for MIT-pthreads i386-SCO. There is probably
 more to do to get this to work on SCO 3.5.
 @end itemize
 
+
 @node News-3.21.7, News-3.21.6, News-3.21.8, News-3.21.x
 @appendixsubsec Changes in release 3.21.7
 
@@ -50715,6 +50868,7 @@ More information can be found in the @file{README} file!
 Fixed some problems when using very long, illegal names.
 @end itemize
 
+
 @node News-3.21.6, News-3.21.5, News-3.21.7, News-3.21.x
 @appendixsubsec Changes in release 3.21.6
 
@@ -50727,6 +50881,7 @@ defines).
 @code{accept()}.
 @end itemize
 
+
 @node News-3.21.5, News-3.21.4, News-3.21.6, News-3.21.x
 @appendixsubsec Changes in release 3.21.5
 
@@ -50747,6 +50902,7 @@ New function @code{SEC_TO_TIME(seconds)} which returns a string in
 New function @code{SUBSTRING_INDEX()}, originally by Zeev Suraski.
 @end itemize
 
+
 @node News-3.21.4, News-3.21.3, News-3.21.5, News-3.21.x
 @appendixsubsec Changes in release 3.21.4
 
@@ -50761,6 +50917,7 @@ Configuration and compilation on FreeBSD 3.0 works, but I couldn't get
 @code{pthread_create} to work.
 @end itemize
 
+
 @node News-3.21.3, News-3.21.2, News-3.21.4, News-3.21.x
 @appendixsubsec Changes in release 3.21.3
 
@@ -50819,6 +50976,7 @@ existed.
 Changed the default sort buffer size from 2M to 1M.
 @end itemize
 
+
 @node News-3.21.2, News-3.21.0, News-3.21.3, News-3.21.x
 @appendixsubsec Changes in release 3.21.2
 
@@ -50882,6 +51040,7 @@ Note: @code{some_field} is normally in the @code{SELECT} part. ANSI SQL should
 require it.
 @end itemize
 
+
 @node News-3.21.0,  , News-3.21.2, News-3.21.x
 @appendixsubsec Changes in release 3.21.0
 
@@ -50954,9 +51113,12 @@ mysql> SELECT * FROM tbl_name
 @end example
 @end itemize
 
+
 @node News-3.20.x, News-3.19.x, News-3.21.x, News
 @appendixsec Changes in release 3.20.x
 
+@cindex changes, version 3.20
+
 Version 3.20 is quite old now, and should be avoided if possible.  This
 information is kept here for historical purposes only.
 
@@ -50981,6 +51143,7 @@ documented as changes to the 3.21 version.
 * News-3.20.0::                 Changes in releases 3.20.0
 @end menu
 
+
 @node News-3.20.18, News-3.20.17, News-3.20.x, News-3.20.x
 @appendixsubsec Changes in release 3.20.18
 
@@ -51026,6 +51189,7 @@ When using overlapping (unnecessary) keys and join over many tables,
 the optimizer could get confused and return 0 records.
 @end itemize
 
+
 @node News-3.20.17, News-3.20.16, News-3.20.18, News-3.20.x
 @appendixsubsec Changes in release 3.20.17
 
@@ -51084,6 +51248,7 @@ number of type @code{YYYYMMDD} or @code{YYMMDD}.
 Added new function @code{UNIX_TIMESTAMP(timestamp_column)}.
 @end itemize
 
+
 @node News-3.20.16, News-3.20.15, News-3.20.17, News-3.20.x
 @appendixsubsec Changes in release 3.20.16
 
@@ -51112,6 +51277,7 @@ Added new latin2 and Russian KOI8 character tables.
 Added support for a dummy @code{GRANT} command to satisfy Powerbuilder.
 @end itemize
 
+
 @node News-3.20.15, News-3.20.14, News-3.20.16, News-3.20.x
 @appendixsubsec Changes in release 3.20.15
 
@@ -51135,6 +51301,7 @@ Fixed bug when doing a @code{SELECT} as superuser without a database.
 Fixed bug when doing @code{SELECT} with group calculation to outfile.
 @end itemize
 
+
 @node News-3.20.14, News-3.20.13, News-3.20.15, News-3.20.x
 @appendixsubsec Changes in release 3.20.14
 
@@ -51177,6 +51344,7 @@ Fixed a bug in @code{OR} of multiple tables (gave empty set).
 Added many patches to MIT-pthreads. This fixes at least one lookup bug.
 @end itemize
 
+
 @node News-3.20.13, News-3.20.11, News-3.20.14, News-3.20.x
 @appendixsubsec Changes in release 3.20.13
 
@@ -51216,6 +51384,7 @@ rows that determine this grant.
 Added @code{WHERE const op field} (by @email{bonis@@kiss.de}).
 @end itemize
 
+
 @node News-3.20.11, News-3.20.10, News-3.20.13, News-3.20.x
 @appendixsubsec Changes in release 3.20.11
 
@@ -51244,6 +51413,7 @@ Added sync of records count in @code{sql_update}. This fixed slow updates
 on first connection. (Thanks to Vaclav Bittner for the test.)
 @end itemize
 
+
 @node News-3.20.10, News-3.20.9, News-3.20.11, News-3.20.x
 @appendixsubsec Changes in release 3.20.10
 
@@ -51272,6 +51442,7 @@ Added @code{--without-perl} option to @code{configure}.
 Lots of small portability changes.
 @end itemize
 
+
 @node News-3.20.9, News-3.20.8, News-3.20.10, News-3.20.x
 @appendixsubsec Changes in release 3.20.9
 
@@ -51287,6 +51458,7 @@ Some compatibility changes for SunOS.
 Removed @file{config.cache} from old distribution.
 @end itemize
 
+
 @node News-3.20.8, News-3.20.7, News-3.20.9, News-3.20.x
 @appendixsubsec Changes in release 3.20.8
 
@@ -51295,6 +51467,7 @@ Removed @file{config.cache} from old distribution.
 Fixed bug with @code{ALTER TABLE} and multi-part keys.
 @end itemize
 
+
 @node News-3.20.7, News-3.20.6, News-3.20.8, News-3.20.x
 @appendixsubsec Changes in release 3.20.7
 
@@ -51330,6 +51503,7 @@ Added @code{-k} option to @code{mysqlshow}, to get key information for a table.
 Added long options to @code{mysqldump}.
 @end itemize
 
+
 @node News-3.20.6, News-3.20.3, News-3.20.7, News-3.20.x
 @appendixsubsec Changes in release 3.20.6
 
@@ -51414,6 +51588,7 @@ New math functions:
 @code{EXP()}, @code{LOG()}, @code{SQRT()}, @code{ROUND()}, @code{CEILING()}.
 @end itemize
 
+
 @node News-3.20.3, News-3.20.0, News-3.20.6, News-3.20.x
 @appendixsubsec Changes in release 3.20.3
 
@@ -51474,6 +51649,7 @@ For example, @code{'user('} is regarded as beginning a function call, and
 @code{'('}, not as a function call.
 @end itemize
 
+
 @node News-3.20.0,  , News-3.20.3, News-3.20.x
 @appendixsubsec Changes in release 3.20.0
 
@@ -51518,9 +51694,12 @@ A lot of small bug fixes done.
 New @file{INSTALL} files (not final version) and some information regarding porting.
 @end itemize
 
+
 @node News-3.19.x,  , News-3.20.x, News
 @appendixsec Changes in release 3.19.x
 
+@cindex changes, version 3.19
+
 Version 3.19 is quite old now, and should be avoided if possible.  This
 information is kept here for historical purposes only.
 
@@ -51530,6 +51709,7 @@ information is kept here for historical purposes only.
 * News-3.19.3::                 Changes in release 3.19.3
 @end menu
 
+
 @node News-3.19.5, News-3.19.4, News-3.19.x, News-3.19.x
 @appendixsubsec Changes in release 3.19.5
 
@@ -51553,6 +51733,7 @@ A group on one column and a sort on a group function (@code{SUM()},
 @code{mysqldump}: Didn't send password to server.
 @end itemize
 
+
 @node News-3.19.4, News-3.19.3, News-3.19.5, News-3.19.x
 @appendixsubsec Changes in release 3.19.4
 
@@ -51578,6 +51759,7 @@ Added functions @code{CEILING()}, @code{ROUND()}, @code{EXP()}, @code{LOG()} and
 Enhanced @code{BETWEEN} to handle strings.
 @end itemize
 
+
 @node News-3.19.3,  , News-3.19.4, News-3.19.x
 @appendixsubsec Changes in release 3.19.3
 
@@ -51598,10 +51780,13 @@ Fixed @code{DISTINCT} with calculated columns.
 
 
 
-@cindex porting, to other systems
-@node Porting, Regexp, News, Top
+
+
+@node Porting, Environment variables, News, Top
 @appendix Comments on porting to other systems
 
+@cindex porting, to other systems
+
 A working Posix thread library is needed for the server. On Solaris 2.5
 we use Sun PThreads (the native thread support in 2.4 and earlier
 versions are not good enough) and on Linux we use LinuxThreads by Xavier
@@ -51673,11 +51858,13 @@ will ensure that your thread installation has even a remote chance to work!
 * Thread packages::             Differences between different thread packages
 @end menu
 
+
+@node Debugging server, Debugging client, Porting, Porting
+@appendixsec Debugging a MySQL server
+
 @cindex server, debugging
 @cindex debugging, server
 @cindex crash
-@node Debugging server, Debugging client, Porting, Porting
-@appendixsec Debugging a MySQL server
 
 If you are using some functionality that is very new in MySQL,
 you can try to run @code{mysqld} with the @code{--skip-new} (which will disable all
@@ -51719,6 +51906,7 @@ problems that may be unique to your environment.
 * Reproduceable test case::     
 @end menu
 
+
 @node Compiling for debugging, Making trace files, Debugging server, Debugging server
 @appendixsubsec Compiling MYSQL for debugging.
 
@@ -51770,6 +51958,7 @@ MySQL version you are using!
 In the Windows MySQL distribution, @code{mysqld.exe} is by
 default compiled with support for trace files.
 
+
 @node Making trace files, Using gdb on mysqld, Compiling for debugging, Debugging server
 @appendixsubsec Creating trace files
 
@@ -51807,10 +51996,12 @@ developer can take a look a this.
 The trace file is made with the @strong{DBUG} package by Fred Fish.
 @xref{The DBUG package}.
 
-@cindex gdb, using
+
 @node Using gdb on mysqld, Using stack trace, Making trace files, Debugging server
 @appendixsubsec Debugging mysqld under gdb
 
+@cindex gdb, using
+
 On most system you can also start @code{mysqld} from @code{gdb} to get
 more information if @code{mysqld} crashes.
 
@@ -51889,6 +52080,7 @@ debugging information by using the @code{trace} method or by
 setting the @code{DBI_TRACE} environment variable.
 @xref{Perl DBI Class, , Perl @code{DBI} Class}.
 
+
 @node Using stack trace, Using log files, Using gdb on mysqld, Debugging server
 @appendixsubsec Using a stack trace
 
@@ -51957,6 +52149,7 @@ that killed @code{mysqld} and preferable a test case so that we can
 repeat the problem!  @xref{Bug reports}.
 @end enumerate
 
+
 @node Using log files, Reproduceable test case, Using stack trace, Debugging server
 @appendixsubsec Using log files to find cause of errors in mysqld
 
@@ -52008,6 +52201,7 @@ It's of course not a good sign if @code{mysqld} did died unexpectedly,
 but in this case one shouldn't investigate the @code{Checking table...} 
 messages but instead try to find out why @code{mysqld} died.
 
+
 @node Reproduceable test case,  , Using log files, Debugging server
 @appendixsubsec Making a test case when you experience table corruption
 
@@ -52056,11 +52250,13 @@ will fix it as soon as possible.
 You can also use the script @code{mysql_find_rows} to just execute some of the
 update statements if you want to narrow down the problem.
 
-@cindex debugging, client
-@cindex clients, debugging
+
 @node Debugging client, The DBUG package, Debugging server, Porting
 @appendixsec Debugging a MySQL client
 
+@cindex debugging, client
+@cindex clients, debugging
+
 To be able to debug a MySQL client with the integrated debug package,
 you should configure MySQL with @code{--with-debug}.
 @xref{configure options}.
@@ -52095,10 +52291,11 @@ A very common mistake is to use an old @file{mysql.h} file from an old
 MySQL installation with new MySQL library.
 
 
-@cindex DBUG package
 @node The DBUG package, Locking methods, Debugging client, Porting
 @appendixsec The DBUG package.
 
+@cindex DBUG package
+
 The MySQL server and most MySQL clients are compiled
 with the DBUG package originally made by Fred Fish.  When one has configured
 MySQL for debugging, this package makes it possible to get a trace
@@ -52162,11 +52359,13 @@ In MySQL, common tags to print (with the @code{d} option) are:
 @code{enter},@code{exit},@code{error},@code{warning},@code{info} and
 @code{loop}.
 
-@cindex locking methods
-@cindex methods, locking
+
 @node Locking methods, RTS-threads, The DBUG package, Porting
 @appendixsec Locking methods
 
+@cindex locking methods
+@cindex methods, locking
+
 Currently MySQL only supports table locking for
 @code{ISAM}/@code{MyISAM} and @code{HEAP} tables and page level locking
 for @code{BDB} tables. @xref{Internal locking}.  With @code{MyISAM}
@@ -52275,11 +52474,13 @@ may be able to solve these to convert some of your tables to @code{BDB} tables.
 The optimization section in the manual covers a lot of different aspects of
 how to tune ones application. @xref{Tips}.
 
-@cindex RTS-threads
-@cindex threads, RTS
+
 @node RTS-threads, Thread packages, Locking methods, Porting
 @appendixsec Comments about RTS threads
 
+@cindex RTS-threads
+@cindex threads, RTS
+
 I have tried to use the RTS thread packages with MySQL but
 stumbled on the following problems:
 
@@ -52371,10 +52572,12 @@ end
 @end example
 @end itemize
 
-@cindex thread packages, differences between
+
 @node Thread packages,  , RTS-threads, Porting
 @appendixsec Differences between different thread packages
 
+@cindex thread packages, differences between
+
 MySQL is very dependent on the thread package used. So when
 choosing a good platform for MySQL, the thread package is very
 important.
@@ -52419,11 +52622,99 @@ level threads in the system libraries. In such cases, the thread
 switching can only be done by the thread library and the kernel isn't
 really ``thread aware''.
 
+
+
+
+@node Environment variables, Regexp, Porting, Top
+@appendix  Environment Variables
+
+@cindex environment variables, list of
+
+Here is a list of all the environment variables that are used directly or
+indirectly by MySQL. Most of these can also be found in other
+places in this manual.
+
+Note that any options on the command line will take precedence over
+values specified in configuration files and environment variables, and
+values in configuration files take precedence over values in environment
+variables.
+
+In many cases it's preferable to use a configure file instead of environment
+variables to modify the behavior of MySQL. @xref{Option files}.
+
+@tindex CCX environment variable
+@tindex Environment variable, CCX
+@tindex CC environment variable
+@tindex Environment variable, CC
+@tindex CFLAGS environment variable
+@tindex Environment variable, CFLAGS
+@tindex CXXFLAGS environment variable
+@tindex Environment variable, CXXFLAGS
+@tindex DBI_USER environment variable
+@tindex Environment variable, DBI_USER
+@tindex DBI_TRACE environment variable
+@tindex Environment variable, DBI_TRACE
+@tindex HOME environment variable
+@tindex Environment variable, HOME
+@tindex LD_RUN_PATH environment variable
+@tindex Environment variable, LD_RUN_PATH
+@tindex MYSQL_DEBUG environment variable
+@tindex Environment variable, MYSQL_DEBUG
+@tindex MYSQL_HISTFILE environment variable
+@tindex Environment variable, MYSQL_HISTFILE
+@tindex MYSQL_HOST environment variable
+@tindex Environment variable, MYSQL_HOST
+@tindex MYSQL_PWD environment variable
+@tindex Environment variable, MYSQL_PWD
+@tindex MYSQL_TCP_PORT environment variable
+@tindex Environment variable, MYSQL_TCP_PORT
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex Environment variable, MYSQL_UNIX_PORT
+@tindex PATH environment variable
+@tindex Environment variable, PATH
+@tindex TMPDIR environment variable
+@tindex Environment variable, TMPDIR
+@tindex TZ environment variable
+@tindex Environment variable, TZ
+@tindex UMASK_DIR environment variable
+@tindex Environment variable, UMASK_DIR
+@tindex UMASK environment variable
+@tindex Environment variable, UMASK
+@tindex USER environment variable
+@tindex Environment variable, USER
+
+@multitable @columnfractions .2 .8
+@item @code{CCX}  @tab Set this to your C++ compiler when running configure.
+@item @code{CC}  @tab Set this to your C compiler when running configure.
+@item @code{CFLAGS} @tab Flags for your C compiler when running configure.
+@item @code{CXXFLAGS} @tab Flags for your C++ compiler when running configure.
+@item @code{DBI_USER} @tab The default user name for Perl DBI.
+@item @code{DBI_TRACE} @tab Used when tracing Perl DBI.
+@item @code{HOME} @tab The default path for the @code{mysql} history file is @file{$HOME/.mysql_history}.
+@item @code{LD_RUN_PATH} @tab Used to specify where your @code{libmysqlclient.so} is.
+@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging.
+@item @code{MYSQL_HISTFILE} @tab The path to the @code{mysql} history file.
+@item @code{MYSQL_HOST} @tab Default host name used by the @code{mysql} command-line prompt.
+@item @code{MYSQL_PWD} @tab The default password when connecting to @code{mysqld}. Note that use of this is insecure!
+@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port.
+@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}.
+@item @code{PATH} @tab Used by the shell to finds the MySQL programs.
+@item @code{TMPDIR} @tab The directory where temporary tables/files are created.
+@item @code{TZ} @tab This should be set to your local time zone. @xref{Timezone problems}.
+@item @code{UMASK_DIR} @tab The user-directory creation mask when creating directories. Note that this is ANDed with @code{UMASK}!
+@item @code{UMASK} @tab The user-file creation mask when creating files.
+@item @code{USER} @tab The default user on Windows to use when connecting to @code{mysqld}.
+@end multitable
+
+
+
+
+@node Regexp, Unireg, Environment variables, Top
+@appendix Description of MySQL regular expression syntax
+
 @cindex regex
 @cindex regular expression syntax, described
 @cindex syntax, regular expression
-@node Regexp, Unireg, Porting, Top
-@appendix Description of MySQL regular expression syntax
 
 A regular expression (regex) is a powerful way of specifying a complex search.
 
@@ -52602,11 +52893,15 @@ mysql> select "a xword a" REGEXP "[[:<:]]word[[:>:]]";     -> 0
 mysql> select "weeknights" REGEXP "^(wee|week)(knights|nights)$"; -> 1
 @end example
 
-@cindex Unireg, described
-@cindex interface builder
+
+
+
 @node Unireg, GPL license, Regexp, Top
 @appendix What is Unireg?
 
+@cindex Unireg, described
+@cindex interface builder
+
 Unireg is our tty interface builder, but it uses a low-level connection
 to our ISAM (which is used by MySQL) and because of this it is
 very quick. It has existed since 1979 (on Unix in C since ~1986).
@@ -52669,6 +52964,8 @@ All new development is concentrated to MySQL.
 @page
 @c This node name is special
 
+
+
 @node GPL license, LGPL license, Unireg, Top
 @appendix GNU GENERAL PUBLIC LICENSE
 
@@ -53067,6 +53364,9 @@ Public License instead of this License.
 
 @page
 
+
+
+
 @node LGPL license, Placeholder, GPL license, Top
 @appendix GNU LESSER GENERAL PUBLIC LICENSE
 
@@ -53636,6 +53936,8 @@ Ty Coon, President of Vice
 That's all there is to it!
 
 
+
+
 @node Placeholder, Function Index, LGPL license, Top
 @appendix Pieces of the manual in transit
 
@@ -53645,6 +53947,7 @@ That's all there is to it!
 * Group by functions::          
 @end menu
 
+
 @node Installing binary, Perl support, Placeholder, Placeholder
 @appendixsec Installing a MySQL Binary Distribution
 
@@ -53880,6 +54183,7 @@ shell> bin/safe_mysqld --user=mysql &
 * Perl support problems::       Problems using the Perl @code{DBI}/@code{DBD} interface
 @end menu
 
+
 @node Perl installation, ActiveState Perl, Perl support, Perl support
 @appendixsubsec Installing Perl on Unix
 
@@ -53951,6 +54255,7 @@ you:
 Look under the heading
 @code{Installing New Modules that Require Locally Installed Modules}.
 
+
 @node ActiveState Perl, Windows Perl, Perl installation, Perl support
 @appendixsubsec Installing ActiveState Perl on Windows
 
@@ -54011,6 +54316,7 @@ $dbh= DBI->connect("DBI:ODBC:$dsn","$user","$password") ||
   die "Got error $DBI::errstr when connecting to $dsn\n";
 @end example
 
+
 @node Windows Perl, Perl support problems, ActiveState Perl, Perl support
 @appendixsubsec Installing the MySQL Perl Distribution on Windows
 
@@ -54036,11 +54342,13 @@ Add the directory @file{C:\PERL\BIN\MSWIN32-x86-thread} or
 Test that @code{perl} works by executing @code{perl -v} in a DOS shell.
 @end itemize
 
-@cindex problems, installing Perl
-@cindex Perl DBI/DBD, installation problems
+
 @node Perl support problems,  , Windows Perl, Perl support
 @appendixsubsec Problems Using the Perl @code{DBI}/@code{DBD} Interface
 
+@cindex problems, installing Perl
+@cindex Perl DBI/DBD, installation problems
+
 If Perl reports that it can't find the @file{../mysql/mysql.so} module,
 then the problem is probably that Perl can't locate the shared library
 @file{libmysqlclient.so}.
@@ -54313,18 +54621,21 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
 @end example
 
 
-
-
-
 @node Function Index, Concept Index, Placeholder, Top
 @unnumbered SQL command, type and function index
 
 @printindex fn
 
 @page
+
+
 @node Concept Index,  , Function Index, Top
 @unnumbered Concept Index
 
 @printindex cp
 
+
+
+
+
 @bye

From 6ca8d50cb14ac9171f4e3cf29483c414c93710e8 Mon Sep 17 00:00:00 2001
From: unknown <sasha@mysql.sashanet.com>
Date: Thu, 16 Aug 2001 12:01:35 -0600
Subject: [PATCH 02/51] fixed bug in Item_func_div::val_int() that broke all
 functions that do val_int() on their arguments before starting the
 computation. Similar fixes are need for +-* and probably several other but I
 want to make sure Monty is fine with my fix approach before changing a lot of
 code.

Amazingly,
this bug is not as critical as you would expect since very few functions do val_int()
on their arguments ( from_unixtime(), sec_to_time()), and those not
very frequently perform a computation on their floating point arguments.
which is probably why no one has yet reported this bug. Another
possibility is that the result is usually wrong by no more than 5%,
which makes it hard to catch it. I found it when trying to compute mile
splits for 30:47 10K - it told me 5:07, and I knew it was wrong because
5:00 mile gives you 31:08. However, if I had not run as many 10K races,
I would have easily believed that 30:47 10K is a 5:07 mile pace and
would not have noticed the bug.


mysql-test/r/func_time.result:
  another test for sec_to_time that exposes a long outstanding bug
mysql-test/t/func_time.test:
  another test for sec_to_time that exposes a long outstanding bug
sql/item_func.cc:
  fixed bug in Item_func_div::val_int()
---
 mysql-test/r/func_time.result |  4 ++--
 mysql-test/t/func_time.test   |  3 ++-
 sql/item_func.cc              | 13 ++++++++-----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index fd7c6897574..790cce9f1c1 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -6,8 +6,8 @@ now()-now()	weekday(curdate())-weekday(now())	unix_timestamp()-unix_timestamp(no
 0	0	0
 from_unixtime(unix_timestamp("1994-03-02 10:11:12"))	from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s")	from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
 1994-03-02 10:11:12	1994-03-02 10:11:12	19940302101112
-sec_to_time(9001)	sec_to_time(9001)+0	time_to_sec("15:12:22")
-02:30:01	23001	54742
+sec_to_time(9001)	sec_to_time(9001)+0	time_to_sec("15:12:22")	sec_to_time(time_to_sec("0:30:47")/6.21)
+02:30:01	23001	54742	00:04:57
 now()-curdate()*1000000-curtime()
 0
 strcmp(current_timestamp(),concat(current_date()," ",current_time()))
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index a91844ab986..cb021d25ae3 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -7,7 +7,8 @@ select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(
 select period_add("9602",-12),period_diff(199505,"9404") ;
 select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
 select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
-select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22");
+select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
+  sec_to_time(time_to_sec("0:30:47")/6.21);
 select now()-curdate()*1000000-curtime();
 select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
 select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 10298ce67f2..1d1a72d35eb 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -309,11 +309,14 @@ double Item_func_div::val()
 
 longlong Item_func_div::val_int()
 {
-  longlong value=args[0]->val_int();
-  longlong val2=args[1]->val_int();
-  if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value))
-    return 0;
-  return value/val2;
+  // the integer result of division of two arguments needs to be computed
+  // as a type-cast division of val(), not as diviion of val_int() of each
+  // argument. For example, val_int(41.5/3.4) = val_int(12.206) = 12, but
+  // if you do val_int(41.5)/val_int(3.4), as in the old code, we get 42/3=
+  // 14, which is wrong. This would break sec_to_time(a/b),
+  // from_unixtime(a/b), and
+  // all functions that do val_int() on their arguments
+  return (longlong)val();
 }
 
 void Item_func_div::fix_length_and_dec()

From f26cd7da7203b1a1d68dc8b79ea6a899e4c4bbb0 Mon Sep 17 00:00:00 2001
From: unknown <mwagner@evoq.mwagner.org>
Date: Fri, 17 Aug 2001 06:12:36 -0500
Subject: [PATCH 03/51] manual.texi	Removed mirror in UK

Docs/manual.texi:
  Removed mirror in UK
---
 Docs/manual.texi | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index b594e296805..babb8d13427 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -6610,12 +6610,6 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
 @c @image{Flags/great-britain} UK [Oyster/UK] @
 @c @uref{ftp://ftp.oyster.co.uk/pub/mysql, FTP}
 
-@item
-@c EMAIL: gareth@omnipotent.net (Gareth Watts)
-@image{Flags/great-britain} UK [Omnipotent/UK] @
-@uref{http://mysql.omnipotent.net/, WWW}
-@uref{ftp://mysql.omnipotent.net/, FTP}
-
 @item
 @c EMAIL: keet@mordor.plig.net (Christiaan Keet)
 @image{Flags/great-britain} UK [PLiG/UK] @

From 0855ce419c44598348474c93d4b36bdc0050a023 Mon Sep 17 00:00:00 2001
From: unknown <mwagner@evoq.mwagner.org>
Date: Fri, 17 Aug 2001 06:14:56 -0500
Subject: [PATCH 04/51] manual.texi	Re-added sunet.se mirror

Docs/manual.texi:
  Re-added sunet.se mirror
---
 Docs/manual.texi | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index babb8d13427..63230319f0a 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -6590,13 +6590,12 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
 @c @image{Flags/spain} Spain [MasterD]
 @c @uref{http://mysql.masterd.es, WWW}
 
-@c @item
-@c Not ok 20000919; Old site (Matt)
+@item
 @c EMAIL: Patrik.Karen@sdi.slu.se (Patrik Karen)
 @c ftp -> remove old files
-@c @image{Flags/sweden} Sweden [Sunet] @
-@c @uref{http://ftp.sunet.se/pub/unix/databases/relational/mysql/, WWW}
-@c @uref{ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/, FTP}
+@image{Flags/sweden} Sweden [Sunet] @
+@uref{http://ftp.sunet.se/pub/unix/databases/relational/mysql/, WWW}
+@uref{ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/, FTP}
 
 @item
 @c EMAIL: archive@sunsite.cnlab-switch.ch (Thomas Lenggenhager)

From 57b1a50c811964b9cf772e070b5e813347ab74b1 Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Fri, 17 Aug 2001 21:19:10 +0300
Subject: [PATCH 05/51] ha_innobase.cc	Impove ref length estimate in a handle
 to eliminate a warning in filesort

sql/ha_innobase.cc:
  Impove ref length estimate in a handle to eliminate a warning in filesort
---
 sql/ha_innobase.cc | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index d0cb8af906a..babe281bd4e 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -821,10 +821,6 @@ ha_innobase::open(
 	  	DBUG_RETURN(1);
   	}
 
-  	/* MySQL allocates the buffer for ref */
-
-  	ref_length = buff_len;
-
 	/* Get pointer to a table object in InnoDB dictionary cache */
 
  	if (NULL == (ib_table = dict_table_get(norm_name, NULL))) {
@@ -861,10 +857,20 @@ ha_innobase::open(
 
 		primary_key = 0;
 		key_used_on_scan = 0;
+
+ 		/* MySQL allocates the buffer for ref */
+
+  		ref_length = table->key_info->key_length
+  				+ table->key_info->key_parts + 10;
+
+  		/* One byte per key field is consumed to the SQL NULL
+		info of the field; we add also 10 bytes of safety margin */
 	} else {
 		((row_prebuilt_t*)innobase_prebuilt)
 				->clust_index_was_generated = TRUE;
 
+  		ref_length = DATA_ROW_ID_LEN + 10;
+				
 		dbug_assert(key_used_on_scan == MAX_KEY);
 	}
 

From 3fac95eea110e6f8776cbb111f7e1bbc35dde737 Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Fri, 17 Aug 2001 22:00:04 +0300
Subject: [PATCH 06/51] manual.texi	Added a note that tablespace has to be
 >= 10 MB

Docs/manual.texi:
  Added a note that tablespace has to be >= 10 MB
---
 Docs/manual.texi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 63230319f0a..8c1bfefb060 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -36019,7 +36019,9 @@ set-variable = innodb_lock_wait_timeout=50
 @end example
 
 Note that data files must be < 4G, and < 2G on
-some file systems! InnoDB does not create directories:
+some file systems! The total size of data files have
+to be >= 10 MB.
+InnoDB does not create directories:
 you have to create them yourself.
 
 Suppose you have a Linux machine with 512 MB RAM and

From 857b5d4f43d4a55106ee621eb8e25d642e38a7f2 Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Fri, 17 Aug 2001 22:05:53 +0300
Subject: [PATCH 07/51] manual.texi	Fix typo

Docs/manual.texi:
  Fix typo
---
 Docs/manual.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 8c1bfefb060..19de9037f60 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -36019,7 +36019,7 @@ set-variable = innodb_lock_wait_timeout=50
 @end example
 
 Note that data files must be < 4G, and < 2G on
-some file systems! The total size of data files have
+some file systems! The total size of data files has
 to be >= 10 MB.
 InnoDB does not create directories:
 you have to create them yourself.

From 52391439cd6fa6ec0baaa112ea246459ebbfb8c9 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Fri, 17 Aug 2001 14:18:28 -0500
Subject: [PATCH 08/51] various cleanups

---
 Docs/manual.texi | 266 ++++++++++++++++++++++++++++-------------------
 1 file changed, 158 insertions(+), 108 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 596126a43aa..a126e377aff 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -7141,35 +7141,39 @@ factors:
 @item
 General stability of the thread library. A platform may have excellent
 reputation otherwise, but if the thread library is unstable in the code
-that is called by MySQL, even if
-everything else is perfect, MySQL will be only as stable as the
-thread library.
+that is called by MySQL, even if everything else is perfect, MySQL will
+be only as stable as the thread library.
+
 @item
 The ability of the kernel and/or thread library to take advantage of
-@strong{SMP} on
-multi-processor systems. In other words, when a process creates a thread, it
-should be possible for that thread to run on a different CPU than the original
-process.
+@strong{SMP} on multi-processor systems. In other words, when a process
+creates a thread, it should be possible for that thread to run on a different
+CPU than the original process.
+
 @item
 The ability of the kernel and/or the thread library to run many threads which
 acquire/release a mutex over a short critical region frequently without
 excessive context switches. In other words, if the implementation of
 @code{pthread_mutex_lock()} is too anxious to yield CPU, this will hurt
-MySQL tremendously. If this issue
-is not taken care of, adding extra CPUs will actually make MySQL
-slower.
+MySQL tremendously. If this issue is not taken care of, adding extra CPUs
+will actually make MySQL slower.
+
 @item
 General file system stability/performance.
+
 @item
 Ability of the file system to deal with large files at all and deal with them
 efficiently, if your tables are big.
+
 @item
 Our level of expertise here at MySQL AB with the platform. If we know
 a platform well, we introduce platform-specific optimizations/fixes enabled at
 compile time. We can also provide advice on configuring your system optimally
 for MySQL.
+
 @item
 The amount of testing of similar configurations we have done internally.
+
 @item
 The number of users that have successfully run MySQL on that
 platform in similar configurations. If this number is high, the chances of
@@ -7943,7 +7947,7 @@ shell> ./configure --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
 
 Note that the given file must be an absolute pathname!
 
-@cindex compiling statically
+@cindex compiling, statically
 @cindex statically, compiling
 @item
 If you want to compile statically linked programs (for example, to make a
@@ -7955,13 +7959,13 @@ shell> ./configure --with-client-ldflags=-all-static \
            --with-mysqld-ldflags=-all-static
 @end example
 
-@tindex CC environment variable
-@tindex environment variable, CC
-@tindex CXX environment variable
-@tindex environment variable, CXX
-@cindex gcc
-@cindex C++ complier, gcc
-@cindex compiler, C++ gcc
+@tindex @code{CC} environment variable
+@tindex environment variable, @code{CC}
+@tindex @code{CXX} environment variable
+@tindex environment variable, @code{CXX}
+@cindex @code{gcc}
+@cindex C++ compiler, @code{gcc}
+@cindex compiler, C++ @code{gcc}
 @item
 If you are using @code{gcc} and don't have @code{libg++} or @code{libstdc++}
 installed, you can tell @code{configure} to use @code{gcc} as your C++
@@ -14822,7 +14826,7 @@ Note that on Windows, you should specify all paths with @code{/} instead of
 @code{\}. If you use @code{\}, you need to specify this twice, as
 @code{\} is the escape character in MySQL.
 
-@cindex Environment variables
+@cindex environment variables
 MySQL tries to read option files in the order listed above.  If
 multiple option files exist, an option specified in a file read later takes
 precedence over the same option specified in a file read earlier.  Options
@@ -14967,10 +14971,10 @@ users access to different @code{mysqld} servers that they manage themselves.
 One way to get a new server running is by starting it with a different
 socket and port as follows:
 
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex Environment variable, MYSQL_TCP_PORT
+@tindex @code{MYSQL_UNIX_PORT} environment variable
+@tindex @code{MYSQL_TCP_PORT} environment variable
+@tindex environment variable, @code{MYSQL_UNIX_PORT}
+@tindex environment variable, @code{MYSQL_TCP_PORT}
 @example
 shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
 shell> MYSQL_TCP_PORT=3307
@@ -15983,12 +15987,12 @@ password=your_pass
 @xref{Option files}.
 
 @item
-@tindex MYSQL_HOST environment variable
-@tindex Environment variable, MYSQL_HOST
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex USER environment variable
-@tindex Environment variable, USER
+@tindex @code{MYSQL_HOST} environment variable
+@tindex environment variable, @code{MYSQL_HOST}
+@tindex @code{MYSQL_PWD} environment variable
+@tindex environment variable, @code{MYSQL_PWD}
+@tindex @code{USER} environment variable
+@tindex environment variable, @code{USER}
 You can specify connection parameters using environment variables.  The
 host can be specified for @code{mysql} using @code{MYSQL_HOST}.  The
 MySQL user name can be specified using @code{USER} (this is for
@@ -16229,7 +16233,7 @@ database administrators.  For other users, you should leave the privileges
 in the @code{user} table set to @code{'N'} and grant privileges on a
 database-specific basis only, using the @code{db} and @code{host} tables.
 
-@cindex Anonymous user
+@cindex anonymous user
 @cindex wild cards, in @code{mysql.db} table
 @cindex wild cards, in @code{mysql.host} table
 The @code{db} and @code{host} tables grant database-specific privileges.
@@ -20539,14 +20543,14 @@ size in bytes of the largest character in the set.
 All MySQL clients that communicate with the server using the
 @code{mysqlclient} library use the following environment variables:
 
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_TCP_PORT
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex MYSQL_DEBUG environment variable
-@tindex Environment variable, MYSQL_DEBUG
+@tindex @code{MYSQL_UNIX_PORT} environment variable
+@tindex environment variable, @code{MYSQL_UNIX_PORT}
+@tindex @code{MYSQL_TCP_PORT} environment variable
+@tindex environment variable, @code{MYSQL_TCP_PORT}
+@tindex @code{MYSQL_PWD} environment variable
+@tindex environment variable, @code{MYSQL_PWD}
+@tindex @code{MYSQL_DEBUG} environment variable
+@tindex environment variable, @code{MYSQL_DEBUG}
 @multitable @columnfractions .25 .75
 @item @strong{Name} @tab @strong{Description}
 @item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
@@ -20559,10 +20563,10 @@ All MySQL clients that communicate with the server using the
 Use of @code{MYSQL_PWD} is insecure.
 @xref{Connecting}.
 
-@tindex MYSQL_HISTFILE environment variable
-@tindex Environment variable, MYSQL_HISTFILE
-@tindex HOME environment variable
-@tindex Environment variable, HOME
+@tindex @code{MYSQL_HISTFILE} environment variable
+@tindex environment variable, @code{MYSQL_HISTFILE}
+@tindex @code{HOME} environment variable
+@tindex environment variable, @code{HOME}
 @cindex history file
 @cindex command line history
 @tindex .mysql_history file
@@ -21468,14 +21472,14 @@ binaries includes:
 All MySQL clients that communicate with the server using the
 @code{mysqlclient} library use the following environment variables:
 
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_TCP_PORT
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex MYSQL_DEBUG environment variable
-@tindex Environment variable, MYSQL_DEBUG
+@tindex @code{MYSQL_UNIX_PORT} environment variable
+@tindex environment variable, @code{MYSQL_UNIX_PORT}
+@tindex @code{MYSQL_TCP_PORT} environment variable
+@tindex environment variable, @code{MYSQL_TCP_PORT}
+@tindex @code{MYSQL_PWD} environment variable
+@tindex environment variable, @code{MYSQL_PWD}
+@tindex @code{MYSQL_DEBUG} environment variable
+@tindex environment variable, @code{MYSQL_DEBUG}
 @multitable @columnfractions .25 .75
 @item @strong{Name} @tab @strong{Description}
 @item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
@@ -21488,10 +21492,10 @@ All MySQL clients that communicate with the server using the
 Use of @code{MYSQL_PWD} is insecure.
 @xref{Connecting}.
 
-@tindex MYSQL_HISTFILE environment variable
-@tindex Environment variable, MYSQL_HISTFILE
-@tindex HOME environment variable
-@tindex Environment variable, HOME
+@tindex @code{MYSQL_HISTFILE} environment variable
+@tindex environment variable, @code{MYSQL_HISTFILE}
+@tindex @code{HOME} environment variable
+@tindex environment variable, @code{HOME}
 @cindex history file
 @cindex command line history
 @tindex .mysql_history file
@@ -21614,140 +21618,181 @@ Using @code{mysql} is very easy. Just start it as follows:
 @code{mysql database} or @code{mysql --user=user_name --password=your_password database}. Type a SQL statement, end it with @samp{;}, @samp{\g}, or @samp{\G}
 and press RETURN/ENTER.
 
-@cindex command line options
-@cindex options, command line
-@cindex startup parameters
+@cindex @code{mysql} command line options
+@cindex command line options, @code{mysql}
+@cindex options, command line, @code{mysql}
+@cindex startup parameters, @code{mysql}
 @code{mysql} supports the following options:
 
 @table @code
-@cindex help option
+@cindex @code{help}, @code{mysql} option
 @item -?, --help
 Display this help and exit.
-@cindex automatic rehash option
+
+@cindex @code{no-auto-rehash}, @code{mysql} option
 @item -A, --no-auto-rehash
 No automatic rehashing. One has to use 'rehash' to get table and field
 completion. This gives a quicker start of mysql.
-@cindex batch option
+
+@cindex @code{batch}, @code{mysql} option
 @item -B, --batch
 Print results with a tab as separator, each row on a new line. Doesn't use
 history file.
-@cindex character sets option
+
+@cindex @code{character-sets-dir}, @code{mysql} option
 @item --character-sets-dir=...
 Directory where character sets are located.
-@cindex compress option.
+
+@cindex @code{compress}, @code{mysql} option
 @item -C, --compress
 Use compression in server/client protocol.
-@cindex debug option
+
+@cindex @code{debug}, @code{mysql} option
 @item -#, --debug[=...]
 Debug log. Default is 'd:t:o,/tmp/mysql.trace'.
-@cindex database option
+
+@cindex @code{database}, @code{mysql} option
 @item -D, --database=...
 Database to use. This is mainly useful in the @code{my.cnf} file.
-@cindex default character set option
+
+@cindex @code{default-character-set}, @code{mysql} option
 @item --default-character-set=...
 Set the default character set.
-@cindex execute option
+
+@cindex @code{execute}, @code{mysql} option
 @item -e, --execute=...
 Execute command and quit. (Output like with --batch)
-@cindex vertical option
+
+@cindex @code{vertical}, @code{mysql} option
 @item -E, --vertical
 Print the output of a query (rows) vertically. Without this option you
 can also force this output by ending your statements with @code{\G}.
-@cindex force option
+
+@cindex @code{force}, @code{mysql} option
 @item -f, --force
 Continue even if we get a SQL error.
-@cindex no-named-commands option
+
+@cindex @code{no-named-commands}, @code{mysql} option
 @item -g, --no-named-commands
 Named commands are disabled. Use \* form only, or use named commands
 only in the beginning of a line ending with a semicolon (;). Since
 Version 10.9, the client now starts with this option ENABLED by default!
 With the -g option, long format commands will still work from the first
 line, however.
-@cindex enable-named-commands option
+
+@cindex @code{enable-named-commands}, @code{mysql} option
 @item -G, --enable-named-commands
 Named commands are @strong{enabled}.  Long format commands are allowed as
 well as shortened \* commands.
-@cindex ignore space option.
+
+@cindex @code{ignore-space}, @code{mysql} option
 @item -i, --ignore-space
 Ignore space after function names.
-@cindex host option
+
+@cindex @code{host}, @code{mysql} option
 @item -h, --host=...
 Connect to the given host.
-@cindex html option
+
+@cindex @code{html}, @code{mysql} option
 @item -H, --html
 Produce HTML output.
-@cindex skip line numbers option
+
+@cindex @code{skip-line-numbers}, @code{mysql} option
 @item -L, --skip-line-numbers
 Don't write line number for errors. Useful when one wants to compare result
 files that includes error messages
-@cindex no pager option
+
+@cindex @code{no-pager}, @code{mysql} option
 @item --no-pager
 Disable pager and print to stdout. See interactive help (\h) also.
-@cindex no tee option
+
+@cindex @code{no-tee}, @code{mysql} option
 @item --no-tee
 Disable outfile. See interactive help (\h) also.
-@cindex unbuffered option.
+
+@cindex @code{unbuffered}, @code{mysql} option
 @item -n, --unbuffered
 Flush buffer after each query.
-@cindex skip column names option
+
+@cindex @code{skip-column-names}, @code{mysql} option
 @item -N, --skip-column-names
 Don't write column names in results.
-@cindex set variable option
+
+@cindex @code{set-variable}, @code{mysql} option
 @item -O, --set-variable var=option
 Give a variable a value. @code{--help} lists variables.
-@cindex one database option
+
+@cindex @code{one-database}, @code{mysql} option
 @item -o, --one-database
 Only update the default database. This is useful for skipping updates to
 other database in the update log.
-@cindex pager option
+
+@cindex @code{pager}, @code{mysql} option
 @item @code{--pager[=...]}
 Output type. Default is your @code{ENV} variable @code{PAGER}. Valid
 pagers are less, more, cat [> filename], etc.  See interactive help (\h)
 also. This option does not work in batch mode. Pager works only in UNIX.
-@cindex password option
+
+@cindex @code{password}, @code{mysql} option
 @item -p[password], --password[=...]
 Password to use when connecting to server. If a password is not given on
 the command line, you will be prompted for it.  Note that if you use the
 short form @code{-p} you can't have a space between the option and the
 password.
+
+@cindex @code{port}, @code{mysql} option
 @item -P  --port=...
 TCP/IP port number to use for connection.
-@cindex quick option
+
+@cindex @code{quick}, @code{mysql} option
 @item -q, --quick
 Don't cache result, print it row-by-row. This may slow down the server
 if the output is suspended. Doesn't use history file.
-@cindex raw option
+
+@cindex @code{raw}, @code{mysql} option
 @item -r, --raw
 Write column values without escape conversion. Used with @code{--batch}
-@cindex silent option
+
+@cindex @code{silent}, @code{mysql} option
 @item -s, --silent
 Be more silent.
+
+@cindex @code{socket}, @code{mysql} option
 @item -S  --socket=...
 Socket file to use for connection.
-@cindex table option
+
+@cindex @code{table}, @code{mysql} option
 @item -t  --table
 Output in table format. This is default in non-batch mode.
+
+@cindex @code{debug-info}, @code{mysql} option
 @item -T, --debug-info
 Print some debug information at exit.
-@cindex tee option
+
+@cindex @code{tee}, @code{mysql} option
 @item --tee=...
 Append everything into outfile. See interactive help (\h) also. Does not
 work in batch mode.
-@cindex user option
+
+@cindex @code{user}, @code{mysql} option
 @item -u, --user=#
 User for login if not current user.
-@cindex safe updates option
+
+@cindex @code{safe-updates}, @code{mysql} option
 @item -U, --safe-updates[=#], --i-am-a-dummy[=#]
 Only allow @code{UPDATE} and @code{DELETE} that uses keys. See below for
 more information about this option.  You can reset this option if you have
 it in your @code{my.cnf} file by using @code{--safe-updates=0}.
-@cindex verbose option
+
+@cindex @code{verbose}, @code{mysql} option
 @item -v, --verbose
 More verbose output (-v -v -v gives the table output format).
-@cindex version option
+
+@cindex @code{version}, @code{mysql} option
 @item -V, --version
 Output version information and exit.
-@cindex wait option
+
+@cindex @code{wait}, @code{mysql} option
 @item -w, --wait
 Wait and retry if connection is down instead of aborting.
 @end table
@@ -21755,14 +21800,19 @@ Wait and retry if connection is down instead of aborting.
 You can also set the following variables with @code{-O} or
 @code{--set-variable}:
 
-@cindex timeout
+@cindex timeout, @code{connect_timeout} variable
+@cindex @code{connect_timeout} variable
+@cindex @code{max_allowed_packet}
+@cindex @code{net_buffer_length}
+@cindex @code{select_limit}
+@cindex @code{max_join_size}
 @multitable @columnfractions .3 .2 .5
-@item Variablename @tab Default @tab Description
-@item connect_timeout @tab 0 @tab Number of seconds before timeout connection.
-@item max_allowed_packet @tab 16777216 @tab Max packetlength to send/receive from to server
-@item net_buffer_length @tab 16384 @tab Buffer for TCP/IP and socket communication
-@item select_limit @tab 1000 @tab Automatic limit for SELECT when using --i-am-a-dummy
-@item max_join_size @tab 1000000 @tab Automatic limit for rows in a join when using --i-am-a-dummy.
+@item Variable Name      @tab Default   @tab Description
+@item connect_timeout    @tab 0         @tab Number of seconds before timeout connection.
+@item max_allowed_packet @tab 16777216  @tab Max packetlength to send/receive from to server
+@item net_buffer_length  @tab 16384     @tab Buffer for TCP/IP and socket communication
+@item select_limit       @tab 1000      @tab Automatic limit for SELECT when using --i-am-a-dummy
+@item max_join_size      @tab 1000000   @tab Automatic limit for rows in a join when using --i-am-a-dummy.
 @end multitable
 
 If you type 'help' on the command line, @code{mysql} will print out the
@@ -29097,9 +29147,9 @@ the number of enumeration values (65535 values maximum)
 on the number of set members (64 members maximum)
 @end multitable
 
-@cindex BLOB, size
-@cindex TEXT, size
-@cindex VARCHAR, size
+@cindex @code{BLOB}, size
+@cindex @code{TEXT}, size
+@cindex @code{VARCHAR}, size
 @code{VARCHAR} and the @code{BLOB} and @code{TEXT} types are variable-length
 types, for which the storage requirements depend on the actual length of
 column values (represented by @code{L} in the preceding table), rather than
@@ -37926,8 +37976,8 @@ $dth->trace(2);               # trace this database handle
 $sth->trace(2);               # trace this statement handle
 @end example
 
-@tindex DBI_TRACE environment variable
-@tindex Environment variable, DBI_TRACE
+@tindex @code{DBI_TRACE} environment variable
+@tindex environment variable, @code{DBI_TRACE}
 You can also enable @code{DBI} tracing by setting the @code{DBI_TRACE}
 environment variable.  Setting it to a numeric value is equivalent to calling
 @code{DBI->(value)}.  Setting it to a pathname is equivalent to calling
@@ -38458,7 +38508,7 @@ You should use the option flag @code{Return matching rows}.
 To get these to work, you should set the option flags
 @code{Don't optimize column widths} and @code{Return matching rows}.
 
-@cindex Borland Buidler 4 program
+@cindex Borland Builder 4 program
 @item Borland Builder 4
 When you start a query you can use the property @code{Active} or use the
 method @code{Open}.  Note that @code{Active} will start by automatically
@@ -38606,8 +38656,8 @@ fReg:= TRegistry.Create;
   AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines);
 @end example
 
-@cindex C++Builder
-@item C++Builder
+@cindex C++ Builder
+@item C++ Builder
 Tested with BDE Version 3.0. The only known problem is that when the table
 schema changes, query fields are not updated. BDE, however, does not seem
 to recognize primary keys, only the index PRIMARY, though this has not
@@ -50561,7 +50611,7 @@ Changed @code{net_write()} to @code{my_net_write()} because of a name
 conflict with Sybase.
 @item
 @cindex ODBC compatibility
-@cindex Compatibility, with ODBC
+@cindex compatibility, with ODBC
 New function @code{DAYOFWEEK()} compatible with ODBC.
 @item
 Stack checking and @code{bison} memory overrun checking to make MySQL

From d01f2efebfd97c63b41f609bf887c92c883fc229 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Sat, 18 Aug 2001 10:49:00 +0300
Subject: [PATCH 09/51] Portability fixes. Let myisamchk generate a new
 checksum for compressed data. Don't unconditionally force filenames to lower
 case on windows. Update mysqltest to match 4.0 source (to get some of the new
 bug fixes into 3.23)

Docs/manual.texi:
  Link changes, and new comments about IA64 and about Sun workshop
client/mysqltest.c:
  Updated this to match the 4.0 source
include/config-win.h:
  Don't unconditionally force filenames to lower case on windows.
innobase/include/ut0ut.h:
  Portability fix
myisam/mi_cache.c:
  Fix problem where reported error number was -1
myisam/mi_check.c:
  Let myisamchk generate a new checksum for compressed data.
myisam/mi_packrec.c:
  Cleanup
myisam/myisamchk.c:
  Report checksum for compressed tables
mysql-test/t/bdb.test:
  Fix to match new mysqltest
mysql-test/t/err000001.test:
  Fix to match new mysqltest
mysql-test/t/fulltext.test:
  Fix to match new mysqltest
mysql-test/t/innodb.test:
  Fix to match new mysqltest
mysql-test/t/overflow.test:
  Fix to match new mysqltest
sql/ha_gemini.cc:
  Fix false -> FALSE
sql/share/estonian/errmsg.txt:
  Updated of translation
sql/share/swedish/errmsg.txt:
  Updated of translation
sql/sql_parse.cc:
  Don't unconditionally force filenames to lower case on windows.
sql/sql_table.cc:
  Don't unconditionally force filenames to lower case on windows.
sql/sql_test.cc:
  Write current directory when using 'mysqladmin debug'
strings/strto.c:
  Portability fix
strings/strtoll.c:
  Portability fix
strings/strtoul.c:
  Portability fix
strings/strtoull.c:
  Portability fix
---
 Docs/manual.texi              |  26 ++-
 client/mysqltest.c            | 319 +++++++++++++++++++++++++---------
 include/config-win.h          |   1 -
 innobase/include/ut0ut.h      |   2 +
 myisam/mi_cache.c             |   4 +-
 myisam/mi_check.c             |  24 +--
 myisam/mi_packrec.c           |   2 +-
 myisam/myisamchk.c            |   4 +-
 mysql-test/t/bdb.test         |   4 +-
 mysql-test/t/err000001.test   |   3 +-
 mysql-test/t/fulltext.test    |  12 +-
 mysql-test/t/innodb.test      |   8 +-
 mysql-test/t/overflow.test    |   2 +-
 sql/ha_gemini.cc              |  14 +-
 sql/share/estonian/errmsg.txt |  24 +--
 sql/share/swedish/errmsg.txt  |  14 +-
 sql/sql_parse.cc              |   2 +-
 sql/sql_table.cc              |   8 +-
 sql/sql_test.cc               |   3 +
 strings/strto.c               |  10 +-
 strings/strtoll.c             |   4 +-
 strings/strtoul.c             |   2 +-
 strings/strtoull.c            |   4 +-
 23 files changed, 334 insertions(+), 162 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 59d9e44a6cf..665ebaacb27 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -1523,7 +1523,7 @@ Apart from the following links, you can find and download a lot of
 @subheading Tutorials and Manuals
 
 @table @asis
-@item @uref{http://netgraft.com/~mbac/research/mysqlmyths.html, MySQL Myths Debunked}
+@item @uref{http://michael.bacarella.com/research/mysqlmyths.html, MySQL Myths Debunked}
 @strong{MySQL} used in the real world.
 
 @item @uref{http://www.4t2.com/mysql}
@@ -10030,6 +10030,12 @@ make_install
 
 and @strong{mysqld} should be ready to run.
 
+On Ia64 the @strong{MySQL} client binaries are using shared
+libraries. This means that if you install our binary distribution in
+some other place than @file{/usr/local/mysql} you need to either modify
+@file{/etc/ld.so.conf} or add the path to the directory where you have
+@file{libmysqlclient.so} to the @code{LD_LIBRARY_PATH} environment
+variable. @xref{Link errors}.
 
 @node Windows, Solaris, Linux, Operating System Specific Notes
 @subsection Windows Notes
@@ -10635,7 +10641,7 @@ CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
 If you have a ultra sparc, you can get 4 % more performance by adding
 "-mcpu=v8 -Wa,-xarch=v8plusa" to CFLAGS and CXXFLAGS.
 
-If you have the Sun Workshop (SunPro) 4.2 (or newer) compiler, you can
+If you have Sun Workshop (Fortre) 5.3 (or newer) compiler, you can
 run @code{configure} like this:
 
 @example
@@ -10644,6 +10650,15 @@ CXX=CC CXXFLAGS="-noex -xO4 -mt" \
 ./configure --prefix=/usr/local/mysql --enable-assembler
 @end example
 
+In the MySQL benchmarks, we got a 6 % speedup on an Ultrasparc when
+using Sun Workshop 5.3 compared to using gcc with -mcpu flags.
+
+If you get a problem with @code{fdatasync} or @code{sched_yield},
+you can fix this by adding @code{LIBS=-lrt} to the configure line
+
+The following paragraph is only relevant for older compilers than
+WorkShop 5.3:
+
 You may also have to edit the @code{configure} script to change this line:
 
 @example
@@ -15496,7 +15511,7 @@ With this option,
 @code{SHOW DATABASES} returns only those databases for which the user has
 some kind of privilege.
 
-@item @code{--safe-user-create}
+@item --safe-user-create
 If this is enabled, an user can't create new users with the @code{GRANT}
 command, if the user doesn't have @code{INSERT} privilege to the
 @code{mysql.user} table.  If you want to give a user access to just create
@@ -21385,7 +21400,7 @@ mysql> show variables like "have_%";
 | have_bdb      | YES   |
 | have_innodb   | NO    |
 | have_isam     | YES   |
-| have_raid     | YES   |
+| have_raid     | NO    |
 | have_ssl      | NO    |
 +---------------+-------+
 @end example
@@ -46291,9 +46306,6 @@ Added prototypes for @code{my_thread_init()} and @code{my_thread_end()} to
 @item
 Added option @code{--safe-user-create} to @code{mysqld}.
 @item
-Added options to the @code{--ansi} startup options to let the user
-decide which @code{ansi} options one to enable.
-@item
 Fixed bug in @code{SELECT DISTINCT ... HAVING} that casued error message
 @code{Can't find record in '#...}
 @end itemize
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 5eaefe165d7..f6d87352a6c 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -43,7 +43,7 @@
 
 **********************************************************************/
 
-#define MTEST_VERSION "1.8"
+#define MTEST_VERSION "1.10"
 
 #include <global.h>
 #include <my_sys.h>
@@ -84,7 +84,7 @@
 static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
 static char *db = 0, *pass=0;
 const char* user = 0, *host = 0, *unix_sock = 0;
-static int port = 0;
+static int port = 0, opt_big_test=0;
 static uint start_lineno, *lineno;
 
 static char **default_argv;
@@ -95,9 +95,13 @@ static FILE** cur_file;
 static FILE** file_stack_end;
 static uint lineno_stack[MAX_INCLUDE_DEPTH];
 static char TMPDIR[FN_REFLEN];
+static int  *block_ok_stack_end;
 
-static int block_stack[BLOCK_STACK_DEPTH];
 static int *cur_block, *block_stack_end;
+static int block_stack[BLOCK_STACK_DEPTH];
+
+
+static int block_ok_stack[BLOCK_STACK_DEPTH];
 static uint global_expected_errno[MAX_EXPECTED_ERRORS];
 
 DYNAMIC_ARRAY q_lines;
@@ -121,7 +125,7 @@ typedef struct
 
 PARSER parser;
 MASTER_POS master_pos;
-int block_ok = 1; /* set to 0 if the current block should not be executed */
+int* block_ok; /* set to 0 if the current block should not be executed */
 int false_block_depth = 0;
 const char* result_file = 0; /* if set, all results are concated and
 				compared against this file*/
@@ -159,6 +163,8 @@ Q_SYNC_WITH_MASTER, Q_ERROR,
 Q_SEND,             Q_REAP, 
 Q_DIRTY_CLOSE,      Q_REPLACE,
 Q_PING,             Q_EVAL,
+Q_RPL_PROBE,        Q_ENABLE_RPL_PARSE,
+Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
 Q_UNKNOWN,                             /* Unknown command.   */
 Q_COMMENT,                             /* Comments, ignored. */
 Q_COMMENT_WITH_COMMAND
@@ -167,7 +173,7 @@ Q_COMMENT_WITH_COMMAND
 /* this should really be called command */
 struct st_query
 {
-  char *query, *query_buf,*first_argument;
+  char *query, *query_buf,*first_argument,*end;
   int first_word_len;
   my_bool abort_on_error, require_file;
   uint expected_errno[MAX_EXPECTED_ERRORS];
@@ -188,6 +194,8 @@ const char *command_names[] = {
   "send",             "reap", 
   "dirty_close",      "replace_result",
   "ping",             "eval",
+  "rpl_probe",        "enable_rpl_parse",
+  "disable_rpl_parse", "eval_result",
   0
 };
 
@@ -199,7 +207,7 @@ static void die(const char* fmt, ...);
 static void init_var_hash();
 static byte* get_var_key(const byte* rec, uint* len,
 			 my_bool __attribute__((unused)) t);
-static VAR* var_init(const char* name, int name_len, const char* val,
+static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
 		     int val_len);
 
 static void var_free(void* v);
@@ -230,10 +238,21 @@ void free_pointer_array(POINTER_ARRAY *pa);
 static int initialize_replace_buffer(void);
 static void free_replace_buffer(void);
 static void do_eval(DYNAMIC_STRING* query_eval, const char* query);
+void str_to_file(const char* fname, char* str, int size);
 
 struct st_replace *glob_replace;
 static char *out_buff;
 static uint out_length;
+static int eval_result = 0;
+
+/* Disable functions that only exist in MySQL 4.0 */
+#if MYSQL_VERSION_ID < 40000
+static void mysql_enable_rpl_parse(MYSQL* mysql) {}
+static void mysql_disable_rpl_parse(MYSQL* mysql) {}
+static int mysql_rpl_parse_enabled(MYSQL* mysql) { return 1; }
+static int mysql_rpl_probe(MYSQL *mysql) { return 1; }
+#endif
+
 
 static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
 {
@@ -290,7 +309,7 @@ static void close_files()
 {
   do
   {
-    if (*cur_file != stdin)
+    if (*cur_file != stdin && *cur_file)
       my_fclose(*cur_file,MYF(0));
   } while (cur_file-- != file_stack);
 }
@@ -352,7 +371,9 @@ static void abort_not_supported_test()
 static void verbose_msg(const char* fmt, ...)
 {
   va_list args;
-  if (!verbose) return;
+  DBUG_ENTER("verbose_msg");
+  if (!verbose)
+    DBUG_VOID_RETURN;
 
   va_start(args, fmt);
 
@@ -360,6 +381,7 @@ static void verbose_msg(const char* fmt, ...)
   vfprintf(stderr, fmt, args);
   fprintf(stderr, "\n");
   va_end(args);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -382,25 +404,53 @@ int hex_val(int c)
 int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
 {
   MY_STAT stat_info;
-  char *tmp;
+  char *tmp, *res_ptr;
+  char eval_file[FN_REFLEN];
   int res;
+  uint res_len;
   int fd;
+  DYNAMIC_STRING res_ds;
   DBUG_ENTER("dyn_string_cmp");
 
   if (!my_stat(fname, &stat_info, MYF(MY_WME)))
     die(NullS);
-  if (stat_info.st_size != ds->length)
+  if (!eval_result && stat_info.st_size != ds->length)
     DBUG_RETURN(2);
-  if (!(tmp = (char*) my_malloc(ds->length, MYF(MY_WME))))
+  if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
     die(NullS);
   if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
     die(NullS);
   if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
     die(NullS);
-  res = (memcmp(tmp, ds->str, stat_info.st_size)) ?  1 : 0;
+  tmp[stat_info.st_size] = 0;
+  init_dynamic_string(&res_ds, "", 0, 65536);
+  if (eval_result)
+  {
+    do_eval(&res_ds, tmp);
+    res_ptr = res_ds.str;
+    if((res_len = res_ds.length) != ds->length)
+    {
+      res = 2;
+      goto err;
+    }
+  }
+  else
+  {
+    res_ptr = tmp;
+    res_len = stat_info.st_size;
+  }
+  
+  res = (memcmp(res_ptr, ds->str, res_len)) ?  1 : 0;
+  
+err:  
+  if(res && eval_result)
+     str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
+		  res_len);
+    
   my_free((gptr) tmp, MYF(0));
   my_close(fd, MYF(MY_WME));
-
+  dynstr_free(&res_ds);
+  
   DBUG_RETURN(res);
 }
 
@@ -446,12 +496,12 @@ VAR* var_get(const char* var_name, const char** var_name_end, int raw)
   {
     const char* save_var_name = var_name, *end;
     end = (var_name_end) ? *var_name_end : 0;
-    while(isalnum(*var_name) || *var_name == '_')
-      {
-	if(end && var_name == end)
-	  break;
-        ++var_name;
-      }
+    while (isvar(*var_name))
+    {
+      if(end && var_name == end)
+	break;
+      ++var_name;
+    }
     if(var_name == save_var_name)
       die("Empty variable");
     
@@ -488,7 +538,7 @@ static VAR* var_obtain(char* name, int len)
   VAR* v;
   if((v = (VAR*)hash_search(&var_hash, name, len)))
     return v;
-  v = var_init(name, len, "", 0);
+  v = var_init(0, name, len, "", 0);
   hash_insert(&var_hash, (byte*)v);
   return v;
 }
@@ -497,7 +547,6 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
 	    char* var_val_end)
 {
   int digit;
-  int val_len;
   VAR* v;
   if (*var_name++ != '$')
     {
@@ -512,21 +561,8 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
     }
   else 
    v = var_reg + digit;
-  if (v->alloced_len < (val_len = (int)(var_val_end - var_val)+1))
-    {
-      v->alloced_len = (val_len < MIN_VAR_ALLOC) ? MIN_VAR_ALLOC : val_len;
-     if (!(v->str_val =
-	  v->str_val ? my_realloc(v->str_val, v->alloced_len,  MYF(MY_WME)) :
-	   my_malloc(v->alloced_len, MYF(MY_WME))))
-	 die("Out of memory");
-    }
-  val_len--;
-  memcpy(v->str_val, var_val, val_len);
-  v->str_val_len = val_len;
-  v->str_val[val_len] = 0;
-  v->int_val = atoi(v->str_val);
-  v->int_dirty=0;
-  return 0;
+  
+  return eval_expr(v, var_val, (const char**)&var_val_end);
 }
 
 int open_file(const char* name)
@@ -554,6 +590,35 @@ int do_source(struct st_query* q)
   return open_file(name);
 }
 
+int var_query_set(VAR* v, const char* p, const char** p_end)
+{
+  char* end = (char*)((p_end && *p_end) ? *p_end : p + strlen(p));
+  MYSQL_RES *res;
+  MYSQL_ROW row;
+  MYSQL* mysql = &cur_con->mysql;
+  LINT_INIT(res);
+  
+  while (end > p && *end != '`')
+    --end;
+  if (p == end)
+    die("Syntax error in query, missing '`'");
+  ++p;
+
+  if (mysql_real_query(mysql, p, (int)(end - p)) ||
+      !(res = mysql_store_result(mysql)))
+  {
+    *end = 0;
+    die("Error running query '%s': %s", p, mysql_error(mysql));
+  }
+
+  if ((row = mysql_fetch_row(res)) && row[0])
+    eval_expr(v, row[0], 0);
+  else
+    eval_expr(v, "", 0);
+
+  mysql_free_result(res);
+  return 0;
+}
 
 int eval_expr(VAR* v, const char* p, const char** p_end)
 {
@@ -566,10 +631,27 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
 	  return 0;
 	}
     }
+  else if(*p == '`')
+  {
+    return var_query_set(v, p, p_end);
+  }
   else
     {
-      v->str_val = (char*)p;
-      v->str_val_len = (p_end && *p_end) ? (int) (*p_end - p) : (int) strlen(p);
+      int new_val_len = (p_end && *p_end) ?
+	 (int) (*p_end - p) : (int) strlen(p);
+      if (new_val_len + 1 >= v->alloced_len)
+      {
+        v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
+	  MIN_VAR_ALLOC : new_val_len + 1;
+	if (!(v->str_val =
+	      v->str_val ? my_realloc(v->str_val, v->alloced_len,
+				      MYF(MY_WME)) :
+	      my_malloc(v->alloced_len, MYF(MY_WME))))
+	  die("Out of memory");
+      }
+      v->str_val_len = new_val_len;
+      memcpy(v->str_val, p, new_val_len);
+      v->str_val[new_val_len] = 0;
       v->int_val=atoi(p);
       v->int_dirty=0;
       return 0;
@@ -605,6 +687,7 @@ int do_system(struct st_query* q)
 {
   char* p=q->first_argument;
   VAR v;
+  var_init(&v, 0, 0, 0, 0);
   eval_expr(&v, p, 0); /* NULL terminated */
   if (v.str_val_len)
     {
@@ -624,6 +707,7 @@ int do_echo(struct st_query* q)
 {
   char* p=q->first_argument;
   VAR v;
+  var_init(&v,0,0,0,0);
   eval_expr(&v, p, 0); /* NULL terminated */
   if (v.str_val_len)
   {
@@ -642,6 +726,11 @@ int do_sync_with_master(struct st_query* q)
   char query_buf[FN_REFLEN+128];
   int offset = 0;
   char* p = q->first_argument;
+  int rpl_parse;
+
+  rpl_parse = mysql_rpl_parse_enabled(mysql);
+  mysql_disable_rpl_parse(mysql);
+  
   if(*p)
     offset = atoi(p);
   
@@ -658,7 +747,10 @@ int do_sync_with_master(struct st_query* q)
   if(!row[0])
     die("Error on slave while syncing with master");
   mysql_free_result(res);
-      
+
+  if(rpl_parse)
+    mysql_enable_rpl_parse(mysql);
+  
   return 0;
 }
 
@@ -667,6 +759,11 @@ int do_save_master_pos()
   MYSQL_RES* res;
   MYSQL_ROW row;
   MYSQL* mysql = &cur_con->mysql;
+  int rpl_parse;
+
+  rpl_parse = mysql_rpl_parse_enabled(mysql);
+  mysql_disable_rpl_parse(mysql);
+  
   if(mysql_query(mysql, "show master status"))
     die("At line %u: failed in show master status: %d: %s", start_lineno,
 	mysql_errno(mysql), mysql_error(mysql));
@@ -678,6 +775,9 @@ int do_save_master_pos()
   strncpy(master_pos.file, row[0], sizeof(master_pos.file));
   master_pos.pos = strtoul(row[1], (char**) 0, 10); 
   mysql_free_result(res);
+  
+  if(rpl_parse)
+    mysql_enable_rpl_parse(mysql);
       
   return 0;
 }
@@ -697,11 +797,29 @@ int do_let(struct st_query* q)
   while(*p && isspace(*p))
     p++;
   var_val_start = p;
-  while(*p && !isspace(*p))
-    p++;
-  return var_set(var_name, var_name_end, var_val_start, p);
+  return var_set(var_name, var_name_end, var_val_start, q->end);
 }
 
+int do_rpl_probe(struct st_query* __attribute__((unused)) q)
+{
+  if(mysql_rpl_probe(&cur_con->mysql))
+    die("Failed in mysql_rpl_probe(): %s", mysql_error(&cur_con->mysql));
+  return 0;
+}
+
+int do_enable_rpl_parse(struct st_query* __attribute__((unused)) q)
+{
+  mysql_enable_rpl_parse(&cur_con->mysql);
+  return 0;
+}
+
+int do_disable_rpl_parse(struct st_query* __attribute__((unused)) q)
+{
+  mysql_disable_rpl_parse(&cur_con->mysql);
+  return 0;
+}
+
+
 int do_sleep(struct st_query* q)
 {
   char* p=q->first_argument;
@@ -1015,7 +1133,8 @@ int do_connect(struct st_query* q)
 
   if (!mysql_init(&next_con->mysql))
     die("Failed on mysql_init()");
-  con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
+  if (con_sock)
+    con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
   if (!con_db[0])
     con_db=db;
   con_error = 1;
@@ -1047,13 +1166,14 @@ int do_done(struct st_query* q)
   q->type = Q_END_BLOCK;
   if (cur_block == block_stack)
     die("Stray '}' - end of block before beginning");
-  if (block_ok)
+  if (*block_ok--)
+  {
     parser.current_line = *--cur_block;
+  }
   else
     {
-      if (!--false_block_depth)
-	block_ok = 1;
       ++parser.current_line;
+      --cur_block;
     }
   return 0;
 }
@@ -1063,13 +1183,17 @@ int do_while(struct st_query* q)
   char* p=q->first_argument;
   const char* expr_start, *expr_end;
   VAR v;
+  var_init(&v,0,0,0,0);
   if (cur_block == block_stack_end)
 	die("Nesting too deeply");
-  if (!block_ok)
+  if (!*block_ok)
     {
       ++false_block_depth;
+      *++block_ok = 0;
+      *cur_block++ = parser.current_line++;
       return 0;
     }
+    
   expr_start = strchr(p, '(');
   if (!expr_start)
     die("missing '(' in while");
@@ -1080,9 +1204,11 @@ int do_while(struct st_query* q)
   *cur_block++ = parser.current_line++;
   if (!v.int_val)
     {
-      block_ok = 0;
-      false_block_depth = 1;
+      *++block_ok = 0;
+      false_block_depth++;
     }
+  else
+    *++block_ok = 1;
   return 0;
 }
 
@@ -1346,7 +1472,7 @@ int read_query(struct st_query** q_ptr)
   q->first_word_len = (uint) (p - q->query);
   while (*p && isspace(*p)) p++;
   q->first_argument=p;
-
+  q->end = strend(q->query);
   parser.read_lines++;
   return 0;
 }
@@ -1356,6 +1482,7 @@ struct option long_options[] =
 {
   {"debug",       optional_argument, 0, '#'},
   {"database",    required_argument, 0, 'D'},
+  {"big-test",	  no_argument,	     0, 'B'},
   {"help",        no_argument,       0, '?'},
   {"host",        required_argument, 0, 'h'},
   {"password",    optional_argument, 0, 'p'},
@@ -1366,6 +1493,7 @@ struct option long_options[] =
   {"silent",      no_argument,       0, 'q'},
   {"sleep",       required_argument, 0, 'T'},
   {"socket",      required_argument, 0, 'S'},
+  {"test-file",   required_argument, 0, 'x'},
   {"tmpdir",      required_argument, 0, 't'},
   {"user",        required_argument, 0, 'u'},
   {"verbose",     no_argument,       0, 'v'},
@@ -1398,6 +1526,7 @@ void usage()
   -u, --user=...           User for login.\n\
   -p[password], --password[=...]\n\
                            Password to use when connecting to server.\n\
+  -B, --big-test	   Define BIG_TEST to 1\n\
   -D, --database=...       Database to use.\n\
   -P, --port=...           Port number to use for connection.\n\
   -S, --socket=...         Socket file to use for connection.\n\
@@ -1405,6 +1534,7 @@ void usage()
   -T, --sleep=#		   Sleep always this many seconds on sleep commands\n\
   -r, --record             Record output of test_file into result file.\n\
   -R, --result-file=...    Read/Store result from/in this file.\n\
+  -x, --test-file=...      Read test from/in this file (default stdin).\n\
   -v, --verbose            Write more.\n\
   -q, --quiet, --silent    Suppress all normal output.\n\
   -V, --version            Output version information and exit.\n\
@@ -1419,7 +1549,7 @@ int parse_args(int argc, char **argv)
   load_defaults("my",load_default_groups,&argc,&argv);
   default_argv= argv;
 
-  while((c = getopt_long(argc, argv, "h:p::u:P:D:S:R:t:T:#:?rvVq",
+  while((c = getopt_long(argc, argv, "h:p::u:BP:D:S:R:x:t:T:#:?rvVq",
 			 long_options, &option_index)) != EOF)
     {
       switch(c)	{
@@ -1438,6 +1568,10 @@ int parse_args(int argc, char **argv)
       case 'R':
 	result_file = optarg;
 	break;
+      case 'x':
+      if (!(*cur_file = my_fopen(optarg, O_RDONLY, MYF(MY_WME))))
+	  die("Could not open %s: errno = %d", optarg, errno);
+	break;
       case 'p':
 	if (optarg)
 	{
@@ -1448,6 +1582,9 @@ int parse_args(int argc, char **argv)
 	else
 	  tty_password=1;
 	break;
+      case 'B':
+        opt_big_test=1;
+        break;
       case 'P':
 	port = atoi(optarg);
 	break;
@@ -1522,10 +1659,12 @@ void reject_dump(const char* record_file, char* buf, int size)
   str_to_file(fn_format(reject_file, record_file,"",".reject",2), buf, size);
 }
 
-/* flags control the phased/stages of query execution to be performed 
+/*
+* flags control the phased/stages of query execution to be performed 
 * if QUERY_SEND bit is on, the query will be sent. If QUERY_REAP is on
 * the result will be read - for regular query, both bits must be on
 */
+
 int run_query(MYSQL* mysql, struct st_query* q, int flags)
 {
   MYSQL_RES* res = 0;
@@ -1568,7 +1707,8 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
   if(!(flags & QUERY_REAP))
     return 0;
   
-  if (mysql_read_query_result(mysql))
+  if (mysql_read_query_result(mysql) ||
+      (!(res = mysql_store_result(mysql)) && mysql_field_count(mysql)))
   {
     if (q->require_file)
       abort_not_supported_test();
@@ -1584,17 +1724,25 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
       }
       if (i)
       {
-	verbose_msg("query '%s' failed with wrong errno\
- %d instead of %d...", q->query, mysql_errno(mysql), q->expected_errno[0]);
+	verbose_msg("query '%s' failed with wrong errno %d instead of %d...",
+		    q->query, mysql_errno(mysql), q->expected_errno[0]);
+	error=1;
 	goto end;
       }
       verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql),
 		  mysql_error(mysql));
-      /* if we do not abort on error, failure to run the query does
+      /* 
+	 if we do not abort on error, failure to run the query does
 	 not fail the whole test case
       */
       goto end;
     }
+    /*{
+      verbose_msg("failed in mysql_store_result for query '%s' (%d)", query,
+		  mysql_errno(mysql));
+      error = 1;
+      goto end;
+    }*/
   }
 
   if (q->expected_errno[0])
@@ -1605,23 +1753,6 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
     goto end;
   }
 
-
-  if (!(res = mysql_store_result(mysql)) && mysql_field_count(mysql))
-  {
-    if (q->require_file)
-      abort_not_supported_test();
-    if (q->abort_on_error)
-      die("At line %u: Failed in mysql_store_result for query '%s' (%d)",
-	  start_lineno, query, mysql_errno(mysql));
-    else
-    {
-      verbose_msg("failed in mysql_store_result for query '%s' (%d)", query,
-		  mysql_errno(mysql));
-      error = 1;
-      goto end;
-    }
-  }
-
   if (!res) goto end;
 
   fields =  mysql_fetch_fields(res);
@@ -1718,33 +1849,39 @@ static byte* get_var_key(const byte* var, uint* len,
   return (byte*)key;
 }
 
-static VAR* var_init(const char* name, int name_len, const char* val,
+static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
 		     int val_len)
 {
   int val_alloc_len;
   VAR* tmp_var;
-  if(!name_len)
+  if(!name_len && name)
     name_len = strlen(name);
-  if(!val_len)
+  if(!val_len && val)
     val_len = strlen(val) ;
   val_alloc_len = val_len + 16; /* room to grow */
-  if(!(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) + val_alloc_len
+  if(!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) 
 				 + name_len, MYF(MY_WME))))
     die("Out of memory");
-  tmp_var->name = (char*)tmp_var + sizeof(*tmp_var);
-  tmp_var->str_val = tmp_var->name + name_len;
+  
+  tmp_var->name = (name) ? (char*)tmp_var + sizeof(*tmp_var) : 0;
+
+  if(!(tmp_var->str_val = my_malloc(val_alloc_len, MYF(MY_WME))))
+    die("Out of memory");
+  
   memcpy(tmp_var->name, name, name_len);
-  memcpy(tmp_var->str_val, val, val_len + 1);
+  if(val)
+    memcpy(tmp_var->str_val, val, val_len + 1);
   tmp_var->name_len = name_len;
   tmp_var->str_val_len = val_len;
   tmp_var->alloced_len = val_alloc_len;
-  tmp_var->int_val = atoi(val);
+  tmp_var->int_val = (val) ? atoi(val) : 0;
   tmp_var->int_dirty = 0;
   return tmp_var;
 }
 
 static void var_free(void* v)
 {
+  my_free(((VAR*)v)->str_val, MYF(MY_WME));
   my_free(v, MYF(MY_WME));
 }
 
@@ -1756,17 +1893,19 @@ static void var_from_env(const char* name, const char* def_val)
   if(!(tmp = getenv(name)))
     tmp = def_val;
     
-  v = var_init(name, 0, tmp, 0); 
+  v = var_init(0, name, 0, tmp, 0); 
   hash_insert(&var_hash, (byte*)v);
 }
 
+
 static void init_var_hash()
 {
-  if(hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
+  if (hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
     die("Variable hash initialization failed");
   var_from_env("MASTER_MYPORT", "9306");
   var_from_env("SLAVE_MYPORT", "9307");
-  var_from_env("MYSQL_TEST_DIR", "");
+  var_from_env("MYSQL_TEST_DIR", "/tmp");
+  var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
 }
 
 int main(int argc, char** argv)
@@ -1793,7 +1932,11 @@ int main(int argc, char** argv)
 		     INIT_Q_LINES);
   memset(block_stack, 0, sizeof(block_stack));
   block_stack_end = block_stack + BLOCK_STACK_DEPTH;
+  memset(block_ok_stack, 0, sizeof(block_stack));
+  block_ok_stack_end = block_ok_stack + BLOCK_STACK_DEPTH;
   cur_block = block_stack;
+  block_ok = block_ok_stack;
+  *block_ok = 1;
   init_dynamic_string(&ds_res, "", 0, 65536);
   parse_args(argc, argv);
   init_var_hash();
@@ -1817,7 +1960,7 @@ int main(int argc, char** argv)
     int current_line_inc = 1, processed = 0;
     if (q->type == Q_UNKNOWN || q->type == Q_COMMENT_WITH_COMMAND)
       get_query_type(q);
-    if (block_ok)
+    if (*block_ok)
     {
       processed = 1;
       switch (q->type) {
@@ -1826,6 +1969,9 @@ int main(int argc, char** argv)
       case Q_DISCONNECT:
       case Q_DIRTY_CLOSE:	
 	close_connection(q); break;
+      case Q_RPL_PROBE: do_rpl_probe(q); break;
+      case Q_ENABLE_RPL_PARSE: do_enable_rpl_parse(q); break;
+      case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break;
       case Q_SOURCE: do_source(q); break;
       case Q_SLEEP: do_sleep(q); break;
       case Q_INC: do_inc(q); break;
@@ -1833,6 +1979,7 @@ int main(int argc, char** argv)
       case Q_ECHO: do_echo(q); break;
       case Q_SYSTEM: do_system(q); break;
       case Q_LET: do_let(q); break;
+      case Q_EVAL_RESULT: eval_result = 1; break;	
       case Q_EVAL:
         if (q->query == q->query_buf)
 	  q->query += q->first_word_len;
@@ -1893,7 +2040,7 @@ int main(int argc, char** argv)
       case Q_SAVE_MASTER_POS: do_save_master_pos(); break;	
       case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break;	
       case Q_COMMENT:				/* Ignore row */
-      case Q_COMMENT_WITH_COMMAND:
+      case Q_COMMENT_WITH_COMMAND: 
       case Q_PING:
 	(void) mysql_ping(&cur_con->mysql);
 	break;
diff --git a/include/config-win.h b/include/config-win.h
index 3791c337cb3..4e4088f07dd 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -287,7 +287,6 @@ inline double ulonglong2double(ulonglong value)
 #define FN_ROOTDIR	"\\"
 #define FN_NETWORK_DRIVES	/* Uses \\ to indicate network drives */
 #define FN_NO_CASE_SENCE	/* Files are not case-sensitive */
-#define FN_LOWER_CASE	TRUE	/* Files are represented in lower case */
 #define MY_NFILE	1024
 
 #define DO_NOT_REMOVE_THREAD_WRAPPERS
diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h
index e1813e763bd..4366b832ff6 100644
--- a/innobase/include/ut0ut.h
+++ b/innobase/include/ut0ut.h
@@ -11,7 +11,9 @@ Created 1/20/1994 Heikki Tuuri
 
 #include "univ.i"
 #include <time.h>
+#ifndef MYSQL_SERVER
 #include <ctype.h>
+#endif
 
 typedef time_t	ib_time_t;
 
diff --git a/myisam/mi_cache.c b/myisam/mi_cache.c
index 0e630cae22b..69a1cb0d7a5 100644
--- a/myisam/mi_cache.c
+++ b/myisam/mi_cache.c
@@ -73,7 +73,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
     if (!(flag & READING_HEADER) || info->error == -1 ||
 	(uint) info->error+in_buff_length < 3)
     {
-      if (!my_errno)
+      if (!my_errno || my_errno == -1)
 	my_errno=HA_ERR_WRONG_IN_RECORD;
       DBUG_RETURN(1);
     }
@@ -87,7 +87,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
   if (!(flag & READING_HEADER) || (int) read_length == -1 ||
       read_length+in_buff_length < 3)
   {
-    if (!my_errno)
+    if (!my_errno || my_errno == -1)
       my_errno=HA_ERR_WRONG_IN_RECORD;
     DBUG_RETURN(1);
   }
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index 0caedbe1a51..64bc5d7b8e5 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -708,7 +708,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
       puts("- check record links");
   }
 
-  if (!(record= (byte*) my_alloca(info->s->base.pack_reclength)))
+  if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0))))
   {
     mi_check_print_error(param,"Not Enough memory");
     DBUG_RETURN(-1);
@@ -924,8 +924,9 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
       if (block_info.rec_len < (uint) info->s->min_pack_length ||
 	  block_info.rec_len > (uint) info->s->max_pack_length)
       {
-	mi_check_print_error(param,"Found block with wrong recordlength: %d at %s",
-		    block_info.rec_len, llstr(start_recpos,llbuff));
+	mi_check_print_error(param,
+			     "Found block with wrong recordlength: %d at %s",
+			     block_info.rec_len, llstr(start_recpos,llbuff));
 	got_error=1;
 	break;
       }
@@ -934,7 +935,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
 	goto err;
       if (_mi_pack_rec_unpack(info,record,info->rec_buff,block_info.rec_len))
       {
-	mi_check_print_error(param,"Found wrong record at %s", llstr(start_recpos,llbuff));
+	mi_check_print_error(param,"Found wrong record at %s",
+			     llstr(start_recpos,llbuff));
 	got_error=1;
       }
       if (static_row_size)
@@ -1082,12 +1084,12 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
     printf("Lost space:   %12s    Linkdata:     %10s\n",
 	   llstr(empty,llbuff),llstr(link_used,llbuff2));
   }
-  my_afree((gptr) record);
+  my_free((gptr) record,MYF(0));
   DBUG_RETURN (error);
  err:
-  mi_check_print_error(param,"got error: %d when reading datafile",my_errno);
+  mi_check_print_error(param,"got error: %d when reading datafile at record: %s",my_errno, llstr(records,llbuff));
  err2:
-  my_afree((gptr) record);
+  my_free((gptr) record,MYF(0));
   param->retry_without_quick=1;
   DBUG_RETURN(1);
 } /* chk_data_link */
@@ -1188,7 +1190,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
   del=info->state->del;
   info->state->records=info->state->del=share->state.split=0;
   info->state->empty=0;
-  if (sort_info->new_data_file_type != COMPRESSED_RECORD && !rep_quick)
+  if (!rep_quick)
     share->state.checksum=0;
   info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
   for (i=0 ; i < info->s->base.keys ; i++)
@@ -1866,8 +1868,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
   sort_param.sort_info=sort_info;
 
   del=info->state->del;
-  if (sort_info->new_data_file_type != COMPRESSED_RECORD &&
-      ! rep_quick)
+  if (! rep_quick)
     share->state.checksum=0;
 
   rec_per_key_part= param->rec_per_key_part;
@@ -2414,6 +2415,7 @@ static int sort_get_next_record(SORT_INFO *sort_info)
 			      llstr(sort_info->pos,llbuff));
 	continue;
       }
+      info->checksum=mi_checksum(info,sort_info->record);
       if (!sort_info->fix_datafile)
 	sort_info->filepos=sort_info->pos;
       sort_info->max_pos=(sort_info->pos=block_info.filepos+
@@ -2492,6 +2494,7 @@ int sort_write_record(SORT_INFO *sort_info)
 	DBUG_RETURN(1);
       }
       sort_info->filepos+=block_length;
+      info->s->state.checksum+=info->checksum;
       break;
     case COMPRESSED_RECORD:
       reclength=info->packed_length;
@@ -2504,6 +2507,7 @@ int sort_write_record(SORT_INFO *sort_info)
 	mi_check_print_error(param,"%d when writing to datafile",my_errno);
 	DBUG_RETURN(1);
       }
+      info->s->state.checksum+=info->checksum;
       sort_info->filepos+=reclength+length;
       break;
     }
diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c
index be7f9dcae0a..68d546b2010 100644
--- a/myisam/mi_packrec.c
+++ b/myisam/mi_packrec.c
@@ -962,7 +962,7 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
     b_type=_mi_pack_get_block_info(info,&block_info,info->dfile,filepos,
 				   info->rec_buff);
   if (b_type)
-    goto err;
+    goto err;					/* Error code is already set */
 #ifndef DBUG_OFF
   if (block_info.rec_len > share->max_pack_length)
   {
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index ec3f0c8dca4..996e4749e53 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -201,7 +201,7 @@ static struct option long_options[] =
 
 static void print_version(void)
 {
-  printf("%s  Ver 1.49 for %s at %s\n",my_progname,SYSTEM_TYPE,
+  printf("%s  Ver 1.50 for %s at %s\n",my_progname,SYSTEM_TYPE,
 	 MACHINE_TYPE);
 }
 
@@ -953,7 +953,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name)
 	     share->base.raid_chunks,
 	     share->base.raid_chunksize);
     }
-    if (share->options & HA_OPTION_CHECKSUM)
+    if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
       printf("Checksum:  %23s\n",llstr(info->s->state.checksum,llbuff));
 ;
     if (share->options & HA_OPTION_DELAY_KEY_WRITE)
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index 7976b482100..5e28c31e051 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -693,7 +693,7 @@ drop table t1;
 create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=bdb;
 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 LOCK TABLES t1 WRITE;
---error 690
+--error 1062
 insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 select id from t1;
 select id from t1;
@@ -704,7 +704,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 LOCK TABLES t1 WRITE;
 begin;
---error 690
+--error 1062
 insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 select id from t1;
 insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
diff --git a/mysql-test/t/err000001.test b/mysql-test/t/err000001.test
index 9957cefff9b..d9898054a83 100644
--- a/mysql-test/t/err000001.test
+++ b/mysql-test/t/err000001.test
@@ -10,7 +10,8 @@ create table t1 (a int);
 !$1054 select count(test.t1.b) from t1;
 !$1109 select count(not_existing_database.t1) from t1;
 !$1109 select count(not_existing_database.t1.a) from t1;
-!$1044 select count(not_existing_database.t1.a) from not_existing_database.t1;
+--error 1044,1146
+select count(not_existing_database.t1.a) from not_existing_database.t1;
 !$1054 select 1 from t1 order by 2;
 !$1054 select 1 from t1 group by 2;
 !$1054 select 1 from t1 order by t1.b;
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 153fdefd960..eedee811f2b 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -73,11 +73,15 @@ CREATE TABLE t3 (
 );
 
 --error 1210
-select * from t2 having MATCH inhalt AGAINST (t1.id);
+select * from t2 where MATCH inhalt AGAINST (t2.inhalt);
+
 --error 1210
-select * from t2 having MATCH ticket AGAINST ('foobar');
+select * from t2 where MATCH inhalt AGAINST (t2.inhalt);
+
+--error 1191
+select * from t2 where MATCH ticket AGAINST ('foobar');
+
 --error 1210
-select * from t2,t3 having MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar');
+select * from t2,t3 where MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar');
 
 drop table t1,t2,t3;
-
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index cef53ce8165..3dc154387f7 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -414,8 +414,8 @@ drop table t1;
 #
 
 CREATE TABLE t1 (a int unsigned NOT NULL) type=innodb;
---error 1031
-INSERT DELAYED INTO t1 VALUES (1);
+# Can't test this in 3.23
+# INSERT DELAYED INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (1);
 SELECT * FROM t1;
 DROP TABLE t1;
@@ -437,7 +437,7 @@ drop table t1;
 create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 LOCK TABLES t1 WRITE;
---error 690
+--error 1062
 insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 select id from t1;
 select id from t1;
@@ -448,7 +448,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 LOCK TABLES t1 WRITE;
 begin;
---error 690
+--error 1062
 insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 select id from t1;
 insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
diff --git a/mysql-test/t/overflow.test b/mysql-test/t/overflow.test
index 7a652257bac..6619a87cabb 100644
--- a/mysql-test/t/overflow.test
+++ b/mysql-test/t/overflow.test
@@ -1,4 +1,4 @@
 connect (con1,localhost,boo,,);
 connection con1;
--- error 1064;
+-- error 1064,1102
 drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
diff --git a/sql/ha_gemini.cc b/sql/ha_gemini.cc
index e80d9a001e6..75ffe4bd0ee 100644
--- a/sql/ha_gemini.cc
+++ b/sql/ha_gemini.cc
@@ -955,7 +955,7 @@ int ha_gemini::handleIndexEntry(const byte * record, dsmRecid_t recid,
 
   thd = current_thd;
   key_info=table->key_info+keynr;
-  thereIsAnull = false;
+  thereIsAnull = FALSE;
   rc = createKeyString(record, key_info, theKey.akey.keystr,
                           sizeof(theKey.apad),&keyStringLen,
                           (short)pindexNumbers[keynr],
@@ -1067,7 +1067,7 @@ int ha_gemini::createKeyString(const byte * record, KEY *pkeyinfo,
 
     isNull = record[key_part->null_offset] & key_part->null_bit;
     if(isNull)
-      *thereIsAnull = true;
+      *thereIsAnull = TRUE;
 
     rc = gemFieldToIdxComponent(pos,
                                 (unsigned long) key_part_length,
@@ -1107,7 +1107,7 @@ int ha_gemini::update_row(const byte * old_record, byte * new_record)
   }
   for (uint keynr=0 ; keynr < table->keys ; keynr++)
   {
-    if(key_cmp(keynr,old_record, new_record,false))
+    if(key_cmp(keynr,old_record, new_record,FALSE))
     {
       error = handleIndexEntry(old_record,lastRowid,KEY_DELETE,keynr);
       if(error)
@@ -2430,8 +2430,8 @@ int ha_gemini::analyze(THD* thd, HA_CHECK_OPT* check_opt)
   uint 	 saveIsolation;
   dsmMask_t saveLockMode;
 
-  check_opt->quick = true;
-  check_opt->optimize = true; // Tells check not to get table lock
+  check_opt->quick = TRUE;
+  check_opt->optimize = TRUE; // Tells check not to get table lock
   saveLockMode = lockMode;
   saveIsolation = thd->gemini.tx_isolation;
   thd->gemini.tx_isolation = ISO_READ_UNCOMMITTED;
@@ -2503,7 +2503,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt)
 	error = fetch_row(thd->gemini.context,buf);
         if(!error)
 	{
-	  if(key_cmp(i,buf,indexBuf,false))
+	  if(key_cmp(i,buf,indexBuf,FALSE))
 	  {
 
             gemini_msg((dsmContext_t *)thd->gemini.context, 
@@ -2534,7 +2534,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt)
 	}
       }
 
-      key_cmp(i,indexBuf,prevBuf,true);
+      key_cmp(i,indexBuf,prevBuf,TRUE);
       bcopy((void *)indexBuf,(void *)prevBuf,table->rec_buff_length);
 
       if(!error)
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 816997f5266..59a8b156ab2 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -177,19 +177,19 @@
 "Can't write, because of unique constraint, to table '%-.64s'",
 "BLOB column '%-.64s' used in key specification without a key length",
 "All parts of a PRIMARY KEY must be NOT NULL;  If you need NULL in a key, use UNIQUE instead",
-"Result consisted of more than one row",
+"Tulemis on rohkem kui �ks kirje",
 "This table type requires a primary key",
 "Antud MySQL ei ole kompileeritud RAID-i toega",
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
-"Can't open table",
-"The handler for the table doesn't support check/repair",
-"You are not allowed to execute this command in a transaction",
-"Got error %d during COMMIT",
-"Got error %d during ROLLBACK",
-"Got error %d during FLUSH_LOGS",
-"Got error %d during CHECKPOINT",
-"Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)",
+"Ei suuda tabelit avada",
+"See tabelit��p ei toeta k�ske CHECK/REPAIR",
+"Puudub �igus selle transaktsioonik�su andmiseks",
+"Sain vea %d COMMIT k�su t�itmisel",
+"Sain vea %d ROLLBACK k�su t�itmisel",
+"Sain vea %d FLUSH_LOGS k�su t�itmisel",
+"Sain vea %d CHECKPOINT k�su t�itmisel",
+"�hendus %ld katkestatud andmebaas: '%-.64s' kasutaja: '%-.32s' masin: `%-.64s' (%-.64s)",
 "The handler for the table does not support binary table dump",
 "Binlog closed while trying to FLUSH MASTER",
 "Failed rebuilding the index of dumped table '%-.64s'",
@@ -198,9 +198,9 @@
 "Net error writing to master",
 "Can't find FULLTEXT index matching the column list",
 "Can't execute the given command because you have active locked tables or an active transaction",
-"Unknown system variable '%-.64'",
-"Table '%-.64s' is marked as crashed and should be repaired",
-"Table '%-.64s' is marked as crashed and last (automatic?) repair failed",
+"Tundmatu s�steemne muutja '%-.64'",
+"Tabel '%-.64s' on m�rgitud vigaseks ja tuleb parandada",
+"Tabel '%-.64s' on m�rgitud vigaseks ja viimane (automaatne?) parandamiskatse eba�nnestus",
 "Warning:  Some non-transactional changed tables couldn't be rolled back",
 "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
 "This operation cannot be performed with a running slave, run SLAVE STOP first",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 79380cbc501..5914ea31188 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -205,11 +205,11 @@
 "Kunde inte initializera replications-strukturerna. Kontrollera privilegerna f�r 'master.info'",
 "Kunde inte starta en tr�d f�r replikering",
 "Anv�ndare '%-.64s' har redan 'max_user_connections' aktiva inloggningar",
-"Du kan endast anv�nda konstant-uttryck med SET",
-"Lock wait timeout exceeded",
-"The total number of locks exceeds the lock table size",
-"Update locks cannot be acquired during a READ UNCOMMITTED transaction",
-"DROP DATABASE not allowed while thread is holding global read lock",
-"CREATE DATABASE not allowed while thread is holding global read lock",
+"Man kan endast anv�nda konstant-uttryck med SET",
+"Fick inte ett l�s i tid",
+"Antal l�s �verskrider antalet reserverade l�s",
+"Updaterings-l�s kan inte g�ras n�r man anv�nder READ UNCOMMITTED",
+"DROP DATABASE �r inte till�tet n�r man har ett globalt l�s-l�s",
+"CREATE DATABASE �r inte till�tet n�r man har ett globalt l�s-l�s",
 "Felaktiga argument till %s",
-"%-.32s@%-.64s is not allowed to create new users",
+"%-.32s@%-.64s har inte r�ttigheter att skapa nya anv�ndare",
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1e42e776d44..8c3f2759e9a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2667,7 +2667,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
     DBUG_RETURN(0);
   }
 
-#ifdef FN_LOWER_CASE
+#ifdef FN_NO_CASE_SENCE
   if (!alias)					/* Alias is case sensitive */
     if (!(alias_str=sql_strmake(alias_str,table->table.length)))
       DBUG_RETURN(0);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 44372ad4800..ca703cca4c5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1125,7 +1125,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
   {
     strmov(new_name_buff,new_name);
     fn_same(new_name_buff,table_name,3);
-#ifdef FN_LOWER_CASE
+#ifdef FN_NO_CASE_SENCE
     if (lower_case_table_names)
       casedn_str(new_name);
     if ((lower_case_table_names &&
@@ -1709,7 +1709,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
   /* Turn off recovery logging since rollback of an
      alter table is to delete the new table so there
      is no need to log the changes to it.              */
-  error = ha_recovery_logging(thd,false);
+  error = ha_recovery_logging(thd,FALSE);
   if (error)
   {
     error = 1;
@@ -1761,7 +1761,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
   if (to->file->activate_all_index(thd))
     error=1;
 
-  tmp_error = ha_recovery_logging(thd,true);
+  tmp_error = ha_recovery_logging(thd,TRUE);
   /*
     Ensure that the new table is saved properly to disk so that we
     can do a rename
@@ -1773,7 +1773,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
   if (to->file->external_lock(thd,F_UNLCK))
     error=1;
  err:
-  tmp_error = ha_recovery_logging(thd,true);
+  tmp_error = ha_recovery_logging(thd,TRUE);
   free_io_cache(from);
   *copied= found_count;
   *deleted=delete_count;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 3edfdd3d5ef..c4c2855a63e 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -189,7 +189,10 @@ TEST_join(JOIN *join)
 
 void mysql_print_status(THD *thd)
 {
+  char current_dir[FN_REFLEN];
   printf("\nStatus information:\n\n");
+  my_getwd(current_dir, sizeof(current_dir),MYF(0));
+  printf("Current dir: %s\n", current_dir);
   if (thd)
     thd->proc_info="locks";
   thr_print_locks();				// Write some debug info
diff --git a/strings/strto.c b/strings/strto.c
index eb8caab2ab6..e2423ed2340 100644
--- a/strings/strto.c
+++ b/strings/strto.c
@@ -42,13 +42,13 @@
 #include "my_sys.h"			/* defines errno */
 #include <errno.h>
 
-#ifdef LONGLONG
+#ifdef USE_LONGLONG
 #define UTYPE_MAX (~(ulonglong) 0)
 #define TYPE_MIN LONGLONG_MIN
 #define TYPE_MAX LONGLONG_MAX
 #define longtype longlong
 #define ulongtype ulonglong
-#ifdef UNSIGNED
+#ifdef USE_UNSIGNED
 #define function ulongtype strtoull
 #else
 #define function longtype strtoll
@@ -59,7 +59,7 @@
 #define TYPE_MAX LONG_MAX
 #define longtype long
 #define ulongtype unsigned long
-#ifdef UNSIGNED
+#ifdef USE_UNSIGNED
 #define function ulongtype strtoul
 #else
 #define function longtype strtol
@@ -170,7 +170,7 @@ function (const char *nptr,char **endptr,int base)
   if (endptr != NULL)
     *endptr = (char *) s;
 
-#ifndef UNSIGNED
+#ifndef USE_UNSIGNED
   /* Check for a value that is within the range of
      `unsigned long int', but outside the range of `long int'.	*/
   if (negative)
@@ -185,7 +185,7 @@ function (const char *nptr,char **endptr,int base)
   if (overflow)
   {
     my_errno=ERANGE;
-#ifdef UNSIGNED
+#ifdef USE_UNSIGNED
     return UTYPE_MAX;
 #else
     return negative ? TYPE_MIN : TYPE_MAX;
diff --git a/strings/strtoll.c b/strings/strtoll.c
index f43dae726f5..678c28649ef 100644
--- a/strings/strtoll.c
+++ b/strings/strtoll.c
@@ -19,7 +19,7 @@
 
 #include <global.h>
 #include <m_string.h>
-#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
-#define LONGLONG
+#if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG)
+#define USE_LONGLONG
 #include "strto.c"
 #endif
diff --git a/strings/strtoul.c b/strings/strtoul.c
index bbfaa6ad22a..e49a9ebea6a 100644
--- a/strings/strtoul.c
+++ b/strings/strtoul.c
@@ -19,6 +19,6 @@
 
 #include <global.h>
 #if !defined(MSDOS) && !defined(HAVE_STRTOUL)
-#define UNSIGNED
+#define USE_UNSIGNED
 #include "strto.c"
 #endif
diff --git a/strings/strtoull.c b/strings/strtoull.c
index 42ce5ea4177..74dab95b801 100644
--- a/strings/strtoull.c
+++ b/strings/strtoull.c
@@ -20,7 +20,7 @@
 #include <global.h>
 #include <m_string.h>
 #if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
-#define UNSIGNED
-#define LONGLONG
+#define USE_UNSIGNED
+#define USE_LONGLONG
 #include "strto.c"
 #endif

From e9ec978e2d58b9fab1871bcb7c223cc9f919a3d7 Mon Sep 17 00:00:00 2001
From: unknown <monty@bitch.mysql.fi>
Date: Sat, 18 Aug 2001 13:11:58 +0300
Subject: [PATCH 10/51] Fix for bug in the Sun Workshop compiler

BUILD/compile-solaris-sparc-purify:
  Build for purify, quantify and purecoverage
---
 BUILD/compile-solaris-sparc-fortre | 19 +++++++++++++++++++
 BUILD/compile-solaris-sparc-purify |  8 ++++++--
 mysys/hash.c                       |  5 ++++-
 3 files changed, 29 insertions(+), 3 deletions(-)
 create mode 100755 BUILD/compile-solaris-sparc-fortre

diff --git a/BUILD/compile-solaris-sparc-fortre b/BUILD/compile-solaris-sparc-fortre
new file mode 100755
index 00000000000..dca0412c979
--- /dev/null
+++ b/BUILD/compile-solaris-sparc-fortre
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+gmake -k clean || true
+/bin/rm -f */.deps/*.P config.cache
+ 
+aclocal && autoheader && aclocal && automake && autoconf
+(cd bdb/dist && sh s_all)
+(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
+if [ -d gemini ]
+then
+   (cd gemini && aclocal && autoheader && aclocal && automake && autoconf)
+fi
+
+PATH=/opt/SUNWspro/bin/:$PATH
+CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt -D_FORTREC_" \
+CXX=CC CXXFLAGS="-noex -xO4 -mt"  \
+./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client
+
+gmake -j 4
diff --git a/BUILD/compile-solaris-sparc-purify b/BUILD/compile-solaris-sparc-purify
index b5c898bff30..91fbbf1ae8d 100755
--- a/BUILD/compile-solaris-sparc-purify
+++ b/BUILD/compile-solaris-sparc-purify
@@ -6,8 +6,12 @@ aclocal && autoheader && aclocal && automake && autoconf
 (cd bdb/dist && sh s_all)
 (cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
 
-CFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug=full --with-berkeley-db --with-innodb
+CFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-berkeley-db --with-innodb
 
 gmake -j 4
 
-cd sql ; rm mysqld ; make CXXLD="purify -best-effort g++"  mysqld
+cd sql ; rm mysqld ;
+make CXXLD="purify -best-effort g++"  mysqld ; mv mysqld mysqld-purify
+make CXXLD="quantify -best-effort g++"  mysqld ; mv mysqld mysqld-quantify
+make CXXLD="purecov -best-effort g++"  mysqld ; mv mysqld mysqld-purecov
+
diff --git a/mysys/hash.c b/mysys/hash.c
index 66fa91811b5..c05379ef4ce 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -180,7 +180,10 @@ uint calc_hashnr_caseup(const byte *key, uint len)
 #endif
 
 
-inline uint rec_hashnr(HASH *hash,const byte *record)
+#ifndef _FORTREC_
+inline
+#endif
+uint rec_hashnr(HASH *hash,const byte *record)
 {
   uint length;
   byte *key=hash_key(hash,record,&length,0);

From a14d63ba6e6b9ee411ac576e513fa31f652138e6 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Sat, 18 Aug 2001 14:24:01 +0300
Subject: [PATCH 11/51] Fix for handling of floats inside val_int() of +, - *
 and /.

Build-tools/Do-compile:
  Make shutdown safer
Docs/manual.texi:
  Fix of bad merge
sql/log.cc:
  cleanup
sql/sql_acl.cc:
  cleanup
---
 Build-tools/Do-compile | 28 ++++++++++++---------
 Docs/manual.texi       | 56 ++++++++++++++++++++++++++++++------------
 sql/item_func.cc       | 54 +++++++++++++++++++++++++---------------
 sql/log.cc             | 10 ++++----
 sql/sql_acl.cc         |  2 +-
 5 files changed, 96 insertions(+), 54 deletions(-)

diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 78b06ed04f3..6f9854a0792 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -68,17 +68,20 @@ delete $ENV{'MY_BASEDIR_VERSION'};
 $ENV{'MYSQL_TCP_PORT'}= $mysql_tcp_port= 3334 + $opt_build_thread;
 $ENV{'MYSQL_UNIX_PORT'}=$mysql_unix_port="$opt_tmp/mysql$opt_suffix.build";
 $ENV{"PERL5LIB"}="$pwd/$host/perl5:$pwd/$host/perl5/site_perl";
+$slave_port=$mysql_tcp_port+16;
+
+if (-x "$host/bin/mysqladmin")
+{
+  log_system("$host/bin/mysqladmin --no-defaults -u root -S $mysql_unix_port -s shutdown");
+  log_system("$host/bin/mysqladmin --no-defaults -u root -P $mysql_tcp_port -h $host -s shutdown");
+  log_system("$host/bin/mysqladmin --no-defaults -u root -P $slave_port -h $host -s shutdown");
+  log_system("$host/bin/mysqladmin --no-defaults -u root -P 9306 -h $host -s shutdown");
+  log_system("$host/bin/mysqladmin --no-defaults -u root -P 9307 -h $host -s shutdown");
+}
 
 if ($opt_stage == 0)
 {
   print "$host: Removing old distribution\n" if ($opt_debug);
-  if (-x "$host/bin/mysqladmin")
-  {
-    log_system("$host/bin/mysqladmin --no-defaults -u root -S $mysql_unix_port -s shutdown");
-    log_system("$host/bin/mysqladmin --no-defaults -u root -P $mysql_tcp_port -h $host -s shutdown");
-    log_system("$host/bin/mysqladmin --no-defaults -u root -P 9306 -h $host -s shutdown");
-    log_system("$host/bin/mysqladmin --no-defaults -u root -P 9307 -h $host -s shutdown");
-  }
   if (!$opt_use_old_distribution)
   {
     system("mkdir $host") if (! -d $host);
@@ -86,7 +89,6 @@ if ($opt_stage == 0)
     rm_all(<$host/mysql-*>);
     system("mkdir $host/bin") if (! -d "$host/bin");
   }
-  system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir);
   rm_all("$host/test");
   system("mkdir $host/test") if (! -d "$host/test");
   system("mkdir Logs") if (! -d "Logs");
@@ -184,13 +186,14 @@ $ENV{"LD_LIBRARY_PATH"}= "$testdir/lib:" . $ENV{"LD_LIBRARY_PATH"};
 
 if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest)
 {
-  my ($slave_port);
-  $slave_port=$mysql_tcp_port+16;
+  system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir);
   safe_cd("${test_dir}/mysql-test");
   check_system("./mysql-test-run --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --sleep=10", "tests were successful");
 }
 
-if ($opt_stage <= 6 && !$opt_no_test)
+# Start the server if we are going to run any of the benchmarks
+
+if (!$opt_no_test)
 {
   my $extra;
   safe_cd($test_dir);
@@ -207,10 +210,11 @@ if ($opt_stage <= 6 && !$opt_no_test)
   {
     $extra.=" --innodb_data_file_path=ibdata1:100M";
   }
-  safe_system("./bin/mysqld --no-defaults --basedir . --datadir ./data --skip-locking $extra >> $log 2>&1 &");
+  safe_system("./bin/mysqld --no-defaults --basedir . --datadir ./data --skip-l\ocking $extra >> $log 2>&1 &");
   sleep(2);
 }
 
+
 if ($opt_stage <= 7 && $opt_perl_files && !$opt_no_perl && !$opt_no_test)
 {
   safe_cd($test_dir);
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 75f02608cc5..25b80fde8a9 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -1523,7 +1523,7 @@ MySQL
 @subheading Tutorials and Manuals
 
 @table @asis
-@item @uref{http://netgraft.com/~mbac/research/mysqlmyths.html, MySQL Myths Debunked}
+@item @uref{http://michael.bacarella.com/research/mysqlmyths.html, MySQL Myths Debunked}
 MySQL used in the real world.
 
 @item @uref{http://www.4t2.com/mysql}
@@ -9620,7 +9620,7 @@ the @code{max_connections} variable.
 If you build MySQL yourself and do not what to mess with patching
 LinuxThreads, you should set @code{max_connections} to a value no higher 
 than 500.  It should be even less if you have a large key buffer,  large 
-heap tables, or some other things that make @strong{mysqld} allocate a lot 
+heap tables, or some other things that make @code{mysqld} allocate a lot 
 of memory or if you are running a 2.2 kernel with a 2GB patch. If you are 
 using our binary or RPM version 3.23.25 or later, you can safely set
 @code{max_connections} at 1500, assuming no large key buffer or heap tables 
@@ -10031,8 +10031,15 @@ make
 make_install
 @end example
 
-and @strong{mysqld} should be ready to run.
+and @code{mysqld} should be ready to run.
 
+On Ia64 the MySQL client binaries are using shared libraries. This means
+that if you install our binary distribution in some other place than
+@file{/usr/local/mysql} you need to either modify @file{/etc/ld.so.conf}
+or add the path to the directory where you have @file{libmysqlclient.so}
+to the @code{LD_LIBRARY_PATH} environment variable.
+
+@xref{Link errors}.
 
 @node Windows, Solaris, Linux, Operating System Specific Notes
 @subsection Windows Notes
@@ -10638,7 +10645,7 @@ CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
 If you have a ultra sparc, you can get 4 % more performance by adding
 "-mcpu=v8 -Wa,-xarch=v8plusa" to CFLAGS and CXXFLAGS.
 
-If you have the Sun Workshop (SunPro) 4.2 (or newer) compiler, you can
+If you have Sun Workshop (Fortre) 5.3 (or newer) compiler, you can
 run @code{configure} like this:
 
 @example
@@ -10647,6 +10654,15 @@ CXX=CC CXXFLAGS="-noex -xO4 -mt" \
 ./configure --prefix=/usr/local/mysql --enable-assembler
 @end example
 
+In the MySQL benchmarks, we got a 6 % speedup on an Ultrasparc when
+using Sun Workshop 5.3 compared to using gcc with -mcpu flags.
+
+If you get a problem with @code{fdatasync} or @code{sched_yield},
+you can fix this by adding @code{LIBS=-lrt} to the configure line
+
+The following paragraph is only relevant for older compilers than
+WorkShop 5.3:
+
 You may also have to edit the @code{configure} script to change this line:
 
 @example
@@ -10851,7 +10867,7 @@ Configure MySQL with the @code{--with-named-z-libs=no} option.
 @node Solaris x86,  , Solaris 2.7, Solaris
 @subsubsection Solaris x86 Notes
 
-On Solaris 2.8 on x86, @strong{mysqld} will core dump if you run
+On Solaris 2.8 on x86, @code{mysqld} will core dump if you run
 'strip' in.
 
 If you are using @code{gcc} or @code{egcs} on Solaris x86 and you
@@ -10919,9 +10935,8 @@ It is recommended you use MIT-pthreads on FreeBSD 2.x and native threads on
 Versions 3 and up. It is possible to run with  native threads on some late
 2.2.x versions but you may encounter problems shutting down @code{mysqld}.
 
-The @strong{MYSQL} Makefiles require GNU make (@code{gmake}) to work.
-If you want to compile @strong{MYSQL} you need to install GNU make
-first.
+The MySQL @file{Makefile}s require GNU make (@code{gmake}) to work.  If
+you want to compile MySQL you need to install GNU @code{make} first.
 
 Be sure to have your name resolver setup correct.  Otherwise you may
 experience resolver delays or failures when connecting to @code{mysqld}.
@@ -15499,7 +15514,7 @@ With this option,
 @code{SHOW DATABASES} returns only those databases for which the user has
 some kind of privilege.
 
-@item @code{--safe-user-create}
+@item --safe-user-create
 If this is enabled, an user can't create new users with the @code{GRANT}
 command, if the user doesn't have @code{INSERT} privilege to the
 @code{mysql.user} table.  If you want to give a user access to just create
@@ -21371,7 +21386,7 @@ You can find the MySQL-max binaries at
 @uref{http://www.mysql.com/downloads/mysql-max-3.23.html}.
 
 The Windows MySQL 3.23 binary distribution includes both the
-standard @strong{mysqld.exe} binary and the @code{mysqld-max.exe} binary.
+standard @code{mysqld.exe} binary and the @code{mysqld-max.exe} binary.
 @uref{http://www.mysql.com/downloads/mysql-3.23.html}.
 @xref{Windows installation}.
 
@@ -21388,7 +21403,7 @@ mysql> show variables like "have_%";
 | have_bdb      | YES   |
 | have_innodb   | NO    |
 | have_isam     | YES   |
-| have_raid     | YES   |
+| have_raid     | NO    |
 | have_ssl      | NO    |
 +---------------+-------+
 @end example
@@ -35830,7 +35845,7 @@ stored as the key data + the @code{PRIMARY KEY}, it's important to keep the
 @code{PRIMARY KEY} as short as possible to save disk and get better speed.
 @item
 @code{LOCK TABLES} works on @code{BDB} tables as with other tables.  If
-you don't use @code{LOCK TABLE}, @strong{MYSQL} will issue an internal
+you don't use @code{LOCK TABLE}, MYSQL will issue an internal
 multiple-write lock on the table to ensure that the table will be
 properly locked if another thread issues a table lock.
 @item
@@ -46464,6 +46479,7 @@ users use this code as the rest of the code and because of this we are
 not yet 100% confident in this code.
 
 @menu
+* News-3.23.42::                Changes in release 3.23.42
 * News-3.23.41::                Changes in release 3.23.41
 * News-3.23.40::                Changes in release 3.23.40
 * News-3.23.39::                Changes in release 3.23.39
@@ -46509,8 +46525,19 @@ not yet 100% confident in this code.
 * News-3.23.0::                 Changes in release 3.23.0
 @end menu
 
+@node News-3.23.42, News-3.23.41, News-3.23.x, News-3.23.x
+@appendixsubsec Changes in release 3.23.42
+@itemize @bullet
+@item
+Use real arithmetic operations even in integer context if not
+all arguments are integers. (Fixes uncommon bug in some integer
+context).
+@item
+Don't force everything to lower cases on windows. (To fix problem
+with windows and @code{ALTER TABLE}).
+@end itemize
 
-@node News-3.23.41, News-3.23.40, News-3.23.x, News-3.23.x
+@node News-3.23.41, News-3.23.40, News-3.23.42, News-3.23.x
 @appendixsubsec Changes in release 3.23.41
 
 @itemize @bullet
@@ -46548,9 +46575,6 @@ Added prototypes for @code{my_thread_init()} and @code{my_thread_end()} to
 @item
 Added option @code{--safe-user-create} to @code{mysqld}.
 @item
-Added options to the @code{--ansi} startup options to let the user
-decide which @code{ansi} options one to enable.
-@item
 Fixed bug in @code{SELECT DISTINCT ... HAVING} that casued error message
 @code{Can't find record in '#...}
 @end itemize
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 1d1a72d35eb..ef3372629f6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -259,10 +259,14 @@ double Item_func_plus::val()
 
 longlong Item_func_plus::val_int()
 {
-  longlong value=args[0]->val_int()+args[1]->val_int();
-  if ((null_value=args[0]->null_value || args[1]->null_value))
-    return 0;
-  return value;
+  if (hybrid_type == INT_RESULT)
+  {
+    longlong value=args[0]->val_int()+args[1]->val_int();
+    if ((null_value=args[0]->null_value || args[1]->null_value))
+      return 0;
+    return value;
+  }
+  return (longlong) Item_func_plus::val();
 }
 
 double Item_func_minus::val()
@@ -275,12 +279,17 @@ double Item_func_minus::val()
 
 longlong Item_func_minus::val_int()
 {
-  longlong value=args[0]->val_int() - args[1]->val_int();
-  if ((null_value=args[0]->null_value || args[1]->null_value))
-    return 0;
-  return value;
+  if (hybrid_type == INT_RESULT)
+  {
+    longlong value=args[0]->val_int() - args[1]->val_int();
+    if ((null_value=args[0]->null_value || args[1]->null_value))
+      return 0;
+    return value;
+  }
+  return (longlong) Item_func_minus::val();
 }
 
+
 double Item_func_mul::val()
 {
   double value=args[0]->val()*args[1]->val();
@@ -291,10 +300,14 @@ double Item_func_mul::val()
 
 longlong Item_func_mul::val_int()
 {
-  longlong value=args[0]->val_int()*args[1]->val_int();
-  if ((null_value=args[0]->null_value || args[1]->null_value))
-    return 0; /* purecov: inspected */
-  return value;
+  if (hybrid_type == INT_RESULT)
+  {
+    longlong value=args[0]->val_int()*args[1]->val_int();
+    if ((null_value=args[0]->null_value || args[1]->null_value))
+      return 0; /* purecov: inspected */
+    return value;
+  }
+  return (longlong) Item_func_mul::val();
 }
 
 
@@ -309,14 +322,15 @@ double Item_func_div::val()
 
 longlong Item_func_div::val_int()
 {
-  // the integer result of division of two arguments needs to be computed
-  // as a type-cast division of val(), not as diviion of val_int() of each
-  // argument. For example, val_int(41.5/3.4) = val_int(12.206) = 12, but
-  // if you do val_int(41.5)/val_int(3.4), as in the old code, we get 42/3=
-  // 14, which is wrong. This would break sec_to_time(a/b),
-  // from_unixtime(a/b), and
-  // all functions that do val_int() on their arguments
-  return (longlong)val();
+  if (hybrid_type == INT_RESULT)
+  {
+    longlong value=args[0]->val_int();
+    longlong val2=args[1]->val_int();
+    if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value))
+      return 0;
+    return value/val2;
+  }
+  return (longlong) Item_func_div::val();
 }
 
 void Item_func_div::fix_length_and_dec()
diff --git a/sql/log.cc b/sql/log.cc
index 33e6ba1de45..d7825ce0e93 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -149,11 +149,11 @@ void MYSQL_LOG::init(enum_log_type log_type_arg)
 
 void MYSQL_LOG::close_index()
 {
-  if(index_file >= 0)
-    {
-      my_close(index_file, MYF(0));
-      index_file = -1;
-    }
+  if (index_file >= 0)
+  {
+    my_close(index_file, MYF(0));
+    index_file = -1;
+  }
 }
 
 void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 86d3f61776c..798cd78cab1 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -354,7 +354,7 @@ static uint get_access(TABLE *form,uint fieldnr)
 
 
 /*
- return a number with if sorted put string in this order:
+ return a number which, if sorted 'desc', puts strings in this order:
  no wildcards
  wildcards
  empty string

From 001f7fb5d379dcd38d2d861529301838a6d11e22 Mon Sep 17 00:00:00 2001
From: unknown <tfr@sarvik.tfr.cafe.ee>
Date: Mon, 20 Aug 2001 16:02:11 +0200
Subject: [PATCH 12/51] manual.texi:   Fixed danish SunSite mirror

Docs/manual.texi:
  Fixed danish SunSite mirror
---
 Docs/manual.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 25b80fde8a9..7591af1c00c 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -6333,8 +6333,8 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
 @item
 @c EMAIL: mkp@socsci.auc.dk (Martin Kasper Petersen)
 @image{Flags/denmark} Denmark [SunSITE] @
-@uref{http://SunSITE.auc.dk/mysql/, WWW}
-@uref{ftp://SunSITE.auc.dk/pub/databases/mysql/, FTP}
+@uref{http://mirrors.sunsite.dk/mysql/, WWW}
+@uref{ftp://sunsite.dk/mirrors/mysql/, FTP}
 
 @c @item
 @c T�nu does not work there anymore :-) 990720

From d61418b94fc2f377c11775039bfe5a7106541b3a Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Tue, 21 Aug 2001 20:06:00 +0300
Subject: [PATCH 13/51] Portability fixes. Patches required by Gemini Fix to
 properly detect if there is an active transaction in InnoDB Fix to not lock
 thread structure when doing automatic rollback when thread ends Allow -O
 lower_case_names=0 on UNIX

Docs/manual.texi:
  Some updates from mailing list.
  Changelog
client/mysqlbinlog.cc:
  Removed variables declared in net.c
configure.in:
  Added test for strtoll and fixed test for gethostname_r for AIX
mysql-test/t/innodb.test:
  Added test of active transactions
sql/field.cc:
  Patch required by Gemini
sql/field.h:
  Patch required by Gemini
sql/filesort.cc:
  Patch required by Gemini
sql/gen_lex_hash.cc:
  Update to support new syntax
sql/ha_gemini.cc:
  Patch required by Gemini
sql/ha_gemini.h:
  Patch required by Gemini
sql/ha_innobase.cc:
  Fix to properly detect if there is an active transaction in InnoDB
sql/handler.cc:
  Fix to properly detect if there is an active transaction in InnoDB
sql/handler.h:
  Fix to properly detect if there is an active transaction in InnoDB.
  Fix for Gemini
sql/lex.h:
  SHOW LOCKS
sql/mysqld.cc:
  Fix to not lock thread structure when doing automatic rollback when thread ends.
sql/share/portuguese/errmsg.txt:
  Update
sql/sql_class.cc:
  Fix to not lock thread structure when doing automatic rollback when thread ends.
sql/sql_class.h:
  Fix to properly detect if there is an active transaction in InnoDB
sql/sql_delete.cc:
  Fix for Gemini
sql/sql_parse.cc:
  Allow -O lower_case_names=0 on UNIX
sql/sql_select.cc:
  Fix for Gemini
sql/sql_table.cc:
  Allow -O lower_case_names=0 on UNIX
sql/sql_update.cc:
  Fix for Gemini
sql/sql_yacc.yy:
  For SHOW LOCKS
strings/strto.c:
  Portability fix
---
 Docs/manual.texi                | 46 ++++++++++++++++++++++++++----
 client/mysqlbinlog.cc           |  2 --
 configure.in                    |  4 +--
 mysql-test/t/innodb.test        | 14 +++++++++
 sql/field.cc                    |  2 +-
 sql/field.h                     |  8 ++++++
 sql/filesort.cc                 |  2 ++
 sql/gen_lex_hash.cc             |  2 +-
 sql/ha_gemini.cc                |  1 +
 sql/ha_gemini.h                 |  1 +
 sql/ha_innobase.cc              |  2 +-
 sql/handler.cc                  |  2 ++
 sql/handler.h                   |  2 ++
 sql/lex.h                       |  1 +
 sql/mysqld.cc                   |  7 +++++
 sql/share/portuguese/errmsg.txt | 50 ++++++++++++++++-----------------
 sql/sql_class.cc                | 29 +++++++++++++------
 sql/sql_class.h                 |  5 ++--
 sql/sql_delete.cc               |  2 ++
 sql/sql_parse.cc                |  2 --
 sql/sql_select.cc               |  2 ++
 sql/sql_table.cc                |  4 ---
 sql/sql_update.cc               |  2 ++
 sql/sql_yacc.yy                 |  2 ++
 strings/strto.c                 |  4 +++
 25 files changed, 143 insertions(+), 55 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 25b80fde8a9..a1ddd969b91 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -10714,6 +10714,10 @@ ld: fatal: library -ldl: not found
 or
 
 undefined reference to `dlopen'
+
+or
+
+cannot find -lrt
 @end example
 
 If too many processes try to connect very rapidly to @code{mysqld}, you will
@@ -19875,8 +19879,8 @@ will be incremented. If you are using @code{--log-slow-queries}, the query
 will be logged to the slow query logfile. @xref{Slow query log}.
 
 @item @code{lower_case_table_names}
-If set to 1 table names are stored in lowercase on disk. This will enable
-you to access the table names case-insensitive also on Unix.
+If set to 1 table names are stored in lowercase on disk and table
+names will be case-insensitive.
 @xref{Name case sensitivity}.
 
 @item @code{max_allowed_packet}
@@ -38431,6 +38435,8 @@ is to upgrade to MyODBC Version 2.50.33 and MySQL Version
 You should also get and apply the Microsoft Jet 4.0 Service Pack 5 (SP5)
 which can be found here
 @uref{http://support.microsoft.com/support/kb/articles/Q 239/1/14.ASP}.
+This will fix some cases where columns are marked as @code{#deleted#}
+in Access.
 
 Note that if you are using MySQL Version 3.22, you must to apply the
 MDAC patch and use MyODBC 2.50.32 or 2.50.34 and above to go around
@@ -43273,6 +43279,11 @@ expecting to store the full length of a @code{BLOB} into a table, you'll need
 to start the server with the @code{--set-variable=max_allowed_packet=16M}
 option.
 
+You can also get strange problems with large packets if you are using
+big blobs, but you haven't given @code{mysqld} access to enough memory
+to handle the query.  If you suspect this is the case, try adding
+@code{ulimit -d 256000} to the beginning of the @code{safe_mysqld} script
+and restart @code{mysqld}.
 
 @node Communication errors, Full table, Packet too large, Common errors
 @appendixsubsec Communication Errors / Aborted Connection
@@ -43344,6 +43355,9 @@ Badly configured TCP/IP.
 @item
 Faulty Ethernets or hubs or switches, cables ... This can be diagnosed
 properly only by replacing hardware.
+@item
+@code{max_allowed_packet} is too small or queries require more memory
+than you have alloacated for @code{mysqld}. @xref{Packet too large}.
 @end itemize
 
 
@@ -45719,7 +45733,7 @@ By Steve Shreeve.
 Perl program to convert Oracle databases to MySQL. Has same
 output format as mysqldump. By Johan Andersson.
 
-@item @uref{http://www.mysql.com/Downloads/Contrib/excel2mysql, excel2mysql}
+@item @uref{http://www.mysql.com/Downloads/Contrib/excel2mysql.pl, excel2mysql.pl}
 Perl program to import Excel spreadsheets into a MySQL database. By Stephen Hurd @email{shurd@@sk.sympatico.ca}
 
 @item @uref{http://www.mysql.com/Downloads/Contrib/T2S_100.ZIP, T2S_100.ZIP}.
@@ -46529,12 +46543,22 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixed problem with InnoDB when one could get the error @code{Can't
+execute the given command...} even when one didn't have an active
+transaction.
+@item
+Applied some fixes for Gemini.
+@item
 Use real arithmetic operations even in integer context if not
 all arguments are integers. (Fixes uncommon bug in some integer
 context).
 @item
 Don't force everything to lower cases on windows. (To fix problem
-with windows and @code{ALTER TABLE}).
+with windows and @code{ALTER TABLE}).  Now @code{--lower_case_names}
+also works on Unix.
+@item
+Fixed that automatic rollback that is done when thread end doesn't lock
+other threads.
 @end itemize
 
 @node News-3.23.41, News-3.23.40, News-3.23.42, News-3.23.x
@@ -52045,9 +52069,19 @@ Start the @code{mysqld} server with a trace log in @file{/tmp/mysqld.trace}
 @code{mysqld --debug}
 
 On Windows you should also use the @code{--standalone} flag to not start
-@code{mysqld} as a service.
-Note that the trace file will get very @emph{BIG}!
+@code{mysqld} as a service:
 
+In a DOS window do:
+
+@example
+mysqld --debug --standalone
+@end example
+
+After this you can use the @code{mysql.exe} command line tool in a
+second DOS window to reproduce the problem. You can take down the above
+@code{mysqld} server with @code{mysqladmin shutdown}.
+
+Note that the trace file will get very @emph{BIG}!
 If you want to have a smaller trace file, you can use something like:
 
 @code{mysqld --debug=d,info,error,query,general,where:O,/tmp/mysqld.trace}
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 757e9dce810..f55a5a3f7c4 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -41,8 +41,6 @@ uint32 server_id = 0;
 // needed by net_serv.c
 ulong bytes_sent = 0L, bytes_received = 0L;
 ulong mysqld_net_retry_count = 10L;
-ulong net_read_timeout=  NET_READ_TIMEOUT;
-ulong net_write_timeout= NET_WRITE_TIMEOUT;
 uint test_flags = 0; 
 FILE *result_file;
 
diff --git a/configure.in b/configure.in
index 87a144b4b57..f046251567a 100644
--- a/configure.in
+++ b/configure.in
@@ -1373,7 +1373,7 @@ AC_CHECK_FUNCS(alarm bmove \
  getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \
  perror pread realpath readlink rename \
  socket strnlen madvise mkstemp \
- strtol strtoul strtoull snprintf tempnam thr_setconcurrency \
+ strtol strtoul strtoll strtoull snprintf tempnam thr_setconcurrency \
  gethostbyaddr_r gethostbyname_r getpwnam \
  bfill bzero bcmp strstr strpbrk strerror \
  tell atod memcpy memmove \
@@ -1485,7 +1485,7 @@ AC_TRY_COMPILE(
 #include <netdb.h>],
 [int skr;
 
- skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (hostent_data*) 0);],
+ skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);],
 mysql_cv_gethostname_arg=hostent_data, mysql_cv_gethostname_arg=char))
 AC_LANG_RESTORE
 CXXFLAGS="$ac_save_CXXFLAGS"
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 3dc154387f7..97908aeaa57 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -161,6 +161,20 @@ delete from t1;
 commit;
 select * from t1;
 drop table t1;
+
+#
+# Test of active transactions
+#
+
+create table t1 (a integer) type=innodb;
+begin;
+rename table t1 to t2;
+create table t1 (b integer) type=innodb;
+insert into t1 values (1);
+rollback;
+drop table t1;
+rename table t2 to t1;
+drop table t1;
 set autocommit=1;
 
 #
diff --git a/sql/field.cc b/sql/field.cc
index 78f57c5ceb5..894ef2ab013 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4122,7 +4122,7 @@ ulonglong Field_blob::get_id(const char *from)
   ulonglong id = 0;
   ulong length=get_length(from);
   if (length)
-    longlongget(id, from+packlength);
+    uint8korr(id, from+packlength);
   return id;
 }
 
diff --git a/sql/field.h b/sql/field.h
index b5d7c613701..ee18d2fa7ae 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -874,6 +874,14 @@ public:
                 uint max_length= ~(uint) 0);
   ulonglong get_id(const char *from);
   const char *unpack_id(char *to, const char *from, const char *bdata);
+  inline void get_ptr_from_key_image(char **str,char *key_str)
+  {
+     *str = key_str + sizeof(uint16);
+  }
+  inline uint get_length_from_key_image(char *key_str)
+  {
+    return uint2korr(key_str);
+  }
   enum_field_types blobtype() { return (packlength == 1 ? FIELD_TYPE_TINY_BLOB : FIELD_TYPE_BLOB);}
 #endif
   char *pack_key(char *to, const char *from, uint max_length);
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 610fe2e966f..86c95395965 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -388,6 +388,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
       }
       make_sortkey(param,sort_keys[idx++],ref_pos);
     }
+    else
+      file->unlock_row();
   }
   (void) file->extra(HA_EXTRA_NO_CACHE);	/* End cacheing of records */
   file->rnd_end();
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 4a923e039c4..6bb43ec2970 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -472,7 +472,7 @@ int main(int argc,char **argv)
   int error;
 
   MY_INIT(argv[0]);
-  start_value=2663113L;  best_t1=1175350L;  best_t2=7404531L;  best_type=4; /* mode=4327  add=3  type: 0 */
+  start_value=8214901L;  best_t1=4099790L;  best_t2=2406115L;  best_type=4; /* mode=4799  add=2  type: 0 */
   if (get_options(argc,(char **) argv))
     exit(1);
 
diff --git a/sql/ha_gemini.cc b/sql/ha_gemini.cc
index 75ffe4bd0ee..e8130c55fc7 100644
--- a/sql/ha_gemini.cc
+++ b/sql/ha_gemini.cc
@@ -93,6 +93,7 @@ bool gemini_init(void)
 
     DBUG_ENTER("gemini_init");
 
+    gemini_basedir=mysql_home;
     /* If datadir isn't set, bail out */
     if (*mysql_real_data_home == '\0')
     {
diff --git a/sql/ha_gemini.h b/sql/ha_gemini.h
index 3bfe85bfba2..96c0cdd4241 100644
--- a/sql/ha_gemini.h
+++ b/sql/ha_gemini.h
@@ -205,3 +205,4 @@ int gemini_set_option_long(int optid, long optval);
 const int gemini_blocksize = BLKSIZE;
 const int gemini_recbits = DEFAULT_RECBITS;
 
+extern "C" void uttrace(void);
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index babe281bd4e..fdbc0b107f5 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -2219,7 +2219,7 @@ ha_innobase::external_lock(
 		if (trx->n_mysql_tables_in_use == 0) {
 			trx_mark_sql_stat_end(trx);
 		}
-
+		thd->transaction.all.innodb_active_trans=1;
 		trx->n_mysql_tables_in_use++;
 
 		if (prebuilt->select_lock_type != LOCK_NONE) {
diff --git a/sql/handler.cc b/sql/handler.cc
index bac24a6dba7..bb17d8f2331 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -286,6 +286,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
 	my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
 	error=1;
       }
+      trans->innodb_active_trans=0;
     }
 #endif
 #ifdef HAVE_GEMINI_DB 
@@ -337,6 +338,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
 	my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error);
 	error=1;
       }
+      trans->innodb_active_trans=0;
     }
 #endif
 #ifdef HAVE_GEMINI_DB
diff --git a/sql/handler.h b/sql/handler.h
index 7a28dc07a81..ef78f0af39b 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -128,6 +128,7 @@ typedef struct st_thd_trans {
   void *bdb_tid;
   void *innobase_tid;
   void *gemini_tid;
+  bool innodb_active_trans;
 } THD_TRANS;
 
 enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
@@ -267,6 +268,7 @@ public:
   virtual int extra(enum ha_extra_function operation)=0;
   virtual int reset()=0;
   virtual int external_lock(THD *thd, int lock_type)=0;
+  virtual void unlock_row() {}
   virtual int start_stmt(THD *thd) {return 0;}
   virtual int delete_all_rows();
   virtual longlong get_auto_increment();
diff --git a/sql/lex.h b/sql/lex.h
index d5df5ed5511..ed97eea751f 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -196,6 +196,7 @@ static SYMBOL symbols[] = {
   { "LOAD",		SYM(LOAD),0,0},
   { "LOCAL",		SYM(LOCAL_SYM),0,0},
   { "LOCK",		SYM(LOCK_SYM),0,0},
+  { "LOCKS",		SYM(LOCKS_SYM),0,0},
   { "LOGS",		SYM(LOGS_SYM),0,0},
   { "LONG",		SYM(LONG_SYM),0,0},
   { "LONGBLOB",		SYM(LONGBLOB),0,0},
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 800e1f038f3..57e65025c8f 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -995,6 +995,7 @@ sig_handler end_thread_signal(int sig __attribute__((unused)))
 void end_thread(THD *thd, bool put_in_cache)
 {
   DBUG_ENTER("end_thread");
+  thd->cleanup();
   (void) pthread_mutex_lock(&LOCK_thread_count);
   thread_count--;
   delete thd;
@@ -1189,8 +1190,13 @@ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n",
 
 #ifdef HAVE_STACKTRACE
   if(!(test_flags & TEST_NO_STACKTRACE))
+  {
+#ifdef HAVE_GEMINI_DB
+    utrace();
+#endif
     print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0,
 		     thread_stack);
+  }
   if (thd)
   {
     fprintf(stderr, "Trying to get some variables.\n\
@@ -2054,6 +2060,7 @@ static int bootstrap(FILE *file)
   (void) pthread_mutex_unlock(&LOCK_thread_count);
   error= thd->fatal_error;
   net_end(&thd->net);
+  thd->cleanup();
   delete thd;
   return error;
 }
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index ae36c738606..9bb32287543 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -1,6 +1,6 @@
 /* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB
    This file is public domain and comes with NO WARRANTY of any kind */
-/* Updated by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */
+/* Updated by Roberto de Martin Serqueira - martinsc@uol.com.br - 08.20.2001 */
 "hashchk",
 "isamchk",
 "n�o",
@@ -35,14 +35,14 @@
 "Manipulador de tabela para '%-.64s' n�o tem esta op��o",
 "N�o pode encontrar registro em '%-.64s'",
 "Informa��o incorreta no arquivo '%-.64s'",
-"Arquivo chave incorreto para tabela '%-.64s'. Tente reparar",
+"Arquivo de �ndice incorreto para tabela '%-.64s'. Tente reparar",
 "Arquivo chave desatualizado para tabela '%-.64s'. Repare-o!",
 "Tabela '%-.64s' � somente para leitura",
 "Sem mem�ria. Reinicie o programa e tente novamente (necessita de %d bytes)",
 "Sem mem�ria para ordena��o. Aumente tamanho do 'buffer' de ordena��o",
 "Encontrado fim de arquivo inesperado ao ler arquivo '%-.64s' (erro no. %d)",
 "Excesso de conex�es",
-"Sem mem�ria. Verifique se o mysqld ou algum outro processo est� usando toda mem�ria dispon�vel. Se n�o, voc� pode ter que usar 'ulimit' para permitir ao mysqld usar mais mem�ria ou se voc� pode adicionar mais �rea de 'swap'",
+"Sem mem�ria. Verifique se o mysqld ou algum outro processo est� usando toda mem�ria dispon�vel. Se n�o, voc� pode ter que usar 'ulimit' para permitir ao mysqld usar mais mem�ria ou voc� pode adicionar mais �rea de 'swap'",
 "N�o pode obter nome do 'host' para seu endere�o",
 "Negocia��o de acesso falhou",
 "Acesso negado para o usu�rio '%-.32s@%-.64s' ao banco de dados '%-.64s'",
@@ -58,7 +58,7 @@
 "Coluna '%-.64s' desconhecida em '%-.64s'",
 "'%-.64s' n�o est� em 'GROUP BY'",
 "N�o pode agrupar em '%-.64s'",
-"Cl�usula cont�m fun��es de soma e colunas juntos",
+"Cl�usula cont�m fun��es de soma e colunas juntas",
 "Contagem de colunas n�o confere com a contagem de valores",
 "Nome identificador '%-.100s' � longo demais",
 "Nome da coluna '%-.64s' duplicado",
@@ -72,27 +72,27 @@
 "Definida mais de uma chave prim�ria",
 "Especificadas chaves demais. O m�ximo permitido s�o %d chaves",
 "Especificadas partes de chave demais. O m�ximo permitido s�o %d partes",
-"Chave especificada longa demais. O comprimento m�ximo permitido � %d",
+"Chave especificada longa demais. O comprimento de chave m�ximo permitido � %d",
 "Coluna chave '%-.64s' n�o existe na tabela",
 "Coluna BLOB '%-.64s' n�o pode ser utilizada na especifica��o de chave para o tipo de tabela usado",
 "Comprimento da coluna '%-.64s' grande demais (max = %d). Use BLOB em seu lugar",
-"Defini��o incorreta de tabela. Somente � permitido um campo auto-incrementado e ele tem que ser definido como chave",
+"Defini��o incorreta de tabela. Somente � permitido um �nico campo auto-incrementado e ele tem que ser definido como chave",
 "%s: Pronto para conex�es\n",
 "%s: 'Shutdown' normal\n",
 "%s: Obteve sinal %d. Abortando!\n",
 "%s: 'Shutdown' completo\n",
 "%s: For�ando finaliza��o da 'thread' %ld - usu�rio '%-.32s'\n",
-"N�o pode criar 'socket' IP",
+"N�o pode criar 'IP socket'",
 "Tabela '%-.64s' n�o possui um �ndice como o usado em CREATE INDEX. Recrie a tabela",
 "Argumento separador de campos n�o � o esperado. Confira no manual",
 "Voc� n�o pode usar comprimento de linha fixo com BLOBs. Favor usar 'fields terminated by'",
-"Arquivo '%-.64s' tem que estar no diret�rio do banco de dados ou ter leitura permitida para todos",
+"Arquivo '%-.64s' tem que estar no diret�rio do banco de dados ou ter leitura poss�vel para todos",
 "Arquivo '%-.80s' j� existe",
 "Registros: %ld - Deletados: %ld - Ignorados: %ld - Avisos: %ld",
 "Registros: %ld - Duplicados: %ld",
-"Parte de chave incorreta. A parte de chave usada n�o � um 'string' ou o comprimento usado � maior do que a parte de chave",
+"Parte de chave incorreta. A parte de chave usada n�o � um 'string' ou o comprimento usado � maior do que a parte de chave ou o manipulador de tabelas n�o aceita partes de chaves �nicas",
 "Voc� n�o pode deletar todas as colunas com ALTER TABLE. Use DROP TABLE em seu lugar",
-"N�o pode fazer DROP '%-.64s'. Confira se este campo/chave existe",
+"N�o pode fazer DROP '%-.64s'. Confira se esta coluna/chave existe",
 "Registros: %ld - Duplicados: %ld - Avisos: %ld",
 "INSERT TABLE '%-.64s' n�o � permitido em lista de tabelas FROM",
 "'Id' de 'thread' %lu desconhecido",
@@ -112,14 +112,14 @@
 "Par�metros incorretos para a 'procedure' '%-.64s'",
 "Tabela '%-.64s' desconhecida em '%-.32s'",
 "Coluna '%-.64s' especificada duas vezes",
-"Uso inv�lido da fun��o GROUP",
+"Uso inv�lido de fun��o de grupo",
 "Tabela '%-.64s' usa uma extens�o que n�o existe nesta vers�o do MySQL",
 "Uma tabela tem que ter pelo menos uma (1) coluna",
 "Tabela '%-.64s' est� cheia",
 "Conjunto de caracteres '%-.64s' desconhecido",
 "Tabelas demais. O MySQL pode usar somente %d tabelas em um JOIN",
 "Colunas demais",
-"Tamanho de linha grande demais. O m�ximo tamanho de linha, n�o contando BLOBs, � de %d. Voc� tem que mudar alguns campos para BLOBs",
+"Tamanho de linha grande demais. O m�ximo tamanho de linha, n�o contando BLOBs, � %d. Voc� tem que mudar alguns campos para BLOBs",
 "Estouro da pilha do 'thread'. Usados %ld de uma pilha de %ld . Use 'mysqld -O thread_stack=#' para especificar uma pilha maior, se necess�rio",
 "Depend�ncia cruzada encontrada em OUTER JOIN.  Examine suas condi��es ON",
 "Coluna '%-.64s' � usada com UNIQUE ou INDEX, mas n�o est� definida como NOT NULL",
@@ -136,7 +136,7 @@
 "Voc� tem que ter o privil�gio para atualizar tabelas no banco de dados mysql para ser capaz de mudar a senha de outros",
 "N�o pode encontrar nenhuma linha que combine na tabela user",
 "Linhas que combinaram: %ld - Alteradas: %ld - Avisos: %ld",
-"N�o pode criar uma nova 'thread' (erro no. %d). Se voc� n�o estiver sem mem�ria dispon�vel, voc� pode consultar o manual sobre uma poss�vel falha dependente do sistema operacional",
+"N�o pode criar uma nova 'thread' (erro no. %d). Se voc� n�o estiver sem mem�ria dispon�vel, voc� pode consultar o manual sobre um poss�vel 'bug' dependente do sistema operacional",
 "Contagem de colunas n�o confere com a contagem de valores na linha %ld",
 "N�o pode reabrir a tabela '%-.64s',
 "Uso inv�lido do valor NULL",
@@ -151,22 +151,22 @@
 "N�o existe tal 'grant' definido para o usu�rio '%-.32s' no 'host' '%-.64s', na tabela '%-.64s'",
 "Comando usado n�o � permitido para esta vers�o do MySQL",
 "Voc� tem um erro de sintaxe no seu SQL",
-"'Thread' de inser��o retardada ('delayed') n�o conseguiu obter trava solicitada na tabela '%-.64s'",
+"'Thread' de inser��o retardada ('delayed') n�o conseguiu obter trava solicitada para tabela '%-.64s'",
 "Excesso de 'threads' retardadas ('delayed') em uso",
 "Conex�o %ld abortou para o banco de dados '%-.64s' - usu�rio '%-.32s' (%-.64s)",
 "Obteve um pacote maior do que 'max_allowed_packet'",
-"Obteve um erro de leitura no 'pipe' de conex�o",
+"Obteve um erro de leitura no 'pipe' da conex�o",
 "Obteve um erro em fcntl()",
 "Obteve pacotes fora de ordem",
 "N�o conseguiu descomprimir pacote de comunica��o",
 "Obteve um erro na leitura de pacotes de comunica��o",
 "Obteve expira��o de tempo ('timeout') na leitura de pacotes de comunica��o",
-"Obteve um erro na grava��o de pacotes de comunica��o",
+"Obteve um erro na escrita de pacotes de comunica��o",
 "Obteve expira��o de tempo ('timeout') na escrita de pacotes de comunica��o",
 "'String' resultante � mais longa do que 'max_allowed_packet'",
 "Tipo de tabela usado n�o permite colunas BLOB/TEXT",
 "Tipo de tabela usado n�o permite colunas AUTO_INCREMENT",
-"INSERT DELAYED n�o pode ser usado com a tabela '%-.64s', porque est� travada com LOCK TABLES",
+"INSERT DELAYED n�o pode ser usado com a tabela '%-.64s', porque ela est� travada com LOCK TABLES",
 "Nome de coluna '%-.100s' incorreto",
 "O manipulador de tabela usado n�o pode indexar a coluna '%-.64s'",
 "Tabelas no MERGE n�o est�o todas definidas identicamente",
@@ -176,7 +176,7 @@
 "O resultado consistiu em mais do que uma linha",
 "Este tipo de tabela requer uma chave prim�ria",
 "Esta vers�o do MySQL n�o foi compilada com suporte a RAID",
-"Voc� est� usando modo de atualiza��o seguro e tentou atualizar uma tabela sem um WHERE que use uma coluna tipo KEY",
+"Voc� est� usando modo de atualiza��o seguro e tentou atualizar uma tabela sem um WHERE que use uma coluna de KEY",
 "Chave '%-.64s' n�o existe na tabela '%-.64s'",
 "N�o pode abrir a tabela",
 "O manipulador de tabela n�o suporta check/repair",
@@ -188,7 +188,7 @@
 "Conex�o %ld abortada ao banco de dados '%-.64s' - usu�rio '%-.32s' - 'host' `%-.64s' ('%-.64s')",
 "O manipulador de tabela n�o suporta DUMP bin�rio de tabela",
 "Binlog fechado. N�o pode fazer RESET MASTER",
-"Falhou na reconstru��o do �ndice da tabela 'dumped' '%-.64s'",
+"Falhou na reconstru��o do �ndice da tabela '%-.64s'  'dumped'",
 "Erro no 'master' '%-.64s'",
 "Erro de rede na leitura do 'master'",
 "Erro de rede na grava��o do 'master'",
@@ -207,9 +207,9 @@
 "Usu�rio '%-.64s' j� possui 'max_user_connections' conex�es ativas",
 "Voc� pode usar apenas express�es de constante com SET",
 "Excedido tempo de espera (timeout) do travamento",
-"O n�mero total de travamentos excede o tamanho de travamento da tabela",
-"Travamentos de atualiza��o n�o podem ser obtidos durante um READ UNCOMMITTED na transa��o",
-"DROP DATABASE n�o permitido enquanto uma 'thread' est� assegurando um travamento global de leitura",
-"CREATE DATABASE n�o permitido enquanto uma 'thread' est� assegurando um travamento global de leitura",
-"Wrong arguments to %s",
-"%-.32s@%-.64s is not allowed to create new users",
+"O n�mero total de travamentos excede o tamanho da tabela de travamentos",
+"Travamentos de atualiza��o n�o podem ser obtidos durante uma transa��o de READ UNCOMMITTED",
+"DROP DATABASE n�o permitido enquanto uma 'thread' est� mantendo um travamento global de leitura",
+"CREATE DATABASE n�o permitido enquanto uma 'thread' est� mantendo um travamento global de leitura",
+"Argumentos errados para %s",
+"N�o � permitido a %-.32s@%-.64s criar novos usu�rios",
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index efe0d7864b9..c57b59f55a6 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -101,7 +101,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
   mysys_var=0;
   net.vio=0;
   ull=0;
-  system_thread=0;
+  system_thread=cleanup_done=0;
 #ifdef	__WIN__
   real_id = 0;
 #endif
@@ -149,15 +149,11 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
 #endif
 }
 
-THD::~THD()
+/* Do operations that may take a long time */
+
+void THD::cleanup(void)
 {
-  DBUG_ENTER("~THD()");
-  /* Close connection */
-  if (net.vio)
-  {
-    vio_delete(net.vio);
-    net_end(&net); 
-  }
+  DBUG_ENTER("THD::cleanup");
   ha_rollback(this);
   if (locked_tables)
   {
@@ -172,6 +168,21 @@ THD::~THD()
     ha_close_connection(this);
   }
 #endif
+  cleanup_done=1;
+  DBUG_VOID_RETURN;
+}
+
+THD::~THD()
+{
+  DBUG_ENTER("~THD()");
+  /* Close connection */
+  if (net.vio)
+  {
+    vio_delete(net.vio);
+    net_end(&net); 
+  }
+  if (!cleanup_done)
+    cleanup();
   if (global_read_lock)
   {
     pthread_mutex_lock(&LOCK_open);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 4ccbeb6f01f..bbf6fe08d88 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -283,7 +283,7 @@ public:
   bool	     no_errors, allow_sum_func, password, fatal_error;
   bool	     query_start_used,last_insert_id_used,insert_id_used;
   bool	     system_thread,in_lock_tables,global_read_lock;
-  bool       query_error, bootstrap;
+  bool       query_error, bootstrap, cleanup_done;
   bool	     volatile killed;
   LOG_INFO*  current_linfo;
   // if we do a purge of binary logs, log index info of the threads
@@ -295,6 +295,7 @@ public:
 
   THD();
   ~THD();
+  void cleanup(void);
   bool store_globals();
 #ifdef SIGNAL_WITH_VIO_CLOSE
   inline void set_active_vio(Vio* vio)
@@ -360,7 +361,7 @@ public:
   {
 #ifdef USING_TRANSACTIONS    
     return (transaction.all.bdb_tid != 0 ||
-	    transaction.all.innobase_tid != 0 || 
+	    transaction.all.innodb_active_trans != 0 || 
 	    transaction.all.gemini_tid != 0);
 #else
     return 0;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 8b4b1b527ca..af658ad0346 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -216,6 +216,8 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit,
 	break;
       }
     }
+    else
+      table->file->unlock_row();  // Row failed selection, release lock on it
   }
   thd->proc_info="end";
   end_read_record(&info);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 8c3f2759e9a..796b571722f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2667,13 +2667,11 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
     DBUG_RETURN(0);
   }
 
-#ifdef FN_NO_CASE_SENCE
   if (!alias)					/* Alias is case sensitive */
     if (!(alias_str=sql_strmake(alias_str,table->table.length)))
       DBUG_RETURN(0);
   if (lower_case_table_names)
     casedn_str(table->table.str);
-#endif
   if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
     DBUG_RETURN(0);				/* purecov: inspected */
   ptr->db= table->db.str;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 51020558f75..b30cb6bb639 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4130,6 +4130,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
 	  if (not_used_in_distinct && found_records != join->found_records)
 	    return 0;
 	}
+	else
+	  info->file->unlock_row();
       }
     } while (!(error=info->read_record(info)));
     if (error > 0)				// Fatal error
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index ca703cca4c5..1728427370f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1125,16 +1125,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
   {
     strmov(new_name_buff,new_name);
     fn_same(new_name_buff,table_name,3);
-#ifdef FN_NO_CASE_SENCE
     if (lower_case_table_names)
       casedn_str(new_name);
     if ((lower_case_table_names &&
 	 !my_strcasecmp(new_name_buff,table_name)) ||
 	(!lower_case_table_names &&
 	 !strcmp(new_name_buff,table_name)))
-#else
-    if (!strcmp(new_name_buff,table_name))	// Check if name changed
-#endif
       new_name=table_name;			// No. Make later check easier
     else
     {
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index c41586c58c8..2e9a3c5e355 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -259,6 +259,8 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List<Item> &fields,
 	}
       }
     }
+    else
+      table->file->unlock_row();
   }
   end_read_record(&info);
   thd->proc_info="end";
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 9ab97d52650..5a1c6baf1e4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -121,6 +121,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	KILL_SYM
 %token	LOAD
 %token	LOCK_SYM
+%token	LOCKS_SYM
 %token	UNLOCK_SYM
 
 %token	ACTION
@@ -2560,6 +2561,7 @@ keyword:
 	| INNOBASE_SYM		{}
 	| LEVEL_SYM		{}
 	| LOCAL_SYM		{}
+	| LOCKS_SYM		{}
 	| LOGS_SYM		{}
 	| MAX_ROWS		{}
 	| MASTER_SYM		{}
diff --git a/strings/strto.c b/strings/strto.c
index e2423ed2340..64b1c9a5ae9 100644
--- a/strings/strto.c
+++ b/strings/strto.c
@@ -42,6 +42,10 @@
 #include "my_sys.h"			/* defines errno */
 #include <errno.h>
 
+#undef strtoull
+#undef strtoll
+#undef strtoul
+#undef strtol
 #ifdef USE_LONGLONG
 #define UTYPE_MAX (~(ulonglong) 0)
 #define TYPE_MIN LONGLONG_MIN

From 31b9e6e03f8fe4be1816c3f33aaefb9a931dcef3 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Wed, 22 Aug 2001 01:45:07 +0300
Subject: [PATCH 14/51] Fixes for OS2. Fix bug in isamlog Add argument types to
 function declarations.

Docs/manual.texi:
  Updated credits
client/mysql.cc:
  Fixes for OS2
client/mysqladmin.c:
  Fixes for OS2
client/mysqldump.c:
  Fixes for OS2
client/mysqlimport.c:
  Fixes for OS2
client/mysqltest.c:
  Fixes for OS2
dbug/dbug.c:
  Fixes for OS2.
  Use new C calling convention.
dbug/factorial.c:
  Fixes for OS2.
  Use new C calling convention.
include/errmsg.h:
  Fix for OS2
include/global.h:
  Fixes for OS2.
include/my_pthread.h:
  Fixes for OS2.
include/my_sys.h:
  Fixes for OS2.
include/mysql_com.h:
  Move defines to global.h
include/thr_alarm.h:
  Fixes for OS2.
isam/isamchk.c:
  Fixes for OS2.
  Add arguments to function declarations.
isam/isamlog.c:
  Fixes for OS2.
  Fix bug in logfile handling.
isam/test1.c:
  Add arguments to function decl
isam/test2.c:
  Add arguments to function declarations.
isam/test_all.res:
  Update result
libmysql/get_password.c:
  Fixes for OS2.
libmysql/libmysql.c:
  Fixes for OS2.
libmysql/net.c:
  Fixes for OS2.
libmysql/violite.c:
  Add arguments to function declarations.
merge/_locking.c:
  Add argument types to function declarations.
merge/close.c:
  Add argument types to function declarations.
merge/create.c:
  Add argument types to function declarations.
merge/extra.c:
  Add argument types to function declarations.
merge/open.c:
  Add argument types to function declarations.
merge/panic.c:
  Add argument types to function declarations.
merge/rsame.c:
  Add argument types to function declarations.
merge/update.c:
  Add argument types to function declarations.
myisam/ft_eval.c:
  Portability fix
myisam/ft_search.c:
  Portability fix
myisam/ft_test1.c:
  Portability fix
myisam/ftdefs.h:
  Portability fix
myisam/mi_check.c:
  Portability fix
myisam/mi_test1.c:
  Portability fix
myisam/mi_test2.c:
  Portability fix
myisam/mi_test_all.sh:
  Update to test for MACH variable
myisam/myisamlog.c:
  Cleanup
myisam/myisampack.c:
  Don't use variable 'new'
myisam/sort.c:
  Portability fix
myisammrg/myrg_delete.c:
  Add argument types to function declarations.
myisammrg/myrg_locking.c:
  Add argument types to function declarations.
myisammrg/myrg_open.c:
  Add argument types to function declarations.
myisammrg/myrg_panic.c:
  Add argument types to function declarations.
mysql-test/t/backup.test:
  Fix for OS2
mysql-test/t/show_check.test:
  Fix for OS2
mysys/charset.c:
  Dont use variable 'new'
mysys/default.c:
  Fixes for OS2.
mysys/getopt.c:
  Fixes for OS2.
mysys/getopt1.c:
  Fixes for OS2.
mysys/list.c:
  Don't use variable 'new'
mysys/mf_dirname.c:
  Fixes for OS2.
mysys/mf_format.c:
  Fixes for OS2.
mysys/mf_path.c:
  Fixes for OS2.
mysys/mf_qsort.c:
  Portability fix
mysys/mf_tempfile.c:
  Fixes for OS2.
mysys/my_clock.c:
  Fixes for OS2.
mysys/my_copy.c:
  Fixes for OS2.
mysys/my_create.c:
  Fixes for OS2.
mysys/my_getwd.c:
  Fixes for OS2.
mysys/my_init.c:
  Fixes for OS2.
mysys/my_lib.c:
  Fixes for OS2.
mysys/my_lock.c:
  Fixes for OS2.
mysys/my_malloc.c:
  Portability fix
mysys/my_mkdir.c:
  Fixes for OS2.
mysys/my_open.c:
  Fixes for OS2.
mysys/my_pthread.c:
  Fixes for OS2.
mysys/my_realloc.c:
  Fixes for OS2.
mysys/my_redel.c:
  Fixes for OS2.
mysys/my_static.c:
  Fixes for OS2.
mysys/my_tempnam.c:
  Fixes for OS2.
mysys/my_thr_init.c:
  Fixes for OS2.
mysys/my_write.c:
  Fixes for OS2.
mysys/test_charset.c:
  Fixes for OS2.
mysys/thr_alarm.c:
  Fixes for OS2.
mysys/tree.c:
  Fixes for OS2.
sql/field.cc:
  Fixes for OS2.
sql/field.h:
  Fixes for OS2.
sql/gen_lex_hash.cc:
  Fixes for OS2.
sql/hostname.cc:
  Fixes for OS2.
sql/item_func.cc:
  Fixes for OS2.
sql/item_strfunc.cc:
  Fixes for OS2.
sql/log_event.cc:
  Fixes for OS2.
sql/md5.c:
  Fixes for OS2.
sql/mini_client.cc:
  Fixes for OS2.
sql/mysql_priv.h:
  Fixes for OS2.
sql/mysqld.cc:
  Fixes for OS2.
sql/net_serv.cc:
  Fixes for OS2.
sql/slave.cc:
  Fixes for OS2.
sql/sql_base.cc:
  Fixes for OS2.
sql/sql_db.cc:
  Portability fix
sql/sql_insert.cc:
  Fixes for OS2.
sql/sql_load.cc:
  Fixes for OS2.
sql/sql_parse.cc:
  Fixes for OS2.
sql/sql_table.cc:
  Fixes for OS2.
sql/sql_udf.cc:
  Fixes for OS2.
sql/violite.c:
  Fixes for OS2.
strings/ctype-big5.c:
  Fixes for OS2.
strings/ctype-gbk.c:
  Fixes for OS2.
strings/ctype-sjis.c:
  Fixes for OS2.
strings/ctype-tis620.c:
  Fixes for OS2.
strings/ctype.c:
  Fixes for OS2.
strings/strnlen.c:
  Fixes for OS2.
---
 Docs/manual.texi             |    6 +
 client/mysql.cc              |   38 +-
 client/mysqladmin.c          |   12 +-
 client/mysqldump.c           |   84 +-
 client/mysqlimport.c         |   13 +-
 client/mysqltest.c           |   36 +-
 dbug/dbug.c                  |  179 +-
 dbug/factorial.c             |    4 +-
 include/config-os2.h         |  822 +++++++++
 include/errmsg.h             |    1 +
 include/global.h             |   34 +-
 include/my_pthread.h         |   50 +-
 include/my_sys.h             |    1 +
 include/mysql_com.h          |    6 -
 include/thr_alarm.h          |    2 +-
 isam/isamchk.c               |  103 +-
 isam/isamlog.c               |  208 +--
 isam/test1.c                 |    8 +-
 isam/test2.c                 |   59 +-
 isam/test_all.res            |  207 +--
 libmysql/get_password.c      |    7 +-
 libmysql/libmysql.c          |    7 +-
 libmysql/net.c               |   23 +-
 libmysql/violite.c           |   39 +-
 merge/_locking.c             |    4 +-
 merge/close.c                |    3 +-
 merge/create.c               |    3 +-
 merge/extra.c                |    6 +-
 merge/open.c                 |    8 +-
 merge/panic.c                |    4 +-
 merge/rsame.c                |    8 +-
 merge/update.c               |    6 +-
 myisam/ft_eval.c             |    4 +-
 myisam/ft_search.c           |    2 +-
 myisam/ft_test1.c            |    4 +-
 myisam/ftdefs.h              |    2 +-
 myisam/mi_check.c            |    4 +-
 myisam/mi_test1.c            |    3 +-
 myisam/mi_test2.c            |   46 +-
 myisam/mi_test_all.sh        |    7 +-
 myisam/myisamlog.c           |   10 +-
 myisam/myisampack.c          |   68 +-
 myisam/sort.c                |   13 +-
 myisammrg/myrg_delete.c      |    6 +-
 myisammrg/myrg_locking.c     |    6 +-
 myisammrg/myrg_open.c        |    8 +-
 myisammrg/myrg_panic.c       |    3 +-
 mysql-test/t/backup.test     |    2 +-
 mysql-test/t/show_check.test |    2 +-
 mysys/charset.c              |   16 +-
 mysys/default.c              |    4 +-
 mysys/getopt.c               |    4 +-
 mysys/getopt1.c              |    2 +-
 mysys/list.c                 |    8 +-
 mysys/mf_dirname.c           |    2 +-
 mysys/mf_format.c            |    2 +-
 mysys/mf_path.c              |    2 +-
 mysys/mf_qsort.c             |    4 +-
 mysys/mf_tempfile.c          |   17 +-
 mysys/my_clock.c             |    4 +-
 mysys/my_copy.c              |    2 +-
 mysys/my_create.c            |    4 +-
 mysys/my_getwd.c             |   14 +-
 mysys/my_init.c              |    2 +-
 mysys/my_lib.c               |   15 +-
 mysys/my_lock.c              |   58 +-
 mysys/my_malloc.c            |    2 +-
 mysys/my_mkdir.c             |    4 +-
 mysys/my_open.c              |    4 +-
 mysys/my_os2cond.c           |  188 +++
 mysys/my_os2dirsrch.c        |  182 ++
 mysys/my_os2dirsrch.h        |   77 +
 mysys/my_os2dlfcn.c          |   74 +
 mysys/my_os2dlfcn.h0         |   39 +
 mysys/my_os2file64.c         |  341 ++++
 mysys/my_os2mutex.c          |   98 ++
 mysys/my_os2thread.c         |  126 ++
 mysys/my_os2tls.c            |  144 ++
 mysys/my_pthread.c           |    2 +-
 mysys/my_realloc.c           |    2 +-
 mysys/my_redel.c             |    2 +-
 mysys/my_static.c            |    2 +-
 mysys/my_tempnam.c           |   17 +-
 mysys/my_thr_init.c          |    6 +-
 mysys/my_write.c             |   40 +
 mysys/test_charset.c         |    2 +-
 mysys/thr_alarm.c            |   14 +-
 mysys/tree.c                 |    2 +-
 os2/ChangeLog.os2            |   23 +
 os2/MySQL-All.icc            |   13 +
 os2/MySQL-Client.icc         |   87 +
 os2/MySQL-Client.irs         | 2335 ++++++++++++++++++++++++++
 os2/MySQL-Lib.icc            |   72 +
 os2/MySQL-Opt.icc            |   53 +
 os2/MySQL-ReadLine.icc       |   27 +
 os2/MySQL-Source.icc         |  298 ++++
 os2/MySQL-Sql.icc            |  117 ++
 os2/MySQL-Util.icc           |  134 ++
 os2/MySQL-Util.irs           | 3067 ++++++++++++++++++++++++++++++++++
 os2/MySQL-binlog.icc         |   68 +
 os2/MySQL-binlog.irs         |    7 +
 os2/MySQL-sql.irs            |   13 +
 os2/build-all.cmd            |   11 +
 os2/build-all.log            |   39 +
 os2/mysql.base               |  127 ++
 os2/mysql.ih                 |    7 +
 os2/readme.os2               |  190 +++
 os2/rint.cmd                 |    4 +
 os2/rint.obj                 |  Bin 0 -> 334 bytes
 os2/rint.s                   |   32 +
 sql/field.cc                 |    2 +-
 sql/field.h                  |    4 +-
 sql/gen_lex_hash.cc          |    2 +-
 sql/hostname.cc              |    2 +-
 sql/item_func.cc             |    6 +
 sql/item_strfunc.cc          |    6 +-
 sql/log_event.cc             |    2 +-
 sql/md5.c                    |   36 +-
 sql/mini_client.cc           |   42 +-
 sql/mysql_priv.h             |    4 +-
 sql/mysqld.cc                |  108 +-
 sql/net_serv.cc              |   22 +-
 sql/slave.cc                 |    2 +-
 sql/sql_base.cc              |    4 +-
 sql/sql_db.cc                |    4 +-
 sql/sql_insert.cc            |    4 +-
 sql/sql_load.cc              |    2 +-
 sql/sql_parse.cc             |   16 +-
 sql/sql_table.cc             |   20 +-
 sql/sql_udf.cc               |    2 +-
 sql/violite.c                |   32 +-
 strings/ctype-big5.c         |    4 +-
 strings/ctype-gbk.c          |    4 +-
 strings/ctype-sjis.c         |    6 +-
 strings/ctype-tis620.c       |    4 +-
 strings/ctype.c              |    4 +-
 strings/strnlen.c            |    2 +-
 137 files changed, 9927 insertions(+), 852 deletions(-)
 create mode 100644 include/config-os2.h
 create mode 100644 mysys/my_os2cond.c
 create mode 100644 mysys/my_os2dirsrch.c
 create mode 100644 mysys/my_os2dirsrch.h
 create mode 100644 mysys/my_os2dlfcn.c
 create mode 100644 mysys/my_os2dlfcn.h0
 create mode 100644 mysys/my_os2file64.c
 create mode 100644 mysys/my_os2mutex.c
 create mode 100644 mysys/my_os2thread.c
 create mode 100644 mysys/my_os2tls.c
 create mode 100644 os2/ChangeLog.os2
 create mode 100644 os2/MySQL-All.icc
 create mode 100644 os2/MySQL-Client.icc
 create mode 100644 os2/MySQL-Client.irs
 create mode 100644 os2/MySQL-Lib.icc
 create mode 100644 os2/MySQL-Opt.icc
 create mode 100644 os2/MySQL-ReadLine.icc
 create mode 100644 os2/MySQL-Source.icc
 create mode 100644 os2/MySQL-Sql.icc
 create mode 100644 os2/MySQL-Util.icc
 create mode 100644 os2/MySQL-Util.irs
 create mode 100644 os2/MySQL-binlog.icc
 create mode 100644 os2/MySQL-binlog.irs
 create mode 100644 os2/MySQL-sql.irs
 create mode 100644 os2/build-all.cmd
 create mode 100644 os2/build-all.log
 create mode 100644 os2/mysql.base
 create mode 100644 os2/mysql.ih
 create mode 100644 os2/readme.os2
 create mode 100644 os2/rint.cmd
 create mode 100644 os2/rint.obj
 create mode 100644 os2/rint.s

diff --git a/Docs/manual.texi b/Docs/manual.texi
index a1ddd969b91..6b042d899c0 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46155,6 +46155,8 @@ incredible help we got in managing the MySQL mailing lists.
 @item Igor Romanenko @email{igor@@frog.kiev.ua}
 @code{mysqldump} (previously @code{msqldump}, but ported and enhanced by
 Monty).
+@item Yuri Dario
+For keeping up and extending the MySQL OS/2 port.
 @item Tim Bunce, Alligator Descartes
 For the @code{DBD} (Perl) interface.
 @item Tim Bunce
@@ -46282,6 +46284,8 @@ MySQL server.
 @item Albert Chin-A-Young.
 Configure updates for Tru64, large file support and better TCP wrappers
 support.
+@item John Birrell
+Emulation of pthread_mutex() for OS/2.
 @end table
 
 Other contributors, bugfinders, and testers: James H. Thompson, Maurizio
@@ -46543,6 +46547,8 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Applied large patch for OS/2 from Yuri Dario.
+@item
 Fixed problem with InnoDB when one could get the error @code{Can't
 execute the given command...} even when one didn't have an active
 transaction.
diff --git a/client/mysql.cc b/client/mysql.cc
index 8d926a54840..e4db7e93256 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -77,7 +77,7 @@ extern "C" {
 
 #undef bcmp				// Fix problem with new readline
 #undef bzero
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
 #include <conio.h>
 #else
 #include <readline/readline.h>
@@ -569,7 +569,7 @@ static int get_options(int argc, char **argv)
 
   set_all_changeable_vars(changeable_vars);
   while ((c=getopt_long(argc,argv,
-			"?ABCD:LfgGHinNoqrstTU::vVw::WEe:h:O:P:S:u:#::p::",
+			(char*) "?ABCD:LfgGHinNoqrstTU::vVw::WEe:h:O:P:S:u:#::p::",
 			long_options, &option_index)) != EOF)
   {
     switch(c) {
@@ -767,10 +767,20 @@ static int get_options(int argc, char **argv)
   return(0);
 }
 
+#if  defined(OS2)
+static char* readline( char* prompt)
+{
+#if defined(OS2)
+   static char linebuffer[254];
+#endif
+   puts( prompt);
+   return gets( linebuffer);
+}
+#endif
 
 static int read_lines(bool execute_commands)
 {
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   char linebuffer[254];
 #endif
   char	*line;
@@ -790,7 +800,7 @@ static int read_lines(bool execute_commands)
     }
     else
     {
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
       if (opt_outfile && glob_buffer.is_empty())
 	fflush(OUTFILE);
       tee_fputs(glob_buffer.is_empty() ? "mysql> " :
@@ -1483,7 +1493,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
 
 static void init_pager()
 {
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined( OS2)
   if (!opt_nopager)
   {
     if (!(PAGER= popen(pager, "w")))
@@ -1499,7 +1509,7 @@ static void init_pager()
 
 static void end_pager()
 {
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined( OS2)
   if (!opt_nopager)
     pclose(PAGER);
 #endif
@@ -2337,6 +2347,9 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
 
   va_start(args, fmt);
   (void) vfprintf(file, fmt, args);
+#ifdef OS2
+  fflush( file);
+#endif
   if (opt_outfile)
     (void) vfprintf(OUTFILE, fmt, args);
   va_end(args);
@@ -2346,6 +2359,9 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
 void tee_fputs(const char *s, FILE *file)
 {
   fputs(s, file);
+#ifdef OS2
+  fflush( file);
+#endif
   if (opt_outfile)
     fputs(s, OUTFILE);
 }
@@ -2355,6 +2371,9 @@ void tee_puts(const char *s, FILE *file)
 {
   fputs(s, file);
   fputs("\n", file);
+#ifdef OS2
+  fflush( file);
+#endif
   if (opt_outfile)
   {
     fputs(s, OUTFILE);
@@ -2365,11 +2384,14 @@ void tee_puts(const char *s, FILE *file)
 void tee_putc(int c, FILE *file)
 {
   putc(c, file);
+#ifdef OS2
+  fflush( file);
+#endif
   if (opt_outfile)
     putc(c, OUTFILE);
 }
 
-#ifdef __WIN__
+#if defined( __WIN__) || defined( OS2)
 #include <time.h>
 #else
 #include <sys/times.h>
@@ -2379,7 +2401,7 @@ void tee_putc(int c, FILE *file)
 
 static ulong start_timer(void)
 {
-#ifdef __WIN__
+#if defined( __WIN__) || defined( OS2)
  return clock();
 #else
   struct tms tms_tmp;
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 3570cefc4ae..e95d6492949 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -132,7 +132,7 @@ static struct option long_options[] = {
   {0, 0, 0, 0}
 };
 
-CHANGEABLE_VAR changeable_vars[] = {
+static CHANGEABLE_VAR changeable_vars[] = {
   { "connect_timeout", (long*) &opt_connect_timeout, 0, 0, 3600*12, 0, 1},
   { "shutdown_timeout", (long*) &opt_shutdown_timeout, SHUTDOWN_DEF_TIMEOUT, 0,
     3600*12, 0, 1},
@@ -152,7 +152,8 @@ int main(int argc,char *argv[])
   load_defaults("my",load_default_groups,&argc,&argv);
   set_all_changeable_vars( changeable_vars );
 
-  while ((c=getopt_long(argc,argv,"h:i:p::u:#::P:sS:Ct:fq?vVw::WrEO:",
+  while ((c=getopt_long(argc,argv,
+			(char*) "h:i:p::u:#::P:sS:Ct:fq?vVw::WrEO:",
 			long_options, &option_index)) != EOF)
   {
     switch(c) {
@@ -1121,14 +1122,15 @@ static void wait_pidfile(char *pidfile)
   uint count=0;
 
   system_filename(buff,pidfile);
-  while ((fd = open(buff, O_RDONLY)) >= 0 && count++ < opt_shutdown_timeout)
+  while ((fd = my_open(buff, O_RDONLY, MYF(0))) >= 0 &&
+	 count++ < opt_shutdown_timeout)
   {
-    close(fd);
+    my_close(fd,MYF(0));
     sleep(1);
   }
   if (fd >= 0)
   {
-    close(fd);
+    my_close(fd,MYF(0));
     fprintf(stderr,
 	    "Warning;  Aborted waiting on pid file: '%s' after %d seconds\n",
 	    buff, count-1);
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 4893c13a0a0..29629940fb5 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -85,11 +85,11 @@ static int   first_error=0;
 extern ulong net_buffer_length;
 static DYNAMIC_STRING extended_row;
 #include "sslopt-vars.h"
-FILE  *result_file;
+FILE  *md_result_file;
 
-enum options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_KEYWORDS,
-	      OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED, OPT_TABLES,
-              OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
+enum md_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+		 OPT_KEYWORDS, OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED,
+		 OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET};
 
 static struct option long_options[] =
 {
@@ -98,12 +98,12 @@ static struct option long_options[] =
   {"add-drop-table",	no_argument,    0, 	OPT_DROP},
   {"add-locks",    	no_argument,    0,	OPT_LOCKS},
   {"allow-keywords",	no_argument,    0, 	OPT_KEYWORDS},
-  {"character-sets-dir",required_argument,0,    OPT_CHARSETS_DIR},
+  {"character-sets-dir",required_argument,0,    MD_OPT_CHARSETS_DIR},
   {"complete-insert",	no_argument,    0, 	'c'},
   {"compress",          no_argument,    0, 	'C'},
   {"databases",         no_argument,    0,      'B'},
   {"debug",		optional_argument, 	0, '#'},
-  {"default-character-set", required_argument,  0, OPT_DEFAULT_CHARSET},
+  {"default-character-set", required_argument,  0, MD_OPT_DEFAULT_CHARSET},
   {"delayed-insert",	no_argument,    0, 	OPT_DELAYED},
   {"extended-insert",   no_argument,    0, 	'e'},
   {"fields-terminated-by", required_argument,   0, (int) OPT_FTB},
@@ -145,7 +145,7 @@ static struct option long_options[] =
 
 static const char *load_default_groups[]= { "mysqldump","client",0 };
 
-CHANGEABLE_VAR changeable_vars[] = {
+CHANGEABLE_VAR md_changeable_vars[] = {
   { "max_allowed_packet", (long*) &max_allowed_packet,24*1024*1024,4096,
     24*1024L*1024L,MALLOC_OVERHEAD,1024},
   { "net_buffer_length", (long*) &net_buffer_length,1024*1024L-1025,4096,
@@ -265,10 +265,10 @@ puts("\
   print_defaults("my",load_default_groups);
 
   printf("\nPossible variables for option --set-variable (-O) are:\n");
-  for (i=0 ; changeable_vars[i].name ; i++)
+  for (i=0 ; md_changeable_vars[i].name ; i++)
     printf("%-20s  current value: %lu\n",
-     changeable_vars[i].name,
-     (ulong) *changeable_vars[i].varptr);
+     md_changeable_vars[i].name,
+     (ulong) *md_changeable_vars[i].varptr);
 } /* usage */
 
 
@@ -290,9 +290,9 @@ static int get_options(int *argc,char ***argv)
   int c,option_index;
   my_bool tty_password=0;
 
-  result_file=stdout;
+  md_result_file=stdout;
   load_defaults("my",load_default_groups,argc,argv);
-  set_all_changeable_vars(changeable_vars);
+  set_all_changeable_vars(md_changeable_vars);
   while ((c=getopt_long(*argc,*argv,
 			"#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?Ix",
 			long_options, &option_index)) != EOF)
@@ -307,10 +307,10 @@ static int get_options(int *argc,char ***argv)
     case 'A':
       opt_alldbs=1;
       break;
-    case OPT_DEFAULT_CHARSET:
+    case MD_OPT_DEFAULT_CHARSET:
       default_charset= optarg;
       break;
-    case OPT_CHARSETS_DIR:
+    case MD_OPT_CHARSETS_DIR:
       charsets_dir= optarg;
       break;
     case 'f':
@@ -332,7 +332,7 @@ static int get_options(int *argc,char ***argv)
       break;
 #endif
     case 'O':
-      if (set_changeable_var(optarg, changeable_vars))
+      if (set_changeable_var(optarg, md_changeable_vars))
       {
 	usage();
 	return(1);
@@ -355,7 +355,7 @@ static int get_options(int *argc,char ***argv)
       opt_mysql_port= (unsigned int) atoi(optarg);
       break;
     case 'r':
-      if (!(result_file = my_fopen(optarg, O_WRONLY | O_BINARY,
+      if (!(md_result_file = my_fopen(optarg, O_WRONLY | O_BINARY,
 				   MYF(MY_WME))))
 	exit(1);
       break;
@@ -602,7 +602,7 @@ static uint getTableStructure(char *table, char* db)
   char 	     *strpos, *table_name;
   const char *delayed;
   char 	     name_buff[NAME_LEN+3],table_buff[NAME_LEN+3];
-  FILE       *sql_file = result_file;
+  FILE       *sql_file = md_result_file;
   DBUG_ENTER("getTableStructure");
 
   delayed= opt_delayed ? " DELAYED " : "";
@@ -973,14 +973,14 @@ static void dumpTable(uint numFields, char *table)
   }
   else
   {
-    fprintf(result_file,"\n#\n# Dumping data for table '%s'\n", table);
+    fprintf(md_result_file,"\n#\n# Dumping data for table '%s'\n", table);
     sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff));
     if (where)
     {
-      fprintf(result_file,"# WHERE:  %s\n",where);
+      fprintf(md_result_file,"# WHERE:  %s\n",where);
       strxmov(strend(query), " WHERE ",where,NullS);
     }
-    fputs("#\n\n", result_file);
+    fputs("#\n\n", md_result_file);
 
     if (mysql_query(sock, query))
     {
@@ -1007,7 +1007,7 @@ static void dumpTable(uint numFields, char *table)
     }
 
     if (opt_lock)
-      fprintf(result_file,"LOCK TABLES %s WRITE;\n",
+      fprintf(md_result_file,"LOCK TABLES %s WRITE;\n",
 	      quote_name(table,table_buff));
 
     total_length=net_buffer_length;		/* Force row break */
@@ -1021,7 +1021,7 @@ static void dumpTable(uint numFields, char *table)
       ulong *lengths=mysql_fetch_lengths(res);
       rownr++;
       if (!extended_insert)
-	fputs(insert_pat,result_file);
+	fputs(insert_pat,md_result_file);
       mysql_field_seek(res,0);
 
       for (i = 0; i < mysql_num_fields(res); i++)
@@ -1075,17 +1075,17 @@ static void dumpTable(uint numFields, char *table)
 	else
 	{
 	  if (i)
-	    fputc(',',result_file);
+	    fputc(',',md_result_file);
 	  if (row[i])
 	  {
 	    if (!IS_NUM_FIELD(field))
-	      unescape(result_file, row[i], lengths[i]);
+	      unescape(md_result_file, row[i], lengths[i]);
 	    else
-	      fputs(row[i],result_file);
+	      fputs(row[i],md_result_file);
 	  }
 	  else
 	  {
-	    fputs("NULL",result_file);
+	    fputs("NULL",md_result_file);
 	  }
 	}
       }
@@ -1098,25 +1098,25 @@ static void dumpTable(uint numFields, char *table)
         if (total_length + row_length < net_buffer_length)
         {
 	  total_length += row_length;
-	  fputc(',',result_file);		/* Always row break */
-	  fputs(extended_row.str,result_file);
+	  fputc(',',md_result_file);		/* Always row break */
+	  fputs(extended_row.str,md_result_file);
 	}
         else
         {
 	  if (row_break)
-	    fputs(";\n", result_file);
+	    fputs(";\n", md_result_file);
 	  row_break=1;				/* This is first row */
-	  fputs(insert_pat,result_file);
-	  fputs(extended_row.str,result_file);
+	  fputs(insert_pat,md_result_file);
+	  fputs(extended_row.str,md_result_file);
 	  total_length = row_length+init_length;
         }
       }
       else
-	fputs(");\n", result_file);
+	fputs(");\n", md_result_file);
     }
     if (extended_insert && row_break)
-      fputs(";\n", result_file);		/* If not empty table */
-    fflush(result_file);
+      fputs(";\n", md_result_file);		/* If not empty table */
+    fflush(md_result_file);
     if (mysql_errno(sock))
     {
       sprintf(query,"%s: Error %d: %s when dumping table '%s' at row: %ld\n",
@@ -1130,7 +1130,7 @@ static void dumpTable(uint numFields, char *table)
       return;
     }
     if (opt_lock)
-      fputs("UNLOCK TABLES;\n", result_file);
+      fputs("UNLOCK TABLES;\n", md_result_file);
     mysql_free_result(res);
   }
 } /* dumpTable */
@@ -1206,11 +1206,11 @@ static int init_dumping(char *database)
   {
     if (opt_databases || opt_alldbs)
     {
-      fprintf(result_file,"\n#\n# Current Database: %s\n#\n", database);
+      fprintf(md_result_file,"\n#\n# Current Database: %s\n#\n", database);
       if (!opt_create_db)
-	fprintf(result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
+	fprintf(md_result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
 		database);
-      fprintf(result_file,"\nUSE %s;\n", database);
+      fprintf(md_result_file,"\nUSE %s;\n", database);
     }
   }
   if (extended_insert)
@@ -1342,7 +1342,7 @@ int main(int argc, char **argv)
   if (dbConnect(current_host, current_user, opt_password))
     exit(EX_MYSQLERR);
   if (!path)
-    write_heder(result_file, *argv);
+    write_heder(md_result_file, *argv);
 
    if (opt_first_slave)
    {
@@ -1378,9 +1378,9 @@ int main(int argc, char **argv)
    }
   }
   dbDisconnect(current_host);
-  fputs("\n", result_file);
-  if (result_file != stdout)
-    my_fclose(result_file, MYF(0));
+  fputs("\n", md_result_file);
+  if (md_result_file != stdout)
+    my_fclose(md_result_file, MYF(0));
   my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
   if (extended_insert)
     dynstr_free(&extended_row);
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 79f0a8d584e..cbdedf56cbe 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -41,7 +41,7 @@ static char *field_escape(char *to,const char *from,uint length);
 static char *add_load_option(char *ptr,const char *object,
 			     const char *statement);
 
-static my_bool	verbose=0,lock_tables=0,ignore_errors=0,delete=0,
+static my_bool	verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
 		replace=0,silent=0,ignore=0,opt_compress=0,opt_local_file=0;
 
 static MYSQL	mysql_connection;
@@ -54,8 +54,8 @@ static uint     opt_mysql_port=0;
 static my_string opt_mysql_unix_port=0;
 #include "sslopt-vars.h"
 
-enum options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
- 	      OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
+enum mi_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+		 OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
 
 static struct option long_options[] =
 {
@@ -173,7 +173,8 @@ static int get_options(int *argc, char ***argv)
   int c, option_index;
   my_bool tty_password=0;
 
-  while ((c=getopt_long(*argc,*argv,"#::p::c:h:u:P:S:CdfilLrsvV?IW",
+  while ((c=getopt_long(*argc,*argv,
+			(char*) "#::p::c:h:u:P:S:CdfilLrsvV?IW",
 			long_options, &option_index)) != EOF)
   {
     switch(c) {
@@ -190,7 +191,7 @@ static int get_options(int *argc, char ***argv)
       charsets_dir= optarg;
       break;
     case 'd':
-      delete= 1;
+      opt_delete= 1;
       break;
     case 'f':
       ignore_errors= 1;
@@ -313,7 +314,7 @@ static int write_to_table(char *filename, MYSQL *sock)
   else
     my_load_path(hard_path, filename, NULL); /* filename includes the path */
 
-  if (delete)
+  if (opt_delete)
   {
     if (verbose)
       fprintf(stdout, "Deleting the old data from table %s\n", tablename);
diff --git a/client/mysqltest.c b/client/mysqltest.c
index f6d87352a6c..2d8c4e00416 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -51,7 +51,11 @@
 #include <mysql.h>
 #include <mysql_version.h>
 #include <m_ctype.h>
-#include <my_config.h>
+#ifdef OS2
+#include <config-os2.h>
+#else
+ #include <my_config.h>
+#endif
 #include <my_dir.h>
 #include <hash.h>
 #include <mysqld_error.h>
@@ -829,6 +833,17 @@ int do_sleep(struct st_query* q)
   if (!*p)
     die("Missing argument in sleep\n");
   t.tv_usec = 0;
+
+#ifdef OS2
+
+  if (opt_sleep)
+    DosSleep( opt_sleep * 1000);
+  else
+    DosSleep( atof( p) * 1000);
+
+  return 0;
+
+#else
   if (opt_sleep)
     t.tv_sec = opt_sleep;
   else
@@ -858,6 +873,7 @@ int do_sleep(struct st_query* q)
   }
   t.tv_usec *= dec_mul;
   return select(0,0,0,0, &t);
+#endif
 }
 
 static void get_file_name(char *filename, struct st_query* q)
@@ -1881,8 +1897,8 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
 
 static void var_free(void* v)
 {
-  my_free(((VAR*)v)->str_val, MYF(MY_WME));
-  my_free(v, MYF(MY_WME));
+  my_free(((VAR*) v)->str_val, MYF(MY_WME));
+  my_free((char*) v, MYF(MY_WME));
 }
 
 
@@ -2744,7 +2760,7 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
 {
   reg1 REPLACE *rep_pos;
   reg2 REPLACE_STRING *rep_str;
-  my_string to,end,pos,new;
+  my_string to,end,pos,new_str;
 
   end=(to= *start) + *max_length-1;
   rep_pos=rep+1;
@@ -2756,10 +2772,10 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
       if (to == end)
       {
 	(*max_length)+=8192;
-	if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+	if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
 	  return (uint) -1;
-	to=new+(to - *start);
-	end=(*start=new)+ *max_length-1;
+	to=new_str+(to - *start);
+	end=(*start=new_str)+ *max_length-1;
       }
       *to++= *from++;
     }
@@ -2771,10 +2787,10 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
       if (to == end)
       {
 	(*max_length)*=2;
-	if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+	if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
 	  return (uint) -1;
-	to=new+(to - *start);
-	end=(*start=new)+ *max_length-1;
+	to=new_str+(to - *start);
+	end=(*start=new_str)+ *max_length-1;
       }
       *to++= *pos;
     }
diff --git a/dbug/dbug.c b/dbug/dbug.c
index f600b281007..1fb8755d605 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -307,6 +307,7 @@ static char *static_strtok(char *s1,pchar chr);
  *	Macros and defines for testing file accessibility under UNIX and MSDOS.
  */
 
+#undef EXISTS
 #if !defined(HAVE_ACCESS) || defined(MSDOS)
 #define EXISTS(pathname) (FALSE)	/* Assume no existance */
 #define Writable(name) (TRUE)
@@ -489,8 +490,7 @@ static CODE_STATE  static_code_state = { 0,0,"?func","?file",NULL,0,NULL,
  *
  */
 
-void _db_push_ (control)
-const char *control;
+void _db_push_ (const char *control)
 {
   reg1 char *scan;
   reg2 struct link *temp;
@@ -691,15 +691,14 @@ void _db_pop_ ()
  *
  */
 
-void _db_enter_ (_func_, _file_, _line_, _sfunc_, _sfile_, _slevel_,
-		 _sframep_)
-const char *_func_;
-const char *_file_;
-uint _line_;
-const char **_sfunc_;
-const char **_sfile_;
-uint *_slevel_;
-char ***_sframep_ __attribute__((unused));
+void _db_enter_ (
+const char *_func_,
+const char *_file_,
+uint _line_,
+const char **_sfunc_,
+const char **_sfile_,
+uint *_slevel_,
+char ***_sframep_ __attribute__((unused)))
 {
   reg1 CODE_STATE *state;
 
@@ -777,11 +776,11 @@ char ***_sframep_ __attribute__((unused));
  *
  */
 
-void _db_return_ (_line_, _sfunc_, _sfile_, _slevel_)
-uint _line_;
-const char **_sfunc_;
-const char **_sfile_;
-uint *_slevel_;
+void _db_return_ (
+uint _line_,
+const char **_sfunc_,
+const char **_sfile_,
+uint *_slevel_)
 {
   CODE_STATE *state;
 
@@ -851,9 +850,9 @@ uint *_slevel_;
  *
  */
 
-void _db_pargs_ (_line_, keyword)
-uint _line_;
-const char *keyword;
+void _db_pargs_ (
+uint _line_,
+const char *keyword)
 {
   CODE_STATE *state=code_state();
   state->u_line = _line_;
@@ -934,10 +933,11 @@ void _db_doprnt_ (const char *format,...)
  *  Is used to examine corrputed memory or arrays.
  */
 
-void _db_dump_(_line_,keyword,memory,length)
-uint _line_,length;
-const char *keyword;
-const char *memory;
+void _db_dump_(
+uint _line_,
+const char *keyword,
+const char *memory,
+uint length)
 {
   int pos;
   char dbuff[90];
@@ -1004,11 +1004,11 @@ const char *memory;
  *
  */
 
-static struct link *ListParse (ctlp)
-char *ctlp;
+static struct link *ListParse (
+char *ctlp)
 {
   REGISTER char *start;
-  REGISTER struct link *new;
+  REGISTER struct link *new_malloc;
   REGISTER struct link *head;
 
   head = NULL;
@@ -1020,10 +1020,10 @@ char *ctlp;
     if (*ctlp == ',') {
       *ctlp++ = EOS;
     }
-    new = (struct link *) DbugMalloc (sizeof (struct link));
-    new -> str = StrDup (start);
-    new -> next_link = head;
-    head = new;
+    new_malloc = (struct link *) DbugMalloc (sizeof (struct link));
+    new_malloc -> str = StrDup (start);
+    new_malloc -> next_link = head;
+    head = new_malloc;
   }
   return (head);
 }
@@ -1052,9 +1052,9 @@ char *ctlp;
  *
  */
 
-static BOOLEAN InList (linkp, cp)
-struct link *linkp;
-const char *cp;
+static BOOLEAN InList (
+struct link *linkp,
+const char *cp)
 {
   REGISTER struct link *scan;
   REGISTER BOOLEAN result;
@@ -1098,7 +1098,7 @@ const char *cp;
 
 static void PushState ()
 {
-  REGISTER struct state *new;
+  REGISTER struct state *new_malloc;
 
   if (!init_done)
   {
@@ -1106,19 +1106,19 @@ static void PushState ()
     init_done=TRUE;
   }
   (void) code_state();				/* Alloc memory */
-  new = (struct state *) DbugMalloc (sizeof (struct state));
-  new -> flags = 0;
-  new -> delay = 0;
-  new -> maxdepth = MAXDEPTH;
-  new -> sub_level=0;
-  new -> out_file = stderr;
-  new -> prof_file = (FILE*) 0;
-  new -> functions = NULL;
-  new -> p_functions = NULL;
-  new -> keywords = NULL;
-  new -> processes = NULL;
-  new -> next_state = stack;
-  stack=new;
+  new_malloc = (struct state *) DbugMalloc (sizeof (struct state));
+  new_malloc -> flags = 0;
+  new_malloc -> delay = 0;
+  new_malloc -> maxdepth = MAXDEPTH;
+  new_malloc -> sub_level=0;
+  new_malloc -> out_file = stderr;
+  new_malloc -> prof_file = (FILE*) 0;
+  new_malloc -> functions = NULL;
+  new_malloc -> p_functions = NULL;
+  new_malloc -> keywords = NULL;
+  new_malloc -> processes = NULL;
+  new_malloc -> next_state = stack;
+  stack=new_malloc;
 }
 
 
@@ -1216,8 +1216,8 @@ static BOOLEAN DoProfile ()
  *
  */
 
-BOOLEAN _db_keyword_ (keyword)
-const char *keyword;
+BOOLEAN _db_keyword_ (
+const char *keyword)
 {
   REGISTER BOOLEAN result;
   CODE_STATE *state;
@@ -1256,8 +1256,8 @@ const char *keyword;
  *
  */
 
-static void Indent (indent)
-int indent;
+static void Indent (
+int indent)
 {
   REGISTER int count;
 
@@ -1289,8 +1289,8 @@ int indent;
  *
  */
 
-static void FreeList (linkp)
-struct link *linkp;
+static void FreeList (
+struct link *linkp)
 {
   REGISTER struct link *old;
 
@@ -1325,13 +1325,13 @@ struct link *linkp;
  */
 
 
-static char *StrDup (str)
-const char *str;
+static char *StrDup (
+const char *str)
 {
-    reg1 char *new;
-    new = DbugMalloc ((int) strlen (str) + 1);
-    (void) strcpy (new, str);
-    return (new);
+    reg1 char *new_malloc;
+    new_malloc = DbugMalloc ((int) strlen (str) + 1);
+    (void) strcpy (new_malloc, str);
+    return (new_malloc);
 }
 
 
@@ -1354,8 +1354,8 @@ const char *str;
  *
  */
 
-static void DoPrefix (_line_)
-uint _line_;
+static void DoPrefix (
+uint _line_)
 {
   CODE_STATE *state;
   state=code_state();
@@ -1419,7 +1419,7 @@ static void DBUGOpenFile (const char *name,int append)
     }
     else
     {
-      if (!Writable(name))
+      if (!Writable((char*)name))
       {
 	(void) fprintf (stderr, ERR_OPEN, _db_process_, name);
 	perror ("");
@@ -1528,8 +1528,8 @@ static FILE *OpenProfile (const char *name)
  *
  */
 
-static void CloseFile (fp)
-FILE *fp;
+static void CloseFile (
+FILE *fp)
 {
   if (fp != stderr && fp != stdout) {
     if (fclose (fp) == EOF) {
@@ -1590,14 +1590,14 @@ static void DbugExit (const char *why)
  *
  */
 
-static char *DbugMalloc (size)
-int size;
+static char *DbugMalloc (
+int size)
 {
-    register char *new;
+    register char *new_malloc;
 
-    if (!(new = malloc ((unsigned int) size)))
+    if (!(new_malloc = (char*) malloc ((unsigned int) size)))
       DbugExit ("out of memory");
-    return (new);
+    return (new_malloc);
 }
 
 
@@ -1606,9 +1606,9 @@ int size;
  *		separator (to allow directory-paths in dos).
  */
 
-static char *static_strtok (s1, separator)
-char *s1;
-pchar separator;
+static char *static_strtok (
+char *s1,
+pchar separator)
 {
   static char *end = NULL;
   reg1 char *rtnval,*cpy;
@@ -1692,8 +1692,8 @@ static char *BaseName (const char *pathname)
 
 #ifndef Writable
 
-static BOOLEAN Writable (pathname)
-char *pathname;
+static BOOLEAN Writable (
+char *pathname)
 {
   REGISTER BOOLEAN granted;
   REGISTER char *lastslash;
@@ -1746,8 +1746,8 @@ char *pathname;
  */
 
 #ifndef ChangeOwner
-static void ChangeOwner (pathname)
-char *pathname;
+static void ChangeOwner (
+char *pathname)
 {
   if (chown (pathname, getuid (), getgid ()) == -1)
   {
@@ -1847,8 +1847,8 @@ EXPORT void _db_longjmp_ ()
 #define HZ (50)			      /* Probably in some header somewhere */
 #endif
 
-static int DelayArg (value)
-int value;
+static int DelayArg (
+int value)
 {
   uint delayarg = 0;
 
@@ -1868,8 +1868,8 @@ int value;
  */
 
 #if ! defined(Delay) && ! defined(AMIGA)
-static int Delay (ticks)
-int ticks;
+static int Delay (
+int ticks)
 {
   return ticks;
 }
@@ -1969,12 +1969,13 @@ void _db_unlock_file()
  * own for whatever system that you have.
  */
 
-#ifdef HAVE_GETRUSAGE
+#ifndef THREAD
+#if defined(HAVE_GETRUSAGE)
 
 #include <sys/param.h>
 #include <sys/resource.h>
 
-/* extern int     getrusage(int, struct rusage *); */
+/* extern int getrusage(int, struct rusage *); */
 
 /*
  * Returns the user time in milliseconds used by this process so
@@ -1989,15 +1990,13 @@ static unsigned long Clock ()
     return ((ru.ru_utime.tv_sec * 1000) + (ru.ru_utime.tv_usec / 1000));
 }
 
-#else
-#if defined(MSDOS) || defined(__WIN__)
+#elif defined(MSDOS) || defined(__WIN__) || defined(OS2)
 
 static ulong Clock()
 {
   return clock()*(1000/CLOCKS_PER_SEC);
 }
-#else
-#ifdef amiga
+#elif defined (amiga)
 
 struct DateStamp {		/* Yes, this is a hack, but doing it right */
 	long ds_Days;		/* is incredibly ugly without splitting this */
@@ -2030,19 +2029,13 @@ static unsigned long Clock ()
     }
     return (millisec);
 }
-
 #else
-
-#ifndef THREAD
 static unsigned long Clock ()
 {
     return (0);
 }
-#endif
-#endif /* amiga */
-#endif /* MSDOS || __WIN__ */
 #endif /* RUSAGE */
-
+#endif /* THREADS */
 
 #ifdef NO_VARARGS
 
diff --git a/dbug/factorial.c b/dbug/factorial.c
index 191c0468356..0dda5c7459e 100644
--- a/dbug/factorial.c
+++ b/dbug/factorial.c
@@ -4,8 +4,8 @@
 
 #include <global.h>
 
-int factorial (value)
-register int value;
+int factorial (
+register int value)
 {
     DBUG_ENTER ("factorial");
     DBUG_PRINT ("find", ("find %d factorial", value));
diff --git a/include/config-os2.h b/include/config-os2.h
new file mode 100644
index 00000000000..172a04a9f01
--- /dev/null
+++ b/include/config-os2.h
@@ -0,0 +1,822 @@
+/* Copyright (C) 2000 MySQL AB & Yuri Dario
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+/* Defines for OS2 to make it compatible for MySQL */
+
+#ifndef __CONFIG_OS2_H__
+#define __CONFIG_OS2_H__
+
+#include <os2.h>
+#include <math.h>
+#include <io.h>
+
+/* Define to name of system eg solaris*/
+#define SYSTEM_TYPE "IBM OS/2 Warp"
+/* Define to machine type name eg sun10 */
+#define MACHINE_TYPE "i686"
+/* Name of package */
+#define PACKAGE "mysql"
+/* Version number of package */
+#define VERSION MYSQL_SERVER_VERSION
+/* Default socket */
+#define MYSQL_UNIX_ADDR "\\socket\\MySQL"
+
+#define FN_LIBCHAR		 '\\'
+#define FN_ROOTDIR		 "\\"
+#define MY_NFILE		1024  /* This is only used to save filenames */
+
+#define HAVE_ACCESS
+
+#define DEFAULT_MYSQL_HOME	"c:\\mysql"
+#define DEFAULT_BASEDIR		"C:\\"
+#define SHAREDIR		"share"
+#define DEFAULT_CHARSET_HOME	"C:/mysql/"
+#define _POSIX_PATH_MAX		255
+#define DWORD			ULONG
+
+#define O_SHARE		0x1000		/* Open file in sharing mode */
+#define FILE_BINARY	O_BINARY	/* my_fopen in binary mode */
+#define S_IROTH		S_IREAD		/* for my_lib */
+
+#define O_NONBLOCK	0x10
+
+#define NO_OPEN_3			/* For my_create() */
+#define SIGQUIT		SIGTERM		/* No SIGQUIT */
+#define SIGALRM		14		/* Alarm */
+
+#define NO_FCNTL_NONBLOCK
+
+#define EFBIG			   E2BIG
+//#define ENFILE		  EMFILE
+//#define ENAMETOOLONG		(EOS2ERR+2)
+//#define ETIMEDOUT		  145
+//#define EPIPE			  146
+#define EROFS			147
+
+#define sleep(A)	DosSleep((A)*1000)
+#define closesocket(A)	soclose(A)
+
+#define F_OK		0
+#define W_OK		2
+
+#define bzero(x,y)	memset((x),'\0',(y))
+#define bcopy(x,y,z)	memcpy((y),(x),(z))
+#define bcmp(x,y,z)	memcmp((y),(x),(z))
+
+#define F_RDLCK		4	    /* Read lock.  */
+#define F_WRLCK		2	    /* Write lock.  */
+#define F_UNLCK		0	    /* Remove lock.  */
+
+#define S_IFMT		0xF000	    /* Mask for file type */
+#define F_TO_EOF	0L	    /* Param to lockf() to lock rest of file */
+
+#ifdef __cplusplus
+extern "C"
+#endif
+double _cdecl rint( double nr);
+
+DWORD	 TlsAlloc( void);
+BOOL	 TlsFree( DWORD);
+PVOID	 TlsGetValue( DWORD);
+BOOL	 TlsSetValue( DWORD, PVOID);
+
+/* support for > 2GB file size */
+#define SIZEOF_OFF_T	8
+#define lseek(A,B,C)	_lseek64( A, B, C)
+#define tell(A)		_lseek64( A, 0, SEEK_CUR)
+
+/* Some typedefs */
+typedef ulonglong os_off_t;
+
+/* config.h.  Generated automatically by configure.  */
+/* config.h.in.  Generated automatically from configure.in by autoheader.  */
+
+/* Define if using alloca.c.  */
+/* #undef C_ALLOCA */
+
+/* Define to empty if the keyword does not work.  */
+/* #undef const */
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+   This function is required for alloca.c support on those systems.  */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define if you have alloca, as a function or macro.  */
+#define HAVE_ALLOCA 1
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
+//#define HAVE_ALLOCA_H 1
+
+/* Define if you don't have vprintf but do have _doprnt.  */
+/* #undef HAVE_DOPRNT */
+
+/* Define if you have a working `mmap' system call.  */
+/* #undef HAVE_MMAP */
+
+/* Define if system calls automatically restart after interruption
+   by a signal.  */
+/* #undef HAVE_RESTARTABLE_SYSCALLS */
+
+/* Define if your struct stat has st_rdev.  */
+#define HAVE_ST_RDEV 1
+
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible.	*/
+//#define HAVE_SYS_WAIT_H 1
+
+/* Define if you don't have tm_zone but do have the external array
+   tzname.  */
+#define HAVE_TZNAME 1
+
+/* Define if utime(file, NULL) sets file's timestamp to the present.  */
+#define HAVE_UTIME_NULL 1
+
+/* Define if you have the vprintf function.  */
+#define HAVE_VPRINTF 1
+
+/* Define as __inline if that's what the C compiler calls it.  */
+/* #undef inline */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #undef off_t */
+
+/* Define as the return type of signal handlers (int or void).	*/
+#define RETSIGTYPE void
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+/* #undef size_t */
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#define STACK_DIRECTION -1
+
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
+/* #undef STAT_MACROS_BROKEN */
+
+/* Define if you have the ANSI C header files.	*/
+#define STDC_HEADERS 1
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if your <sys/time.h> declares struct tm.  */
+/* #undef TM_IN_SYS_TIME */
+
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).	*/
+/* #undef WORDS_BIGENDIAN */
+
+/* Version of .frm files */
+#define DOT_FRM_VERSION 6
+
+/* READLINE: */
+#define FIONREAD_IN_SYS_IOCTL 1
+
+/* READLINE: Define if your system defines TIOCGWINSZ in sys/ioctl.h.  */
+/* #undef GWINSZ_IN_SYS_IOCTL */
+
+/* Do we have FIONREAD */
+#define FIONREAD_IN_SYS_IOCTL 1
+
+/* atomic_add() from <asm/atomic.h> (Linux only) */
+/* #undef HAVE_ATOMIC_ADD */
+
+/* atomic_sub() from <asm/atomic.h> (Linux only) */
+/* #undef HAVE_ATOMIC_SUB */
+
+/* bool is not defined by all C++ compilators */
+#define HAVE_BOOL 1
+
+/* Have berkeley db installed */
+//#define HAVE_BERKELEY_DB 1
+
+/* DSB style signals ? */
+/* #undef HAVE_BSD_SIGNALS */
+
+/* Can netinet be included */
+/* #undef HAVE_BROKEN_NETINET_INCLUDES */
+
+/* READLINE: */
+/* #undef HAVE_BSD_SIGNALS */
+
+/* ZLIB and compress: */
+#define HAVE_COMPRESS 1
+
+/* Define if we are using OSF1 DEC threads */
+/* #undef HAVE_DEC_THREADS */
+
+/* Define if we are using OSF1 DEC threads on 3.2 */
+/* #undef HAVE_DEC_3_2_THREADS */
+
+/* fp_except from ieeefp.h */
+/* #undef HAVE_FP_EXCEPT */
+
+/* READLINE: */
+/* #undef HAVE_GETPW_DECLS */
+
+/* Solaris define gethostbyname_r with 5 arguments. glibc2 defines
+   this with 6 arguments */
+/* #undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE */
+
+/* In OSF 4.0f the 3'd argument to gethostname_r is hostent_data * */
+/* #undef HAVE_GETHOSTBYNAME_R_RETURN_INT */
+
+/* Define if int8, int16 and int32 types exist */
+/* #undef HAVE_INT_8_16_32 */
+
+/* Define if have -lwrap */
+/* #undef HAVE_LIBWRAP */
+
+/* Define if we are using Xavier Leroy's LinuxThreads */
+/* #undef HAVE_LINUXTHREADS */
+
+/* Do we use user level threads */
+/* #undef HAVE_mit_thread */
+
+/* For some non posix threads */
+/* #undef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC */
+
+/* For some non posix threads */
+/* #undef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
+
+/* READLINE: */
+#define HAVE_POSIX_SIGNALS 1
+
+/* sigwait with one argument */
+/* #undef HAVE_NONPOSIX_SIGWAIT */
+
+/* pthread_attr_setscope */
+#define HAVE_PTHREAD_ATTR_SETSCOPE 1
+
+/* POSIX readdir_r */
+/* #undef HAVE_READDIR_R */
+
+/* POSIX sigwait */
+/* #undef HAVE_SIGWAIT */
+
+/* crypt */
+#define HAVE_CRYPT 1
+
+/* Solaris define gethostbyaddr_r with 7 arguments. glibc2 defines
+   this with 8 arguments */
+/* #undef HAVE_SOLARIS_STYLE_GETHOST */
+
+/* Timespec has a ts_sec instead of tv_sev  */
+#define HAVE_TIMESPEC_TS_SEC 1
+
+/* Have the tzname variable */
+#define HAVE_TZNAME 1
+
+/* Define if the system files define uchar */
+/* #undef HAVE_UCHAR */
+
+/* Define if the system files define uint */
+/* #undef HAVE_UINT */
+
+/* Define if the system files define ulong */
+/* #undef HAVE_ULONG */
+
+/* UNIXWARE7 threads are not posix */
+/* #undef HAVE_UNIXWARE7_THREADS */
+
+/* new UNIXWARE7 threads that are not yet posix */
+/* #undef HAVE_UNIXWARE7_POSIX */
+
+/* READLINE: */
+/* #undef HAVE_USG_SIGHOLD */
+
+/* Define if want -lwrap */
+/* #undef LIBWRAP */
+
+/* mysql client protocoll version */
+#define PROTOCOL_VERSION 10
+
+/* Define if qsort returns void */
+#define QSORT_TYPE_IS_VOID 1
+
+/* Define as the return type of qsort (int or void). */
+#define RETQSORTTYPE void
+
+/* Define as the base type of the last arg to accept */
+#define SOCKET_SIZE_TYPE int
+
+/* Last argument to get/setsockopt */
+/* #undef SOCKOPT_OPTLEN_TYPE */
+
+/* #undef SPEED_T_IN_SYS_TYPES */
+/* #undef SPRINTF_RETURNS_PTR */
+#define SPRINTF_RETURNS_INT 1
+/* #undef SPRINTF_RETURNS_GARBAGE */
+
+/* #undef STRUCT_DIRENT_HAS_D_FILENO */
+#define STRUCT_DIRENT_HAS_D_INO 1
+
+/* Define if you want to have threaded code. This may be undef on client code */
+#define THREAD 1
+
+/* Should be client be thread safe */
+/* #undef THREAD_SAFE_CLIENT */
+
+/* READLINE: */
+/* #undef TIOCSTAT_IN_SYS_IOCTL */
+
+/* Use multi-byte character routines */
+/* #undef USE_MB */
+/* #undef USE_MB_IDENT */
+
+/* Use MySQL RAID */
+/* #undef USE_RAID */
+
+/* Use strcoll() functions when comparing and sorting. */
+/* #undef USE_STRCOLL */
+
+/* READLINE: */
+#define VOID_SIGHANDLER 1
+
+/* The number of bytes in a char.  */
+#define SIZEOF_CHAR 1
+
+/* The number of bytes in a int.  */
+#define SIZEOF_INT 4
+
+/* The number of bytes in a long.  */
+#define SIZEOF_LONG 4
+
+/* The number of bytes in a long long.	*/
+#define SIZEOF_LONG_LONG 8
+
+/* Define if you have the alarm function.  */
+#define HAVE_ALARM 1
+
+/* Define if you have the atod function.  */
+/* #undef HAVE_ATOD */
+
+/* Define if you have the bcmp function.  */
+#define HAVE_BCMP 1
+
+/* Define if you have the bfill function.  */
+/* #undef HAVE_BFILL */
+
+/* Define if you have the bmove function.  */
+/* #undef HAVE_BMOVE */
+
+/* Define if you have the bzero function.  */
+#define HAVE_BZERO 1
+
+/* Define if you have the chsize function.  */
+#define HAVE_CHSIZE 1
+
+/* Define if you have the cuserid function.  */
+//#define HAVE_CUSERID 1
+
+/* Define if you have the dlerror function.  */
+#define HAVE_DLERROR 1
+
+/* Define if you have the dlopen function.  */
+#define HAVE_DLOPEN 1
+
+/* Define if you have the fchmod function.  */
+/* #undef HAVE_FCHMOD */
+
+/* Define if you have the fcntl function.  */
+//#define HAVE_FCNTL 1
+
+/* Define if you have the fconvert function.  */
+/* #undef HAVE_FCONVERT */
+
+/* Define if you have the finite function.  */
+/* #undef HAVE_FINITE */
+
+/* Define if you have the fpresetsticky function.  */
+/* #undef HAVE_FPRESETSTICKY */
+
+/* Define if you have the fpsetmask function.  */
+/* #undef HAVE_FPSETMASK */
+
+/* Define if you have the fseeko function.  */
+/* #undef HAVE_FSEEKO */
+
+/* Define if you have the ftruncate function.  */
+//#define HAVE_FTRUNCATE 1
+
+/* Define if you have the getcwd function.  */
+#define HAVE_GETCWD 1
+
+/* Define if you have the gethostbyaddr_r function.  */
+/* #undef HAVE_GETHOSTBYADDR_R */
+
+/* Define if you have the gethostbyname_r function.  */
+/* #undef HAVE_GETHOSTBYNAME_R */
+
+/* Define if you have the getpagesize function.  */
+#define HAVE_GETPAGESIZE 1
+
+/* Define if you have the getpass function.  */
+//#define HAVE_GETPASS 1
+
+/* Define if you have the getpassphrase function.  */
+/* #undef HAVE_GETPASSPHRASE */
+
+/* Define if you have the getpwnam function.  */
+//#define HAVE_GETPWNAM 1
+
+/* Define if you have the getpwuid function.  */
+//#define HAVE_GETPWUID 1
+
+/* Define if you have the getrlimit function.  */
+/* #undef HAVE_GETRLIMIT */
+
+/* Define if you have the getrusage function.  */
+/* #undef HAVE_GETRUSAGE */
+
+/* Define if you have the getwd function.  */
+#define HAVE_GETWD 1
+
+/* Define if you have the index function.  */
+#define HAVE_INDEX 1
+
+/* Define if you have the initgroups function.	*/
+/* #undef HAVE_INITGROUPS */
+
+/* Define if you have the localtime_r function.  */
+#define HAVE_LOCALTIME_R 1
+
+/* Define if you have the locking function.  */
+/* #undef HAVE_LOCKING */
+
+/* Define if you have the longjmp function.  */
+#define HAVE_LONGJMP 1
+
+/* Define if you have the lrand48 function.  */
+/* #undef HAVE_LRAND48 */
+
+/* Define if you have the lstat function.  */
+/* #undef HAVE_LSTAT */
+
+/* Define if you have the madvise function.  */
+/* #undef HAVE_MADVISE */
+
+/* Define if you have the memcpy function.  */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the memmove function.  */
+#define HAVE_MEMMOVE 1
+
+/* Define if you have the mkstemp function.  */
+//#define HAVE_MKSTEMP 1
+
+/* Define if you have the mlockall function.  */
+/* #undef HAVE_MLOCKALL */
+
+/* Define if you have the perror function.  */
+#define HAVE_PERROR 1
+
+/* Define if you have the poll function.  */
+/* #undef HAVE_POLL */
+
+/* Define if you have the pread function.  */
+/* #undef HAVE_PREAD */
+
+/* Define if you have the pthread_attr_create function.  */
+/* #undef HAVE_PTHREAD_ATTR_CREATE */
+
+/* Define if you have the pthread_attr_setprio function.  */
+#define HAVE_PTHREAD_ATTR_SETPRIO 1
+
+/* Define if you have the pthread_attr_setschedparam function.	*/
+/* #undef HAVE_PTHREAD_ATTR_SETSCHEDPARAM */
+
+/* Define if you have the pthread_attr_setstacksize function.  */
+#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
+
+/* Define if you have the pthread_condattr_create function.  */
+/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
+
+/* Define if you have the pthread_getsequence_np function.  */
+/* #undef HAVE_PTHREAD_GETSEQUENCE_NP */
+
+/* Define if you have the pthread_init function.  */
+/* #undef HAVE_PTHREAD_INIT */
+
+/* Define if you have the pthread_rwlock_rdlock function.  */
+/* #undef HAVE_PTHREAD_RWLOCK_RDLOCK */
+
+/* Define if you have the pthread_setprio function.  */
+#define HAVE_PTHREAD_SETPRIO 1
+
+/* Define if you have the pthread_setprio_np function.	*/
+/* #undef HAVE_PTHREAD_SETPRIO_NP */
+
+/* Define if you have the pthread_setschedparam function.  */
+/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
+
+/* Define if you have the pthread_sigmask function.  */
+#define HAVE_PTHREAD_SIGMASK 1
+
+/* Define if you have the putenv function.  */
+#define HAVE_PUTENV 1
+
+/* Define if you have the readlink function.  */
+/* #undef HAVE_READLINK */
+
+/* Define if you have the realpath function.  */
+/* #undef HAVE_REALPATH */
+
+/* Define if you have the rename function.  */
+#define HAVE_RENAME 1
+
+/* Define if you have the rint function.  */
+#define HAVE_RINT 1
+
+/* Define if you have the rwlock_init function.  */
+/* #undef HAVE_RWLOCK_INIT */
+
+/* Define if you have the select function.  */
+#define HAVE_SELECT 1
+
+/* Define if you have the setenv function.  */
+/* #undef HAVE_SETENV */
+
+/* Define if you have the setlocale function.  */
+#define HAVE_SETLOCALE 1
+
+/* Define if you have the setupterm function.  */
+/* #undef HAVE_SETUPTERM */
+
+/* Define if you have the sighold function.  */
+/* #undef HAVE_SIGHOLD */
+
+/* Define if you have the sigset function.  */
+/* #undef HAVE_SIGSET */
+
+/* Define if you have the sigthreadmask function.  */
+/* #undef HAVE_SIGTHREADMASK */
+
+/* Define if you have the snprintf function.  */
+//#define HAVE_SNPRINTF 1
+
+/* Define if you have the socket function.  */
+#define HAVE_SOCKET 1
+
+/* Define if you have the stpcpy function.  */
+/* #undef HAVE_STPCPY */
+
+/* Define if you have the strcasecmp function.	*/
+/* #undef HAVE_STRCASECMP */
+
+/* Define if you have the strcoll function.  */
+#define HAVE_STRCOLL 1
+
+/* Define if you have the strerror function.  */
+#define HAVE_STRERROR 1
+
+/* Define if you have the strnlen function.  */
+/* #undef HAVE_STRNLEN */
+
+/* Define if you have the strpbrk function.  */
+#define HAVE_STRPBRK 1
+
+/* Define if you have the strstr function.  */
+#define HAVE_STRSTR 1
+
+/* Define if you have the strtok_r function.  */
+/* #undef HAVE_STRTOK_R */
+
+/* Define if you have the strtol function.  */
+#define HAVE_STRTOL 1
+
+/* Define if you have the strtoul function.  */
+#define HAVE_STRTOUL 1
+
+/* Define if you have the strtoull function.  */
+/* #undef HAVE_STRTOULL */
+
+/* Define if you have the tcgetattr function.  */
+#define HAVE_TCGETATTR 1
+
+/* Define if you have the tell function.  */
+#define HAVE_TELL 1
+
+/* Define if you have the tempnam function.  */
+#define HAVE_TEMPNAM 1
+
+/* Define if you have the thr_setconcurrency function.	*/
+/* #undef HAVE_THR_SETCONCURRENCY */
+
+/* Define if you have the vidattr function.  */
+/* #undef HAVE_VIDATTR */
+
+/* Define if you have the <alloca.h> header file.  */
+//#define HAVE_ALLOCA_H 1
+
+/* Define if you have the <arpa/inet.h> header file.  */
+#define HAVE_ARPA_INET_H 1
+
+/* Define if you have the <asm/termbits.h> header file.  */
+/* #undef HAVE_ASM_TERMBITS_H */
+
+/* Define if you have the <crypt.h> header file.  */
+#define HAVE_CRYPT_H 1
+
+/* Define if you have the <curses.h> header file.  */
+//#define HAVE_CURSES_H 1
+
+/* Define if you have the <dirent.h> header file.  */
+//#define HAVE_DIRENT_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <float.h> header file.  */
+#define HAVE_FLOAT_H 1
+
+/* Define if you have the <floatingpoint.h> header file.  */
+/* #undef HAVE_FLOATINGPOINT_H */
+
+/* Define if you have the <grp.h> header file.	*/
+//#define HAVE_GRP_H 1
+
+/* Define if you have the <ieeefp.h> header file.  */
+/* #undef HAVE_IEEEFP_H */
+
+/* Define if you have the <limits.h> header file.  */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <locale.h> header file.  */
+#define HAVE_LOCALE_H 1
+
+/* Define if you have the <memory.h> header file.  */
+#define HAVE_MEMORY_H 1
+
+/* Define if you have the <ndir.h> header file.  */
+/* #undef HAVE_NDIR_H */
+
+/* Define if you have the <netinet/in.h> header file.  */
+#define HAVE_NETINET_IN_H 1
+
+/* Define if you have the <paths.h> header file.  */
+/* #undef HAVE_PATHS_H */
+
+/* Define if you have the <pwd.h> header file.	*/
+//#define HAVE_PWD_H 1
+
+/* Define if you have the <sched.h> header file.  */
+/* #undef HAVE_SCHED_H */
+
+/* Define if you have the <select.h> header file.  */
+/* #undef HAVE_SELECT_H */
+
+/* Define if you have the <stdarg.h> header file.  */
+#define HAVE_STDARG_H 1
+
+/* Define if you have the <stddef.h> header file.  */
+#define HAVE_STDDEF_H 1
+
+/* Define if you have the <stdlib.h> header file.  */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file.  */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <strings.h> header file.  */
+//#define HAVE_STRINGS_H 1
+
+/* Define if you have the <synch.h> header file.  */
+/* #undef HAVE_SYNCH_H */
+
+/* Define if you have the <sys/dir.h> header file.  */
+//#define HAVE_SYS_DIR_H 1
+
+/* Define if you have the <sys/file.h> header file.  */
+//#define HAVE_SYS_FILE_H 1
+
+/* Define if you have the <sys/ioctl.h> header file.  */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define if you have the <sys/mman.h> header file.  */
+/* #undef HAVE_SYS_MMAN_H */
+
+/* Define if you have the <sys/ndir.h> header file.  */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define if you have the <sys/pte.h> header file.  */
+/* #undef HAVE_SYS_PTE_H */
+
+/* Define if you have the <sys/ptem.h> header file.  */
+/* #undef HAVE_SYS_PTEM_H */
+
+/* Define if you have the <sys/select.h> header file.  */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define if you have the <sys/socket.h> header file.  */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define if you have the <sys/stream.h> header file.  */
+/* #undef HAVE_SYS_STREAM_H */
+
+/* Define if you have the <sys/timeb.h> header file.  */
+#define HAVE_SYS_TIMEB_H 1
+
+/* Define if you have the <sys/types.h> header file.  */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sys/un.h> header file.  */
+#define HAVE_SYS_UN_H 1
+
+/* Define if you have the <sys/utime.h> header file.  */
+#define HAVE_SYS_UTIME_H 1
+
+/* Define if you have the <sys/vadvise.h> header file.	*/
+/* #undef HAVE_SYS_VADVISE_H */
+
+/* Define if you have the <sys/wait.h> header file.  */
+//#define HAVE_SYS_WAIT_H 1
+
+/* Define if you have the <term.h> header file.  */
+/* #undef HAVE_TERM_H */
+
+/* Define if you have the <termbits.h> header file.  */
+/* #undef HAVE_TERMBITS_H */
+
+/* Define if you have the <termcap.h> header file.  */
+//#define HAVE_TERMCAP_H 1
+
+/* Define if you have the <termio.h> header file.  */
+//#define HAVE_TERMIO_H 1
+
+/* Define if you have the <termios.h> header file.  */
+//#define HAVE_TERMIOS_H 1
+
+/* Define if you have the <unistd.h> header file.  */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <utime.h> header file.  */
+#define HAVE_UTIME_H 1
+
+/* Define if you have the <varargs.h> header file.  */
+#define HAVE_VARARGS_H 1
+
+/* Define if you have the bind library (-lbind).  */
+/* #undef HAVE_LIBBIND */
+
+/* Define if you have the c_r library (-lc_r).	*/
+/* #undef HAVE_LIBC_R */
+
+/* Define if you have the compat library (-lcompat).  */
+/* #undef HAVE_LIBCOMPAT */
+
+/* Define if you have the crypt library (-lcrypt).  */
+#define HAVE_LIBCRYPT 1
+
+/* Define if you have the dl library (-ldl).  */
+#define HAVE_LIBDL 1
+
+/* Define if you have the gen library (-lgen).	*/
+/* #undef HAVE_LIBGEN */
+
+/* Define if you have the m library (-lm).  */
+#define HAVE_LIBM 1
+
+/* Define if you have the nsl library (-lnsl).	*/
+/* #undef HAVE_LIBNSL */
+
+/* Define if you have the nsl_r library (-lnsl_r).  */
+/* #undef HAVE_LIBNSL_R */
+
+/* Define if you have the pthread library (-lpthread).	*/
+/* #undef HAVE_LIBPTHREAD */
+
+/* Define if you have the socket library (-lsocket).  */
+/* #undef HAVE_LIBSOCKET */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define to make fseeko etc. visible, on some hosts. */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+#endif // __CONFIG_OS2_H__
diff --git a/include/errmsg.h b/include/errmsg.h
index b7afe11b615..7a967954bab 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -29,6 +29,7 @@ extern const char *client_errors[];	/* Error messages */
 
 #define CR_MIN_ERROR		2000	/* For easier client code */
 #define CR_MAX_ERROR		2999
+#undef ER
 #define ER(X) client_errors[(X)-CR_MIN_ERROR]
 #define CLIENT_ERRMAP		2	/* Errormap used by my_error() */
 
diff --git a/include/global.h b/include/global.h
index a11600a96fc..d6a46e1b187 100644
--- a/include/global.h
+++ b/include/global.h
@@ -43,14 +43,14 @@
 
 #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
 #include <config-win.h>
+#elif defined(OS2)
+#include <config-os2.h>
 #else
 #include <my_config.h>
-#endif
-#if defined(__cplusplus)
-#if defined(inline)
+#if defined(__cplusplus) && defined(inline)
 #undef inline				/* fix configure problem */
 #endif
-#endif /* _cplusplus */
+#endif /* _WIN32... */
 
 /* Fix problem with S_ISLNK() on Linux */
 #if defined(HAVE_LINUXTHREADS)
@@ -76,7 +76,7 @@
 #define __STDC_EXT__ 1          /* To get large file support on hpux */
 #endif
 
-#if defined(THREAD) && !defined(__WIN__)
+#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
 #ifndef _POSIX_PTHREAD_SEMANTICS
 #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
 #endif
@@ -220,7 +220,9 @@
 #define POSIX_MISTAKE 1		/* regexp: Fix stupid spec error */
 #define USE_REGEX 1		/* We want the use the regex library */
 /* Do not define for ultra sparcs */
+#ifndef OS2
 #define USE_BMOVE512 1		/* Use this unless the system bmove is faster */
+#endif
 
 /* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
 #ifdef I_AM_PARANOID
@@ -470,7 +472,11 @@ extern double		my_atof(const char*);
 #endif
 #undef remove		/* Crashes MySQL on SCO 5.0.0 */
 #ifndef __WIN__
+#ifdef OS2
+#define closesocket(A)	soclose(A)
+#else
 #define closesocket(A)	close(A)
+#endif
 #ifndef ulonglong2double
 #define ulonglong2double(A) ((double) (A))
 #define my_off_t2double(A)  ((double) (A))
@@ -559,9 +565,13 @@ typedef long		my_ptrdiff_t;
 #ifndef NEAR
 #define NEAR				/* Who needs segments ? */
 #define FAR				/* On a good machine */
+#ifndef HUGE_PTR
 #define HUGE_PTR
 #endif
-#ifndef STDCALL
+#endif
+#if defined(__IBMC__) || defined(__IBMCPP__)
+#define STDCALL _System _Export
+#elif !defined( STDCALL)
 #define STDCALL
 #endif
 
@@ -629,10 +639,20 @@ typedef ulonglong my_off_t;
 typedef unsigned long my_off_t;
 #endif
 #define MY_FILEPOS_ERROR	(~(my_off_t) 0)
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
 typedef off_t os_off_t;
 #endif
 
+#if defined(__WIN__)
+#define socket_errno WSAGetLastError()
+#elif defined(OS2)
+#define socket_errno sock_errno()
+#define closesocket(A)	soclose(A)
+#else
+#define socket_errno errno
+#define closesocket(A) close(A)
+#endif
+
 typedef uint8		int7;	/* Most effective integer 0 <= x <= 127 */
 typedef short		int15;	/* Most effective integer 0 <= x <= 32767 */
 typedef char		*my_string; /* String of characters */
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 652bdd205c0..d31d09896dc 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -25,9 +25,19 @@
 #define ETIME ETIMEDOUT				/* For FreeBSD */
 #endif
 
-#if defined(__WIN__)
+#if defined(__WIN__) || defined(OS2)
 
+#ifdef OS2
+typedef ULONG     HANDLE;
+typedef ULONG     DWORD;
+typedef int sigset_t;
+#endif
+
+#ifdef OS2
+typedef HMTX             pthread_mutex_t;
+#else
 typedef CRITICAL_SECTION pthread_mutex_t;
+#endif
 typedef HANDLE		 pthread_t;
 typedef struct thread_attr {
     DWORD dwStackSize ;
@@ -46,19 +56,30 @@ typedef struct st_pthread_link {
 
 typedef struct {
   uint32 waiting;
+#ifdef OS2
+  HEV    semaphore;
+#else
   HANDLE semaphore;
+#endif
 } pthread_cond_t;
 
 
+#ifndef OS2
 struct timespec {		/* For pthread_cond_timedwait() */
     time_t tv_sec;
     long tv_nsec;
 };
+#endif
 
 typedef int pthread_mutexattr_t;
 #define win_pthread_self my_thread_var->pthread_self
+#ifdef OS2
+#define pthread_handler_decl(A,B) void * _Optlink A(void *B)
+typedef void * (_Optlink *pthread_handler)(void *);
+#else
 #define pthread_handler_decl(A,B) void * __cdecl A(void *B)
 typedef void * (__cdecl *pthread_handler)(void *);
+#endif
 
 void win_pthread_init(void);
 int win_pthread_setspecific(void *A,void *B,uint length);
@@ -78,12 +99,14 @@ struct tm *localtime_r(const time_t *timep,struct tm *tmp);
 
 void pthread_exit(void *a);	 /* was #define pthread_exit(A) ExitThread(A)*/
 
+#ifndef OS2
 #define ETIMEDOUT 145		    /* Win32 doesn't have this */
 #define getpid() GetCurrentThreadId()
+#endif
 #define pthread_self() win_pthread_self
-#define HAVE_LOCALTIME_R
-#define _REENTRANT
-#define HAVE_PTHREAD_ATTR_SETSTACKSIZE
+#define HAVE_LOCALTIME_R		1
+#define _REENTRANT			1
+#define HAVE_PTHREAD_ATTR_SETSTACKSIZE	1
 
 #ifdef USE_TLS					/* For LIBMYSQL.DLL */
 #undef SAFE_MUTEX				/* This will cause conflicts */
@@ -105,13 +128,23 @@ void pthread_exit(void *a);	 /* was #define pthread_exit(A) ExitThread(A)*/
 #endif /* USE_TLS */
 
 #define pthread_equal(A,B) ((A) == (B))
+#ifdef OS2
+int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *);
+int pthread_mutex_lock (pthread_mutex_t *);
+int pthread_mutex_unlock (pthread_mutex_t *);
+int pthread_mutex_destroy (pthread_mutex_t *);
+#define my_pthread_setprio(A,B)  DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A)
+#define pthread_kill(A,B) raise(B)
+#else
 #define pthread_mutex_init(A,B)  InitializeCriticalSection(A)
 #define pthread_mutex_lock(A)	 (EnterCriticalSection(A),0)
 #define pthread_mutex_unlock(A)  LeaveCriticalSection(A)
 #define pthread_mutex_destroy(A) DeleteCriticalSection(A)
 #define my_pthread_setprio(A,B)  SetThreadPriority(GetCurrentThread(), (B))
-/* Dummy defines for easier code */
 #define pthread_kill(A,B) pthread_dummy(0)
+#endif /* OS2 */
+
+/* Dummy defines for easier code */
 #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
 #define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
 #define pthread_attr_setscope(A,B)
@@ -311,12 +344,15 @@ extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
 #undef	HAVE_GETHOSTBYADDR_R			/* No definition */
 #endif
 
-#ifndef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC
+#if defined(OS2)
+#define my_pthread_getspecific(T,A) ((T) &(A))
+#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
+#elif !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC)
 #define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
 #else
 #define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
 void *my_pthread_getspecific_imp(pthread_key_t key);
-#endif
+#endif /* OS2 */
 
 #ifndef HAVE_LOCALTIME_R
 struct tm *localtime_r(const time_t *clock, struct tm *res);
diff --git a/include/my_sys.h b/include/my_sys.h
index 42f332bcee7..5b45f6a91e5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -126,6 +126,7 @@ extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
 extern ulonglong safemalloc_mem_limit;
 #else
 #define my_checkmalloc() (0)
+#undef TERMINATE
 #define TERMINATE(A) {}
 #define QUICK_SAFEMALLOC
 #define NORMAL_SAFEMALLOC
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 82eb34060a9..2e455c456fa 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -233,10 +233,4 @@ void my_thread_end(void);
 
 #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
 
-#ifdef __WIN__
-#define socket_errno WSAGetLastError()
-#else
-#define socket_errno errno
-#endif
-
 #endif
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
index da68b9fce07..1f3fed1d29b 100644
--- a/include/thr_alarm.h
+++ b/include/thr_alarm.h
@@ -65,7 +65,7 @@ typedef struct st_thr_alarm_entry
   rf_SetTimer crono;
 } thr_alarm_entry;
 
-#elif defined(__EMX__)
+#elif defined(__EMX__) || defined(OS2)
 
 typedef struct st_thr_alarm_entry
 {
diff --git a/isam/isamchk.c b/isam/isamchk.c
index bb9b7bfa16b..3aa1cf4e3c2 100644
--- a/isam/isamchk.c
+++ b/isam/isamchk.c
@@ -44,7 +44,7 @@ SET_STACK_SIZE(9000)			/* Minimum stack size for program */
 #define T_SORT_RECORDS	4096
 #define T_SORT_INDEX	8192
 #define T_WAIT_FOREVER	16384
-#define T_REP_BY_SORT	32768
+#define T_REP_BY_SORT	32768L
 
 
 #define O_NEW_INDEX	1		/* Bits set in out_flag */
@@ -74,17 +74,17 @@ SET_STACK_SIZE(9000)			/* Minimum stack size for program */
 #define UPDATE_STAT		2
 #define UPDATE_SORT		4
 
-typedef struct st_sort_key_blocks {		/* Used when sorting */
+typedef struct st_isam_sort_key_blocks {	/* Used when sorting */
   uchar *buff,*end_pos;
   uchar lastkey[N_MAX_POSSIBLE_KEY_BUFF];
   uint last_length;
   int inited;
-} SORT_KEY_BLOCKS;
+} ISAM_SORT_KEY_BLOCKS;
 
-typedef struct st_sort_info {
+typedef struct st_isam_sort_info {
   N_INFO *info;
   enum data_file_type new_data_file_type;
-  SORT_KEY_BLOCKS *key_block,*key_block_end;
+  ISAM_SORT_KEY_BLOCKS *key_block,*key_block_end;
   uint key,find_length;
   ulong pos,max_pos,filepos,start_recpos,filelength,dupp,max_records,unique,
     buff_length;
@@ -92,9 +92,9 @@ typedef struct st_sort_info {
   char *record,*buff;
   N_KEYDEF *keyinfo;
   N_KEYSEG *keyseg;
-} SORT_INFO;
+} ISAM_SORT_INFO;
 
-enum options {OPT_CHARSETS_DIR=256};
+enum ic_options {OPT_CHARSETS_DIR_IC=256};
 
 static ulong	use_buffers=0,read_buffer_length=0,write_buffer_length=0,
 		sort_buffer_length=0,sort_key_blocks=0,crc=0,unique_count=0;
@@ -120,7 +120,7 @@ static const char *type_names[]=
 
 static char temp_filename[FN_REFLEN], *isam_file_name, *default_charset; 
 static IO_CACHE read_cache;
-static SORT_INFO sort_info;
+static ISAM_SORT_INFO sort_info;
 static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
 
 static const char *load_default_groups[]= { "isamchk",0 };
@@ -137,8 +137,8 @@ static int chk_del(N_INFO *info,uint testflag);
 static int check_k_link(N_INFO *info,uint nr);
 static int chk_size(N_INFO *info);
 static int chk_key(N_INFO *info);
-static int chk_index(N_INFO *info,N_KEYDEF *keyinfo,ulong page,uchar *buff,
-		     ulong *keys,uint level);
+static int chk_index(N_INFO *info, N_KEYDEF *keyinfo, ulong page, uchar *buff,
+		     ulong *keys, uint level);
 static uint isam_key_length(N_INFO *info,N_KEYDEF *keyinfo);
 static unsigned long calc_checksum(ulong count);
 static int chk_data_link(N_INFO *info,int extend);
@@ -171,12 +171,12 @@ static int sort_key_cmp(const void *not_used, const void *a,const void *b);
 static int sort_key_write(const void *a);
 static ulong get_record_for_key(N_INFO *info,N_KEYDEF *keyinfo,
 				uchar *key);
-static int sort_insert_key(reg1 SORT_KEY_BLOCKS *key_block,uchar *key,
+static int sort_insert_key(reg1 ISAM_SORT_KEY_BLOCKS *key_block,uchar *key,
 			   ulong prev_block);
 static int sort_delete_record(void);
 static void usage(void);
 static int flush_pending_blocks(void);
-static SORT_KEY_BLOCKS	*alloc_key_blocks(uint blocks,uint buffer_length);
+static ISAM_SORT_KEY_BLOCKS	*alloc_key_blocks(uint blocks,uint buffer_length);
 static int test_if_almost_full(N_INFO *info);
 static int recreate_database(N_INFO **info,char *filename);
 static void save_integer(byte *pos,uint pack_length,ulong value);
@@ -186,9 +186,7 @@ static int update_state_info(N_INFO *info,uint update);
 
 	/* Main program */
 
-int main(argc,argv)
-int argc;
-char **argv;
+int main( int argc, char **argv)
 {
   int error;
   MY_INIT(argv[0]);
@@ -255,7 +253,7 @@ static CHANGEABLE_VAR changeable_vars[] = {
 static struct option long_options[] =
 {
   {"analyze",          no_argument,       0, 'a'},
-  {"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR},
+  {"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR_IC},
 #ifndef DBUG_OFF
   {"debug",            required_argument, 0, '#'},
 #endif
@@ -284,7 +282,7 @@ static struct option long_options[] =
 
 static void print_version(void)
 {
-  printf("%s  Ver 5.16 for %s at %s\n",my_progname,SYSTEM_TYPE,
+  printf("%s  Ver 5.17 for %s at %s\n",my_progname,SYSTEM_TYPE,
 	 MACHINE_TYPE);
 }
 
@@ -598,7 +596,7 @@ static void get_options(register int *argc,register char ***argv)
     case 'C':
       default_charset=optarg;
       break;
-    case OPT_CHARSETS_DIR:
+    case OPT_CHARSETS_DIR_IC:
       charsets_dir = optarg;
       break;
     case 'b':
@@ -706,9 +704,7 @@ static void get_options(register int *argc,register char ***argv)
 
 	/* Check delete links */
 
-static int chk_del(info,test_flag)
-reg1 N_INFO *info;
-uint test_flag;
+static int chk_del( reg1 N_INFO *info, uint test_flag)
 {
   reg2 ulong i;
   uint j,delete_link_length;
@@ -793,9 +789,7 @@ wrong:
 
 	/* Kontrollerar l{nkarna i nyckelfilen */
 
-static int check_k_link(info,nr)
-register N_INFO *info;
-uint nr;
+static int check_k_link( register N_INFO *info, uint nr)
 {
   ulong next_link,records;
   DBUG_ENTER("check_k_link");
@@ -898,8 +892,7 @@ static int chk_size(register N_INFO *info)
 
 	/* Kontrollerar nycklarna */
 
-static int chk_key(info)
-register N_INFO *info;
+static int chk_key( register N_INFO *info)
 {
   uint key;
   ulong keys,all_keydata,all_totaldata,key_totlength,length,
@@ -988,12 +981,8 @@ register N_INFO *info;
 
 	/* Check if index is ok */
 
-static int chk_index(info,keyinfo,page,buff,keys,level)
-N_INFO *info;
-N_KEYDEF *keyinfo;
-ulong page,*keys;
-uchar *buff;
-uint level;
+static int chk_index(N_INFO *info, N_KEYDEF *keyinfo, ulong page, uchar *buff,
+		     ulong *keys,uint level)
 {
   int flag;
   uint used_length,comp_flag,nod_flag;
@@ -1129,9 +1118,7 @@ ulong count;
 
 	/* Calc length of key in normal isam */
 
-static uint isam_key_length(info,keyinfo)
-N_INFO *info;
-reg1 N_KEYDEF *keyinfo;
+static uint isam_key_length( N_INFO *info, reg1 N_KEYDEF *keyinfo)
 {
   uint length;
   N_KEYSEG *keyseg;
@@ -2962,8 +2949,7 @@ static int sort_key_cmp(const void *not_used __attribute__((unused)),
 } /* sort_key_cmp */
 
 
-static int sort_key_write(a)
-const void *a;
+static int sort_key_write( const void *a)
 {
   int cmp=sort_info.key_block->inited ?
     _nisam_key_cmp(sort_info.keyseg,sort_info.key_block->lastkey,(uchar*) a,
@@ -2997,10 +2983,7 @@ const void *a;
 
 	/* get pointer to record from a key */
 
-static ulong get_record_for_key(info,keyinfo,key)
-N_INFO *info;
-N_KEYDEF *keyinfo;
-uchar *key;
+static ulong get_record_for_key( N_INFO *info, N_KEYDEF *keyinfo, uchar *key)
 {
   return _nisam_dpos(info,0,key+_nisam_keylength(keyinfo,key));
 } /* get_record_for_key */
@@ -3008,10 +2991,8 @@ uchar *key;
 
 	/* Insert a key in sort-key-blocks */
 
-static int sort_insert_key(key_block,key,prev_block)
-reg1 SORT_KEY_BLOCKS *key_block;
-uchar *key;
-ulong prev_block;
+static int sort_insert_key(reg1 ISAM_SORT_KEY_BLOCKS *key_block,
+			   uchar *key, ulong prev_block)
 {
   uint a_length,t_length,nod_flag;
   ulong filepos;
@@ -3140,7 +3121,7 @@ static int flush_pending_blocks()
   uint nod_flag,length;
   ulong filepos;
   N_INFO *info;
-  SORT_KEY_BLOCKS *key_block;
+  ISAM_SORT_KEY_BLOCKS *key_block;
   DBUG_ENTER("flush_pending_blocks");
 
   filepos= NI_POS_ERROR;			/* if empty file */
@@ -3169,16 +3150,15 @@ static int flush_pending_blocks()
 
 	/* alloc space and pointers for key_blocks */
 
-static SORT_KEY_BLOCKS *alloc_key_blocks(blocks,buffer_length)
-uint blocks,buffer_length;
+static ISAM_SORT_KEY_BLOCKS *alloc_key_blocks(uint blocks, uint buffer_length)
 {
   reg1 uint i;
-  SORT_KEY_BLOCKS *block;
+  ISAM_SORT_KEY_BLOCKS *block;
   DBUG_ENTER("alloc_key_blocks");
 
-  if (!(block=(SORT_KEY_BLOCKS*) my_malloc((sizeof(SORT_KEY_BLOCKS)+
-					    buffer_length+IO_SIZE)*blocks,
-					   MYF(0))))
+  if (!(block=(ISAM_SORT_KEY_BLOCKS*) my_malloc((sizeof(ISAM_SORT_KEY_BLOCKS)+
+						 buffer_length+IO_SIZE)*blocks,
+						MYF(0))))
   {
     print_error("Not Enough memory for sort-key-blocks");
     return(0);
@@ -3253,8 +3233,7 @@ void print_error(const char *fmt,...)
 
 	/* Check if file is almost full */
 
-static int test_if_almost_full(info)
-N_INFO *info;
+static int test_if_almost_full(N_INFO *info)
 {
   double diff= 0.9;
   if (info->s->base.options & HA_OPTION_COMPRESS_RECORD)
@@ -3274,9 +3253,7 @@ N_INFO *info;
 
 	/* Recreate table with bigger more alloced record-data */
 
-static int recreate_database(org_info,filename)
-N_INFO **org_info;
-char *filename;
+static int recreate_database(N_INFO **org_info, char *filename)
 {
   int error;
   N_INFO info;
@@ -3369,10 +3346,7 @@ end:
 
 	/* Store long in 1,2,3 or 4 bytes */
 
-static void save_integer(pos,pack_length,value)
-byte *pos;
-uint pack_length;
-ulong value;
+static void save_integer( byte *pos, uint pack_length, ulong value)
 {
   switch (pack_length) {
   case 4: int4store(pos,value); break;
@@ -3386,8 +3360,7 @@ ulong value;
 
 	/* write suffix to data file if neaded */
 
-static int write_data_suffix(info)
-N_INFO *info;
+static int write_data_suffix( N_INFO *info)
 {
   if (info->s->base.options & HA_OPTION_COMPRESS_RECORD &&
       sort_info.fix_datafile)
@@ -3407,9 +3380,7 @@ N_INFO *info;
 
 	/* Update state and isamchk_time of indexfile */
 
-static int update_state_info(info,update)
-N_INFO *info;
-uint update;
+static int update_state_info( N_INFO *info, uint update)
 {
   ISAM_SHARE *share=info->s;
   uint base_pos=uint2korr(info->s->state.header.base_pos);
diff --git a/isam/isamlog.c b/isam/isamlog.c
index d1347d46c2e..5763b697d07 100644
--- a/isam/isamlog.c
+++ b/isam/isamlog.c
@@ -1,15 +1,15 @@
 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 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, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
@@ -29,7 +29,7 @@
 
 #define FILENAME(A) (A ? A->show_name : "Unknown")
 
-struct file_info {
+struct isamlog_file_info {
   long process;
   int  filenr,id;
   my_string name,show_name,record;
@@ -46,7 +46,7 @@ struct test_if_open_param {
 struct st_access_param
 {
   ulong min_accessed;
-  struct file_info *found;
+  struct isamlog_file_info *found;
 };
 
 #define NO_FILEPOS (ulong) ~0L
@@ -56,21 +56,22 @@ static void get_options(int *argc,char ***argv);
 static int examine_log(my_string file_name,char **table_names);
 static int read_string(IO_CACHE *file,gptr *to,uint length);
 static int file_info_compare(void *a,void *b);
-static int test_if_open(struct file_info *key,element_count count,
+static int test_if_open(struct isamlog_file_info *key,element_count count,
 			struct test_if_open_param *param);
 static void fix_blob_pointers(N_INFO *isam,byte *record);
 static uint set_maximum_open_files(uint);
-static int test_when_accessed(struct file_info *key,element_count count,
+static int test_when_accessed(struct isamlog_file_info *key,element_count count,
 			      struct st_access_param *access_param);
-static void file_info_free(struct file_info *info);
+static void file_info_free(struct isamlog_file_info *info);
 static int close_some_file(TREE *tree);
-static int reopen_closed_file(TREE *tree,struct file_info *file_info);
-static int find_record_with_key(struct file_info *file_info,byte *record);
+static int reopen_closed_file(TREE *tree,struct isamlog_file_info *file_info);
+static int find_record_with_key(struct isamlog_file_info *file_info,
+				byte *record);
 static void printf_log(const char *str,...);
-static bool cmp_filename(struct file_info *file_info,my_string name);
+static bool cmp_filename(struct isamlog_file_info *file_info,my_string name);
 
 static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0,
-  recover=0,prefix_remove=0;
+  recover=0,prefix_remove=0,opt_processes=0;
 static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0;
 static ulong com_count[10][3],number_of_commands=(ulong) ~0L,start_offset=0,
 	     record_pos= NO_FILEPOS,isamlog_filepos,isamlog_process;
@@ -78,9 +79,7 @@ static const char *command_name[]=
 {"open","write","update","delete","close","extra","lock","re-open",NullS};
 
 
-int main(argc,argv)
-int argc;
-char **argv;
+int main(int argc, char **argv)
 {
   int error,i,first;
   ulong total_count,total_error,total_recover;
@@ -92,11 +91,11 @@ char **argv;
   max_files=(set_maximum_open_files(min(max_files,8))-6)/2;
 
   if (update)
-    printf("Trying to %s isamfiles according to log '%s'\n",
+    printf("Trying to %s ISAM files according to log '%s'\n",
 	   (recover ? "recover" : "update"),log_filename);
   error= examine_log(log_filename,argv);
   if (update && ! error)
-    puts("isamfile:s updated successfully");
+    puts("Tables updated successfully");
   total_count=total_error=total_recover=0;
   for (i=first=0 ; command_name[i] ; i++)
   {
@@ -128,17 +127,15 @@ char **argv;
 } /* main */
 
 
-static void get_options(argc,argv)
-register int *argc;
-register char ***argv;
+static void get_options(register int *argc, register char ***argv)
 {
   int help,version;
-  const char *usage;
-  char *pos, option;
+  const char *pos,*usage;
+  char option;
 
   help=0;
-  usage="Usage: %s [-?iruvIV] [-c #] [-f #] [-F filepath/] [-o #] [-R file recordpos] [-w write_file] [log-filename [table ...]] \n";
-  pos= (char*) "";
+  usage="Usage: %s [-?iruvIPV] [-c #] [-f #] [-F filepath/] [-o #] [-R file recordpos] [-w write_file] [log-filename [table ...]] \n";
+  pos= "";
 
   while (--*argc > 0 && *(pos = *(++*argv)) == '-' ) {
     while (*++pos)
@@ -147,7 +144,7 @@ register char ***argv;
       switch((option=*pos)) {
       case '#':
 	DBUG_PUSH (++pos);
-	pos= (char*) " ";			/* Skipp rest of arg */
+	pos=" ";				/* Skipp rest of arg */
 	break;
       case 'c':
 	if (! *++pos)
@@ -158,7 +155,7 @@ register char ***argv;
 	    pos= *(++*argv);
 	}
 	number_of_commands=(ulong) atol(pos);
-	pos= (char*) " ";
+	pos=" ";
 	break;
       case 'u':
 	update=1;
@@ -172,7 +169,7 @@ register char ***argv;
 	    pos= *(++*argv);
 	}
 	max_files=(uint) atoi(pos);
-	pos= (char*) " ";
+	pos=" ";
 	break;
       case 'i':
 	test_info=1;
@@ -186,7 +183,7 @@ register char ***argv;
 	    pos= *(++*argv);
 	}
 	start_offset=(ulong) atol(pos);
-	pos= (char*) " ";
+	pos=" ";
 	break;
       case 'p':
 	if (! *++pos)
@@ -202,6 +199,9 @@ register char ***argv;
 	update=1;
 	recover++;
 	break;
+      case 'P':
+	opt_processes=1;
+	break;
       case 'R':
 	if (! *++pos)
 	{
@@ -210,11 +210,11 @@ register char ***argv;
 	  else
 	    pos= *(++*argv);
 	}
-	record_pos_file=pos;
+	record_pos_file=(char*) pos;
 	if (!--*argc)
 	  goto err;
 	record_pos=(ulong) atol(*(++*argv));
-	pos= (char*) " ";
+	pos= " ";
 	break;
       case 'v':
 	verbose++;
@@ -227,8 +227,8 @@ register char ***argv;
 	  else
 	    pos= *(++*argv);
 	}
-	write_filename=pos;
-	pos= (char*) " ";
+	write_filename=(char*) pos;
+	pos=" ";
 	break;
       case 'F':
 	if (! *++pos)
@@ -238,20 +238,20 @@ register char ***argv;
 	  else
 	    pos= *(++*argv);
 	}
-	filepath=pos;
-	pos= (char*) " ";
+	filepath= (char*) pos;
+	pos=" ";
 	break;
       case 'V':
 	version=1;
 	/* Fall through */
       case 'I':
       case '?':
-	printf("%s  Ver 3.2 for %s at %s\n",my_progname,SYSTEM_TYPE,
+	printf("%s  Ver 3.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
 	       MACHINE_TYPE);
-	puts("TCX Datakonsult AB, by Monty, for your professional use\n");
+	puts("By Monty, for your professional use\n");
 	if (version)
 	  break;
-	puts("Write info about whats in a nisam log file.");
+	puts("Write info about whats in a ISAM log file.");
 	printf("If no file name is given %s is used\n",log_filename);
 	puts("");
 	printf(usage,my_progname);
@@ -261,6 +261,7 @@ register char ***argv;
 	puts("         -o \"offset\"         -p # \"remove # components from path\"");
 	puts("         -r \"recover\"        -R \"file recordposition\"");
 	puts("         -u \"update\"         -v \"verbose\"   -w \"write file\"");
+	puts("         -P \"processes\"");
 	puts("\nOne can give a second and a third '-v' for more verbose.");
 	puts("Normaly one does a update (-u).");
 	puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted.");
@@ -281,7 +282,7 @@ register char ***argv;
   }
   if (*argc >= 1)
   {
-    log_filename=pos;
+    log_filename=(char*) pos;
     (*argc)--;
     (*argv)++;
   }
@@ -308,7 +309,8 @@ static int examine_log(my_string file_name, char **table_names)
   FILE *write_file;
   enum ha_extra_function extra_command;
   TREE tree;
-  struct file_info file_info,*curr_file_info;
+  struct isamlog_file_info file_info,*curr_file_info;
+  char llbuff[22],llbuff2[22];
   DBUG_ENTER("examine_log");
 
   if ((file=my_open(file_name,O_RDONLY,MYF(MY_WME))) < 0)
@@ -336,8 +338,11 @@ static int examine_log(my_string file_name, char **table_names)
     isamlog_filepos=my_b_tell(&cache)-9L;
     file_info.filenr=uint2korr(head+1);
     isamlog_process=file_info.process=(long) uint4korr(head+3);
+    if (!opt_processes)
+      file_info.process=0;
     result=uint2korr(head+7);
-    if ((curr_file_info=(struct file_info*) tree_search(&tree,&file_info)))
+    if ((curr_file_info=(struct isamlog_file_info*)
+	 tree_search(&tree,&file_info)))
     {
       curr_file_info->accessed=access_time;
       if (update && curr_file_info->used && curr_file_info->closed)
@@ -352,7 +357,7 @@ static int examine_log(my_string file_name, char **table_names)
     }
     command=(uint) head[0];
     if (command < sizeof(com_count)/sizeof(com_count[0][0])/3 &&
-	(!curr_file_info || curr_file_info->used))
+	(!table_names[0] || (curr_file_info && curr_file_info->used)))
     {
       com_count[command][0]++;
       if (result)
@@ -360,12 +365,15 @@ static int examine_log(my_string file_name, char **table_names)
     }
     switch ((enum nisam_log_commands) command) {
     case LOG_OPEN:
-      com_count[command][0]--;			/* Must be counted explicite */
-      if (result)
-	com_count[command][1]--;
+      if (!table_names[0])
+      {
+	com_count[command][0]--;		/* Must be counted explicite */
+	if (result)
+	  com_count[command][1]--;
+      }
 
       if (curr_file_info)
-	printf("\nWarning: %s is opened twice with same process and filenumber\n",
+	printf("\nWarning: %s is opened with same process and filenumber\nMaybe you should use the -P option ?\n",
 	       curr_file_info->show_name);
       if (my_b_read(&cache,(byte*) head,2))
 	goto err;
@@ -376,11 +384,17 @@ static int examine_log(my_string file_name, char **table_names)
 	goto err;
       {
 	uint i;
-	char *pos=file_info.name,*to;
+	char *pos,*to;
+
+	/* Fix if old DOS files to new format */
+	for (pos=file_info.name; (pos=strchr(pos,'\\')) ; pos++)
+	  *pos= '/';
+
+	pos=file_info.name;
 	for (i=0 ; i < prefix_remove ; i++)
 	{
 	  char *next;
-	  if (!(next=strchr(pos,FN_LIBCHAR)))
+	  if (!(next=strchr(pos,'/')))
 	    break;
 	  pos=next+1;
 	}
@@ -426,7 +440,7 @@ static int examine_log(my_string file_name, char **table_names)
 	  files_open--;
 	}
 	if (!(file_info.isam= nisam_open(isam_file_name,O_RDWR,
-				      HA_OPEN_WAIT_IF_LOCKED)))
+					 HA_OPEN_WAIT_IF_LOCKED)))
 	  goto com_err;
 	if (!(file_info.record=my_malloc(file_info.isam->s->base.reclength,
 					 MYF(MY_WME))))
@@ -438,7 +452,7 @@ static int examine_log(my_string file_name, char **table_names)
       if (file_info.used)
       {
 	if (verbose && !record_pos_file)
-	  printf_log("%s: open",file_info.show_name);
+	  printf_log("%s: open -> %d",file_info.show_name, file_info.filenr);
 	com_count[command][0]++;
 	if (result)
 	  com_count[command][1]++;
@@ -453,7 +467,6 @@ static int examine_log(my_string file_name, char **table_names)
       {
 	if (!curr_file_info->closed)
 	  files_open--;
-	file_info_free(curr_file_info);
 	VOID(tree_delete(&tree,(gptr) curr_file_info));
       }
       break;
@@ -464,14 +477,17 @@ static int examine_log(my_string file_name, char **table_names)
       if (verbose && !record_pos_file &&
 	  (!table_names[0] || (curr_file_info && curr_file_info->used)))
 	printf_log("%s: %s(%d) -> %d",FILENAME(curr_file_info),
-		   command_name[command], extra_command,result);
+		   command_name[command], (int) extra_command,result);
       if (update && curr_file_info && !curr_file_info->closed)
       {
 	if (nisam_extra(curr_file_info->isam,extra_command) != (int) result)
 	{
+	  fflush(stdout);
 	  VOID(fprintf(stderr,
-		       "Warning: error %d, expected %d on command %s at %lx\n",
-		       my_errno,result,command_name[command],isamlog_filepos));
+		       "Warning: error %d, expected %d on command %s at %s\n",
+		       my_errno,result,command_name[command],
+		       llstr(isamlog_filepos,llbuff)));
+	  fflush(stderr);
 	}
       }
       break;
@@ -501,6 +517,9 @@ static int examine_log(my_string file_name, char **table_names)
 	    goto com_err;
 	  if (ni_result)
 	    com_count[command][2]++;		/* Mark error */
+	  if (verbose)
+	    printf_log("error: Got result %d from mi_delete instead of %d",
+		       ni_result, result);
 	}
       }
       break;
@@ -539,6 +558,8 @@ static int examine_log(my_string file_name, char **table_names)
 	      result=0;
 	      goto com_err;
 	    }
+	    if (verbose)
+	      printf_log("error: Didn't find row to update with mi_rrnd");
 	    if (recover == 1 || result ||
 		find_record_with_key(curr_file_info,buff))
 	    {
@@ -553,6 +574,9 @@ static int examine_log(my_string file_name, char **table_names)
 	  {
 	    if (!recover)
 	      goto com_err;
+	    if (verbose)
+	      printf_log("error: Got result %d from mi_update instead of %d",
+			 ni_result, result);
 	    if (ni_result)
 	      com_count[command][2]++;		/* Mark error */
 	  }
@@ -570,9 +594,10 @@ static int examine_log(my_string file_name, char **table_names)
 	  }
 	  if (! recover && filepos != curr_file_info->isam->lastpos)
 	  {
-	    printf("Warning: Wrote at position: %ld, should have been %ld",
-		   curr_file_info->isam->lastpos,(long) filepos);
-	    goto com_err;
+	    printf("error: Wrote at position: %s, should have been %s",
+		   llstr(curr_file_info->isam->lastpos,llbuff),
+		   llstr(filepos,llbuff2));
+	    goto end;
 	  }
 	}
       }
@@ -597,6 +622,7 @@ static int examine_log(my_string file_name, char **table_names)
       VOID(fprintf(stderr,
 		   "Error: found unknown command %d in logfile, aborted\n",
 		   command));
+      fflush(stderr);
       goto end;
     }
   }
@@ -609,11 +635,16 @@ static int examine_log(my_string file_name, char **table_names)
   DBUG_RETURN(0);
 
  err:
+  fflush(stdout);
   VOID(fprintf(stderr,"Got error %d when reading from logfile\n",my_errno));
+  fflush(stderr);
   goto end;
  com_err:
-  VOID(fprintf(stderr,"Got error %d, expected %d on command %s at %lx\n",
-	       my_errno,result,command_name[command],isamlog_filepos));
+  fflush(stdout);
+  VOID(fprintf(stderr,"Got error %d, expected %d on command %s at %s\n",
+	       my_errno,result,command_name[command],
+	       llstr(isamlog_filepos,llbuff)));
+  fflush(stderr);
  end:
   end_key_cache();
   delete_tree(&tree);
@@ -625,10 +656,7 @@ static int examine_log(my_string file_name, char **table_names)
 }
 
 
-static int read_string(file,to,length)
-IO_CACHE *file;
-reg1 gptr *to;
-reg2 uint length;
+static int read_string(IO_CACHE *file, reg1 gptr *to, reg2 uint length)
 {
   DBUG_ENTER("read_string");
 
@@ -647,24 +675,22 @@ reg2 uint length;
 }				/* read_string */
 
 
-static int file_info_compare(a,b)
-void *a;
-void *b;
+static int file_info_compare(void *a, void *b)
 {
   long lint;
 
-  if ((lint=((struct file_info*) a)->process -
-       ((struct file_info*) b)->process))
+  if ((lint=((struct isamlog_file_info*) a)->process -
+       ((struct isamlog_file_info*) b)->process))
     return lint < 0L ? -1 : 1;
-  return ((struct file_info*) a)->filenr - ((struct file_info*) b)->filenr;
+  return (((struct isamlog_file_info*) a)->filenr -
+	  ((struct isamlog_file_info*) b)->filenr);
 }
 
 	/* ARGSUSED */
 
-static int test_if_open (key,count,param)
-struct file_info *key;
-element_count count __attribute__((unused));
-struct test_if_open_param *param;
+static int test_if_open (struct isamlog_file_info *key,
+			 element_count count __attribute__((unused)),
+			 struct test_if_open_param *param)
 {
   if (!strcmp(key->name,param->name) && key->id > param->max_id)
     param->max_id=key->id;
@@ -672,9 +698,7 @@ struct test_if_open_param *param;
 }
 
 
-static void fix_blob_pointers(info,record)
-N_INFO *info;
-byte *record;
+static void fix_blob_pointers( N_INFO *info, byte *record)
 {
   byte *pos;
   N_BLOB *blob,*end;
@@ -689,8 +713,7 @@ byte *record;
   }
 }
 
-static uint set_maximum_open_files(maximum_files)
-uint maximum_files;
+static uint set_maximum_open_files(uint maximum_files)
 {
 #if defined(HAVE_GETRUSAGE) && defined(RLIMIT_NOFILE)
   struct rlimit rlimit;
@@ -725,10 +748,9 @@ uint maximum_files;
 	/* close the file with hasn't been accessed for the longest time */
 	/* ARGSUSED */
 
-static int test_when_accessed (key,count,access_param)
-struct file_info *key;
-element_count count __attribute__((unused));
-struct st_access_param *access_param;
+static int test_when_accessed (struct isamlog_file_info *key,
+			       element_count count __attribute__((unused)),
+			       struct st_access_param *access_param)
 {
   if (key->accessed < access_param->min_accessed && ! key->closed)
   {
@@ -739,9 +761,9 @@ struct st_access_param *access_param;
 }
 
 
-static void file_info_free(fileinfo)
-struct file_info *fileinfo;
+static void file_info_free(struct isamlog_file_info *fileinfo)
 {
+  DBUG_ENTER("file_info_free");
   if (update)
   {
     if (!fileinfo->closed)
@@ -751,12 +773,12 @@ struct file_info *fileinfo;
   }
   my_free(fileinfo->name,MYF(0));
   my_free(fileinfo->show_name,MYF(0));
+  DBUG_VOID_RETURN;
 }
 
 
 
-static int close_some_file(tree)
-TREE *tree;
+static int close_some_file(TREE *tree)
 {
   struct st_access_param access_param;
 
@@ -774,9 +796,7 @@ TREE *tree;
 }
 
 
-static int reopen_closed_file(tree,fileinfo)
-TREE *tree;
-struct file_info *fileinfo;
+static int reopen_closed_file(TREE *tree, struct isamlog_file_info *fileinfo)
 {
   char name[FN_REFLEN];
   if (close_some_file(tree))
@@ -794,9 +814,8 @@ struct file_info *fileinfo;
 
 	/* Try to find record with uniq key */
 
-static int find_record_with_key(file_info,record)
-struct file_info *file_info;
-byte *record;
+static int find_record_with_key(struct isamlog_file_info *file_info,
+				byte *record)
 {
   uint key;
   N_INFO *info=file_info->isam;
@@ -817,10 +836,11 @@ byte *record;
 
 static void printf_log(const char *format,...)
 {
+  char llbuff[21];
   va_list args;
   va_start(args,format);
   if (verbose > 2)
-    printf("%9ld:",isamlog_filepos);
+    printf("%9s:",llstr(isamlog_filepos,llbuff));
   if (verbose > 1)
     printf("%5ld ",isamlog_process);	/* Write process number */
   (void) vprintf((char*) format,args);
@@ -829,9 +849,7 @@ static void printf_log(const char *format,...)
 }
 
 
-static bool cmp_filename(file_info,name)
-struct file_info *file_info;
-my_string name;
+static bool cmp_filename(struct isamlog_file_info *file_info,my_string name)
 {
   if (!file_info)
     return 1;
diff --git a/isam/test1.c b/isam/test1.c
index 1ec5d8b0318..33c61a53d4a 100644
--- a/isam/test1.c
+++ b/isam/test1.c
@@ -21,9 +21,7 @@ static void get_options(int argc, char *argv[]);
 static int rec_pointer_size=0,verbose=0,remove_ant=0,pack_keys=1,flags[50],
   packed_field=FIELD_SKIPP_PRESPACE;
 
-int main(argc,argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
 {
   N_INFO *file;
   int i,j,error,deleted,found;
@@ -145,9 +143,7 @@ err:
 	/* l{ser optioner */
 	/* OBS! intierar endast DEBUG - ingen debuggning h{r ! */
 
-static void get_options(argc,argv)
-int argc;
-char *argv[];
+static void get_options(int argc, char *argv[])
 {
   char *pos;
 
diff --git a/isam/test2.c b/isam/test2.c
index 6ed041ad8c5..def6a4d3d5c 100644
--- a/isam/test2.c
+++ b/isam/test2.c
@@ -53,13 +53,11 @@ static char record[300],record2[300],key[100],key2[100],
 
 		/* Test program */
 
-int main(argc,argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
 {
   uint i;
   int j,n1,n2,n3,error,k;
-  uint write_count,update,dupp_keys,delete,start,length,blob_pos,
+  uint write_count,update,dupp_keys,opt_delete,start,length,blob_pos,
        reclength,ant;
   ulong lastpos,range_records,records;
   N_INFO *file;
@@ -138,7 +136,7 @@ char *argv[];
   else
     recinfo[6].base.type= FIELD_LAST;
 
-  write_count=update=dupp_keys=delete=0;
+  write_count=update=dupp_keys=opt_delete=0;
   blob_buffer=0;
 
   for (i=999 ; i>0 ; i--) key1[i]=0;
@@ -232,7 +230,7 @@ char *argv[];
 	printf("error: %d; can't delete record: \"%s\"\n", my_errno,read_record);
 	goto err;
       }
-      delete++;
+      opt_delete++;
       key1[atoi(read_record+keyinfo[0].seg[0].base.start)]--;
       key3[atoi(read_record+keyinfo[2].seg[0].base.start)]=0;
     }
@@ -346,9 +344,9 @@ char *argv[];
   }
   while (nisam_rnext(file,read_record3,0) == 0 && ant < write_count+10)
     ant++;
-  if (ant != write_count - delete)
+  if (ant != write_count - opt_delete)
   {
-    printf("next: I found: %d records of %d\n",ant,write_count - delete);
+    printf("next: I found: %d records of %d\n",ant,write_count - opt_delete);
     goto end;
   }
   if (nisam_rlast(file,read_record2,0) ||
@@ -362,7 +360,7 @@ char *argv[];
   ant=1;
   while (nisam_rprev(file,read_record3,0) == 0 && ant < write_count+10)
     ant++;
-  if (ant != write_count - delete)
+  if (ant != write_count - opt_delete)
   {
     printf("prev: I found: %d records of %d\n",ant,write_count);
     goto end;
@@ -414,7 +412,7 @@ char *argv[];
     if (nisam_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err;
     if (nisam_rnext(file,read_record3,0)) goto err;
     if (nisam_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=1;
     while (nisam_rnext(file,read_record3,0) == 0 &&
 	   bcmp(read_record3+start,key,length) == 0) ant++;
@@ -431,7 +429,7 @@ char *argv[];
     if (nisam_rprev(file,read_record3,0)) goto err;
     if (nisam_rprev(file,read_record3,0)) goto err;
     if (nisam_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=1;
     while (nisam_rprev(file,read_record3,0) == 0 &&
 	   bcmp(read_record3+start,key,length) == 0) ant++;
@@ -447,7 +445,7 @@ char *argv[];
     DBUG_PRINT("progpos",("first - delete - next -> last"));
     if (nisam_rkey(file,read_record3,0,key,0,HA_READ_KEY_EXACT)) goto err;
     if (nisam_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=1;
     if (nisam_rnext(file,read_record,0))
       goto err;					/* Skall finnas poster */
@@ -463,7 +461,7 @@ char *argv[];
     DBUG_PRINT("progpos",("last - delete - prev -> first"));
     if (nisam_rprev(file,read_record3,0)) goto err;
     if (nisam_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=0;
     while (nisam_rprev(file,read_record3,0) == 0 &&
 	   bcmp(read_record3+start,key,length) == 0) ant++;
@@ -555,11 +553,11 @@ char *argv[];
 
   printf("- nisam_info\n");
   nisam_info(file,&info,0);
-  if (info.records != write_count-delete || info.deleted > delete + update
+  if (info.records != write_count-opt_delete || info.deleted > opt_delete + update
       || info.keys != keys)
   {
     puts("Wrong info from nisam_info");
-    printf("Got: records: %ld  delete: %ld  i_keys: %d\n",
+    printf("Got: records: %ld  opt_delete: %ld  i_keys: %d\n",
 	   info.records,info.deleted,info.keys);
   }
   if (verbose)
@@ -591,10 +589,10 @@ char *argv[];
   while ((error=nisam_rrnd(file,record,NI_POS_ERROR)) >= 0 &&
 	 ant < write_count + 10)
 	ant+= error ? 0 : 1;
-  if (ant != write_count-delete)
+  if (ant != write_count-opt_delete)
   {
     printf("rrnd with cache: I can only find: %d records of %d\n",
-	   ant,write_count-delete);
+	   ant,write_count-opt_delete);
     goto end;
   }
   if (nisam_extra(file,HA_EXTRA_NO_CACHE))
@@ -648,14 +646,14 @@ char *argv[];
 	printf("can't delete record: %s\n",read_record);
 	goto err;
       }
-      delete++;
+      opt_delete++;
     }
   }
   if (my_errno != HA_ERR_END_OF_FILE && my_errno != HA_ERR_RECORD_DELETED)
     printf("error: %d from nisam_rrnd\n",my_errno);
-  if (write_count != delete)
+  if (write_count != opt_delete)
   {
-    printf("Deleted only %d of %d records\n",write_count,delete);
+    printf("Deleted only %d of %d records\n",write_count,opt_delete);
     goto err;
   }
 end:
@@ -663,7 +661,7 @@ end:
     goto err;
   nisam_panic(HA_PANIC_CLOSE);			/* Should close log */
   printf("\nFollowing test have been made:\n");
-  printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,delete);
+  printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete);
   if (rec_pointer_size)
     printf("Record pointer size: %d\n",rec_pointer_size);
   if (key_cacheing)
@@ -692,9 +690,7 @@ err:
 	/* l{ser optioner */
 	/* OBS! intierar endast DEBUG - ingen debuggning h{r ! */
 
-static void get_options(argc,argv)
-int argc;
-char *argv[];
+static void get_options( int argc, char *argv[])
 {
   char *pos,*progname;
   DEBUGGER_OFF;
@@ -785,8 +781,7 @@ char *argv[];
 
 	/* Ge ett randomv{rde inom ett intervall 0 <=x <= n */
 
-static uint rnd(max_value)
-uint max_value;
+static uint rnd( uint max_value)
 {
   return (uint) ((rand() & 32767)/32767.0*max_value);
 } /* rnd */
@@ -794,9 +789,7 @@ uint max_value;
 
 	/* G|r en record av skiftande length */
 
-static void fix_length(rec,length)
-byte *rec;
-uint length;
+static void fix_length( byte *rec, uint length)
 {
   bmove(rec+STANDAR_LENGTH,
 	"0123456789012345678901234567890123456789012345678901234567890",
@@ -807,8 +800,7 @@ uint length;
 
 	/* Put maybe a blob in record */
 
-static void put_blob_in_record(blob_pos,blob_buffer)
-char *blob_pos,**blob_buffer;
+static void put_blob_in_record(char *blob_pos, char **blob_buffer)
 {
   ulong i,length;
   if (use_blob)
@@ -836,10 +828,7 @@ char *blob_pos,**blob_buffer;
 }
 
 
-static void copy_key(info,inx,rec,key_buff)
-N_INFO *info;
-uint inx;
-uchar *rec,*key_buff;
+static void copy_key( N_INFO *info, uint inx, uchar *rec, uchar *key_buff)
 {
   N_KEYSEG *keyseg;
 
diff --git a/isam/test_all.res b/isam/test_all.res
index 756a05f869c..f6280dd9f98 100644
--- a/isam/test_all.res
+++ b/isam/test_all.res
@@ -11,16 +11,16 @@ test2 -L -K -W -P
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Key cacheing used
 Write cacheing used
 Locking used
@@ -37,16 +37,16 @@ test2 -L -K -W -P -A
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Key cacheing used
 Write cacheing used
 Asyncron io with locking used
@@ -62,16 +62,16 @@ test2 -L -K -W -P -S -R1 -m500
 - Test read key-part
 - Read key (first) - next - delete - next -> last
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 484
-Update records: 48
-Same-key-read: 3
-Delete records: 484
+Write records: 475
+Update records: 44
+Same-key-read: 4
+Delete records: 475
 Record pointer size: 1
 Key cacheing used
 Write cacheing used
@@ -79,8 +79,31 @@ Locking used
 test2 -L -K -R1 -m2000 ; Should give error 135
 - Creating isam-file
 - Writing key:s
-Error: 135 in write at record: 1122
-got error: 135 when using NISAM-database
+- Delete
+- Update
+- Same key: first - next -> last - prev -> first
+- All keys: first - next -> last - prev -> first
+- Test if: Read first - next - prev - prev - next == first
+- Test if: Read last - prev - next - next - prev == last
+- Test read key-part
+- Read key (first) - next - delete - next -> last
+- Read last of key - prev - delete - prev -> first
+- Read first - delete - next -> last
+- Read last - delete - prev -> first
+- Test if: Read rrnd - same
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
+- Removing keys
+
+Following test have been made:
+Write records: 1647
+Update records: 125
+Same-key-read: 8
+Delete records: 1647
+Record pointer size: 1
+Key cacheing used
+Locking used
 test2 -L -K -P -S -R3 -m50 -b1000000
 - Creating isam-file
 - Writing key:s
@@ -92,9 +115,9 @@ test2 -L -K -P -S -R3 -m50 -b1000000
 - Test if: Read last - prev - next - next - prev == last
 - Test read key-part
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
@@ -118,16 +141,16 @@ test2 -L -B
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 912
-Update records: 81
+Write records: 903
+Update records: 86
 Same-key-read: 5
-Delete records: 912
+Delete records: 903
 Locking used
 blobs used
 test2 -L -K -W -P -m50 -l
@@ -141,9 +164,9 @@ test2 -L -K -W -P -m50 -l
 - Test if: Read last - prev - next - next - prev == last
 - Test read key-part
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
@@ -155,13 +178,13 @@ Key cacheing used
 Write cacheing used
 Locking used
 Commands   Used count    Errors   Recover errors
-open                3         0                0
-write             150         0                0
-update             15         0                0
-delete            150         0                0
-close               3         0                0
-extra              18         0                0
-Total             339         0                0
+open               14         0                0
+write             700         0                0
+update             70         0                0
+delete            700         0                0
+close              14         0                0
+extra              84         0                0
+Total            1582         0                0
 test2 -L -K -W -P -m50 -l -b100
 - Creating isam-file
 - Writing key:s
@@ -173,9 +196,9 @@ test2 -L -K -W -P -m50 -l -b100
 - Test if: Read last - prev - next - next - prev == last
 - Test read key-part
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
@@ -187,13 +210,13 @@ Key cacheing used
 Write cacheing used
 Locking used
 Commands   Used count    Errors   Recover errors
-open                4         0                0
-write             200         0                0
-update             20         0                0
-delete            200         0                0
-close               4         0                0
-extra              24         0                0
-Total             452         0                0
+open               15         0                0
+write             750         0                0
+update             75         0                0
+delete            750         0                0
+close              15         0                0
+extra              90         0                0
+Total            1695         0                0
 time test2
 - Creating isam-file
 - Writing key:s
@@ -207,18 +230,16 @@ time test2
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
-4.77user 6.81system 0:15.07elapsed 76%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
+Delete records: 907
 time test2 -K
 - Creating isam-file
 - Writing key:s
@@ -232,19 +253,17 @@ time test2 -K
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Key cacheing used
-6.09user 4.33system 0:11.66elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
 time test2 -L
 - Creating isam-file
 - Writing key:s
@@ -258,19 +277,17 @@ time test2 -L
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Locking used
-5.01user 5.20system 0:10.86elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
 time test2 -L -K
 - Creating isam-file
 - Writing key:s
@@ -284,20 +301,18 @@ time test2 -L -K
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Key cacheing used
 Locking used
-5.63user 0.97system 0:07.85elapsed 84%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
 time test2 -L -K -W
 - Creating isam-file
 - Writing key:s
@@ -311,21 +326,19 @@ time test2 -L -K -W
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Key cacheing used
 Write cacheing used
 Locking used
-5.28user 1.32system 0:08.86elapsed 74%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
 time test2 -L -K -W -S
 - Creating isam-file
 - Writing key:s
@@ -339,18 +352,16 @@ time test2 -L -K -W -S
 - Read key (first) - next - delete - next -> last
 - Read last of key - prev - delete - prev -> first
 - Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
 - Removing keys
 
 Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
 Same-key-read: 6
-Delete records: 915
+Delete records: 907
 Key cacheing used
 Write cacheing used
 Locking used
-5.32user 0.62system 0:06.13elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
diff --git a/libmysql/get_password.c b/libmysql/get_password.c
index d61c40a9559..989de9dd11a 100644
--- a/libmysql/get_password.c
+++ b/libmysql/get_password.c
@@ -35,7 +35,7 @@
 #include <pwd.h>
 #endif /* HAVE_PWD_H */
 #else /* ! HAVE_GETPASS */
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
 #include <sys/ioctl.h>
 #ifdef HAVE_TERMIOS_H				/* For tty-password */
 #include	<termios.h>
@@ -62,9 +62,8 @@
 #define getpass(A) getpassphrase(A)
 #endif
 
-#ifdef __WIN__
-/* were just going to fake it here and get input from
-   the keyboard */
+#if defined( __WIN__) || defined(OS2)
+/* were just going to fake it here and get input from the keyboard */
 
 char *get_tty_password(char *opt_message)
 {
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 4101fe18ea1..469331641c8 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -77,8 +77,7 @@ my_string	mysql_unix_port=0;
 #include <errno.h>
 #define ERRNO errno
 #define SOCKET_ERROR -1
-#define closesocket(A) close(A)
-#endif
+#endif /* __WIN__ */
 
 static void mysql_once_init(void);
 static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
@@ -121,7 +120,7 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
 static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
 		    uint timeout)
 {
-#if defined(__WIN__)
+#if defined(__WIN__) || defined(OS2)
   return connect(s, (struct sockaddr*) name, namelen);
 #else
   int flags, res, s_err;
@@ -490,7 +489,7 @@ struct passwd *getpwuid(uid_t);
 char* getlogin(void);
 #endif
 
-#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__)
+#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) && !defined(OS2)
 static void read_user_name(char *name)
 {
   DBUG_ENTER("read_user_name");
diff --git a/libmysql/net.c b/libmysql/net.c
index 11497cc7077..ba0944a2516 100644
--- a/libmysql/net.c
+++ b/libmysql/net.c
@@ -34,6 +34,7 @@
 #include <signal.h>
 #include <errno.h>
 #include <sys/types.h>
+#include <violite.h>
 
 #ifdef MYSQL_SERVER
 ulong max_allowed_packet=65536;
@@ -67,13 +68,19 @@ void sql_print_error(const char *format,...);
 #define RETRY_COUNT mysqld_net_retry_count
 extern ulong mysqld_net_retry_count;
 #else
+
+#ifdef OS2				/* avoid name conflict */
+#define thr_alarm_t  thr_alarm_t_net
+#define ALARM        ALARM_net
+#endif
+
 typedef my_bool thr_alarm_t;
 typedef my_bool ALARM;
-#define thr_alarm_init(A) (*A)=0
+#define thr_alarm_init(A) (*(A))=0
 #define thr_alarm_in_use(A) (*(A))
 #define thr_end_alarm(A)
 #define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
-static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
+inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
 {
   *A=1;
   return 0;
@@ -123,7 +130,7 @@ int my_net_init(NET *net, Vio* vio)
   if (vio != 0)					/* If real connection */
   {
     net->fd  = vio_fd(vio);			/* For perl DBI/DBD */
-#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__)
+#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
     if (!(test_flags & TEST_BLOCKING))
       vio_blocking(vio, FALSE);
 #endif
@@ -270,7 +277,7 @@ net_real_write(NET *net,const char *packet,ulong len)
   int length;
   char *pos,*end;
   thr_alarm_t alarmed;
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
   ALARM alarm_buff;
 #endif
   uint retry_count=0;
@@ -328,7 +335,7 @@ net_real_write(NET *net,const char *packet,ulong len)
     if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
     {
       my_bool interrupted = vio_should_retry(net->vio);
-#if (!defined(__WIN__) && !defined(__EMX__))
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
       if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
       {
         if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
@@ -425,7 +432,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
     if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L)
     {
       my_bool interrupted = vio_should_retry(net->vio);
-      if (!thr_got_alarm(&alarmed) && interrupted)
+      if (!thr_got_alarm(alarmed) && interrupted)
       {					/* Probably in MIT threads */
 	if (retry_count++ < RETRY_COUNT)
 	  continue;
@@ -447,7 +454,7 @@ my_real_read(NET *net, ulong *complen)
   uint i,retry_count=0;
   ulong len=packet_error;
   thr_alarm_t alarmed;
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
   ALARM alarm_buff;
 #endif
   my_bool net_blocking=vio_is_blocking(net->vio);
@@ -474,7 +481,7 @@ my_real_read(NET *net, ulong *complen)
 
 	  DBUG_PRINT("info",("vio_read returned %d,  errno: %d",
 			     length, vio_errno(net->vio)));
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
 	  /*
 	    We got an error that there was no data on the socket. We now set up
 	    an alarm to not 'read forever', change the socket to non blocking
diff --git a/libmysql/violite.c b/libmysql/violite.c
index 25ab5db31d2..aff4224e5a3 100644
--- a/libmysql/violite.c
+++ b/libmysql/violite.c
@@ -35,11 +35,13 @@
 #ifdef HAVE_POLL
 #include <sys/poll.h>
 #endif
-
-#if defined(__EMX__)
+#ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+#endif
+
+#if defined(__EMX__) || defined(OS2)
 #define ioctlsocket ioctl
-#endif				/* defined(__EMX__) */
+#endif	/* defined(__EMX__) */
 
 #if defined(MSDOS) || defined(__WIN__)
 #ifdef __WIN__
@@ -103,9 +105,12 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
     sprintf(vio->desc,
 	    (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
 	    vio->sd);
-#if !defined(___WIN__) && !defined(__EMX__)
+#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
 #if !defined(NO_FCNTL_NONBLOCK)
     vio->fcntl_mode = fcntl(sd, F_GETFL);
+#elif defined(HAVE_SYS_IOCTL_H)			/* hpux */
+    /* Non blocking sockets doesn't work good on HPUX 11.0 */
+    (void) ioctl(sd,FIOSNBIO,0);
 #endif
 #else /* !defined(__WIN__) && !defined(__EMX__) */
     {
@@ -149,7 +154,7 @@ void vio_delete(Vio * vio)
 
 int vio_errno(Vio *vio __attribute__((unused)))
 {
-  return errno;			/* On Win32 this mapped to WSAGetLastError() */
+  return socket_errno;		/* On Win32 this mapped to WSAGetLastError() */
 }
 
 
@@ -158,12 +163,17 @@ int vio_read(Vio * vio, gptr buf, int size)
   int r;
   DBUG_ENTER("vio_read");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   if (vio->type == VIO_TYPE_NAMEDPIPE)
   {
     DWORD length;
+#ifdef OS2
+    if (!DosRead((HFILE)vio->hPipe, buf, size, &length))
+      DBUG_RETURN(-1);
+#else
     if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
       DBUG_RETURN(-1);
+#endif
     DBUG_RETURN(length);
   }
   r = recv(vio->sd, buf, size,0);
@@ -174,7 +184,7 @@ int vio_read(Vio * vio, gptr buf, int size)
 #ifndef DBUG_OFF
   if (r < 0)
   {
-    DBUG_PRINT("error", ("Got error %d during read",errno));
+    DBUG_PRINT("vio_error", ("Got error %d during read",socket_errno));
   }
 #endif /* DBUG_OFF */
   DBUG_PRINT("exit", ("%d", r));
@@ -187,12 +197,17 @@ int vio_write(Vio * vio, const gptr buf, int size)
   int r;
   DBUG_ENTER("vio_write");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   if ( vio->type == VIO_TYPE_NAMEDPIPE)
   {
     DWORD length;
+#ifdef OS2
+    if (!DosWrite((HFILE)vio->hPipe, (char*) buf, size, &length))
+      DBUG_RETURN(-1);
+#else
     if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
       DBUG_RETURN(-1);
+#endif
     DBUG_RETURN(length);
   }
   r = send(vio->sd, buf, size,0);
@@ -202,7 +217,7 @@ int vio_write(Vio * vio, const gptr buf, int size)
 #ifndef DBUG_OFF
   if (r < 0)
   {
-    DBUG_PRINT("error", ("Got error on write: %d",errno));
+    DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno));
   }
 #endif /* DBUG_OFF */
   DBUG_PRINT("exit", ("%d", r));
@@ -216,7 +231,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode)
   DBUG_ENTER("vio_blocking");
   DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode));
 
-#if !defined(___WIN__) && !defined(__EMX__)
+#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
 #if !defined(NO_FCNTL_NONBLOCK)
 
   if (vio->sd >= 0)
@@ -341,7 +356,7 @@ int vio_close(Vio * vio)
   }
   if (r)
   {
-    DBUG_PRINT("error", ("close() failed, error: %d",errno));
+    DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno));
     /* FIXME: error handling (not critical for MySQL) */
   }
   vio->type= VIO_CLOSED;
@@ -380,7 +395,7 @@ my_bool vio_peer_addr(Vio * vio, char *buf)
     if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)),
 		    &addrLen) != 0)
     {
-      DBUG_PRINT("exit", ("getpeername, error: %d", errno));
+      DBUG_PRINT("exit", ("getpeername, error: %d", socket_errno));
       DBUG_RETURN(1);
     }
     my_inet_ntoa(vio->remote.sin_addr,buf);
diff --git a/merge/_locking.c b/merge/_locking.c
index f90b41e2375..81582da1312 100644
--- a/merge/_locking.c
+++ b/merge/_locking.c
@@ -20,9 +20,7 @@
 
 #include "mrgdef.h"
 
-int mrg_lock_database(info,lock_type)
-MRG_INFO *info;
-int lock_type;
+int mrg_lock_database(MRG_INFO *info,int lock_type)
 {
   int error,new_error;
   MRG_TABLE *file;
diff --git a/merge/close.c b/merge/close.c
index 45aa889ef0c..2b769ade8e9 100644
--- a/merge/close.c
+++ b/merge/close.c
@@ -18,8 +18,7 @@
 
 #include "mrgdef.h"
 
-int mrg_close(info)
-register MRG_INFO *info;
+int mrg_close(register MRG_INFO *info)
 {
   int error=0,new_error;
   MRG_TABLE *file;
diff --git a/merge/create.c b/merge/create.c
index e7086210237..fd2c16f9ea2 100644
--- a/merge/create.c
+++ b/merge/create.c
@@ -23,8 +23,7 @@
 	   a NULL-pointer last
 	   */
 
-int mrg_create(name,table_names)
-const char *name,**table_names;
+int mrg_create(const char *name, const char**table_names)
 {
   int save_errno;
   uint errpos;
diff --git a/merge/extra.c b/merge/extra.c
index 343806dbfad..c4f048a4385 100644
--- a/merge/extra.c
+++ b/merge/extra.c
@@ -22,9 +22,9 @@
 
 #include "mrgdef.h"
 
-int mrg_extra(info,function)
-MRG_INFO *info;
-enum ha_extra_function function;
+int mrg_extra(
+MRG_INFO *info,
+enum ha_extra_function function)
 {
   MRG_TABLE *file;
 
diff --git a/merge/open.c b/merge/open.c
index 35005e6e718..c1be98b7e18 100644
--- a/merge/open.c
+++ b/merge/open.c
@@ -30,10 +30,10 @@
 */
 
 
-MRG_INFO *mrg_open(name,mode,handle_locking)
-const char *name;
-int mode;
-int handle_locking;
+MRG_INFO *mrg_open(
+const char *name,
+int mode,
+int handle_locking)
 {
   int save_errno,i,errpos;
   uint files,dir_length,length;
diff --git a/merge/panic.c b/merge/panic.c
index c3820fe468d..cf333e3a9bf 100644
--- a/merge/panic.c
+++ b/merge/panic.c
@@ -24,8 +24,8 @@
 	   done for all single user files to get changes in database */
 
 
-int mrg_panic(flag)
-enum ha_panic_function flag;
+int mrg_panic(
+enum ha_panic_function flag)
 {
   int error=0;
   LIST *list_element,*next_open;
diff --git a/merge/rsame.c b/merge/rsame.c
index a18f1771c37..4ebf25b21c1 100644
--- a/merge/rsame.c
+++ b/merge/rsame.c
@@ -17,10 +17,10 @@
 #include "mrgdef.h"
 
 
-int mrg_rsame(info,record,inx)
-MRG_INFO *info;
-byte *record;
-int inx;				/* not used, should be 0 */
+int mrg_rsame(
+MRG_INFO *info,
+byte *record,
+int inx)				/* not used, should be 0 */
 {
   if (inx)
   {
diff --git a/merge/update.c b/merge/update.c
index 64900b82116..9fcb82089e4 100644
--- a/merge/update.c
+++ b/merge/update.c
@@ -18,9 +18,9 @@
 
 #include "mrgdef.h"
 
-int mrg_update(info,oldrec,newrec)
-register MRG_INFO *info;
-const byte *oldrec,*newrec;
+int mrg_update(
+register MRG_INFO *info,
+const byte *oldrec, const byte *newrec)
 {
   if (!info->current_table)
   {
diff --git a/myisam/ft_eval.c b/myisam/ft_eval.c
index a8e4d8e8881..845b56a7fed 100644
--- a/myisam/ft_eval.c
+++ b/myisam/ft_eval.c
@@ -19,6 +19,8 @@
 #include <getopt.h>
 
 static void print_error(int exit_code, const char *fmt,...);
+static void get_options(int argc, char *argv[]);
+static int create_record(char *pos, FILE *file);
 
 int main(int argc,char *argv[])
 {
@@ -123,7 +125,7 @@ void get_options(int argc,char *argv[])
       {
 	FILE *f; char s[HA_FT_MAXLEN]; int i=0,n=SWL_INIT;
 
-	if(!(stopwordlist=malloc(n*sizeof(char *))))
+	if(!(stopwordlist=(const char**) malloc(n*sizeof(char *))))
 	  print_error(1,"malloc(%d)",n*sizeof(char *));
 	if(!(f=fopen(optarg,"r")))
 	  print_error(1,"fopen(%s)",optarg);
diff --git a/myisam/ft_search.c b/myisam/ft_search.c
index 4ca1551e809..9a728a4c211 100644
--- a/myisam/ft_search.c
+++ b/myisam/ft_search.c
@@ -211,7 +211,7 @@ err:
 
 int ft_read_next(FT_DOCLIST *handler, char *record)
 {
-  MI_INFO *info=handler->info;
+  MI_INFO *info= (MI_INFO *) handler->info;
 
   if (++handler->curdoc >= handler->ndocs)
   {
diff --git a/myisam/ft_test1.c b/myisam/ft_test1.c
index dfe8e30383b..e986f686302 100644
--- a/myisam/ft_test1.c
+++ b/myisam/ft_test1.c
@@ -32,6 +32,8 @@ static char record[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
 
 void get_options(int argc,char *argv[]);
 static int run_test(const char *filename);
+static void get_options(int argc, char *argv[]);
+static void create_record(char *, int);
 
 int main(int argc,char *argv[])
 {
@@ -46,8 +48,6 @@ static MI_COLUMNDEF recinfo[3];
 static MI_KEYDEF keyinfo[2];
 static MI_KEYSEG keyseg[10];
 
-void create_record(char *, int);
-
 static int run_test(const char *filename)
 {
   MI_INFO *file;
diff --git a/myisam/ftdefs.h b/myisam/ftdefs.h
index ebf99e84d5a..d9b4ff6b44d 100644
--- a/myisam/ftdefs.h
+++ b/myisam/ftdefs.h
@@ -45,7 +45,7 @@
 #define LWS_TF						  (count)
 #define LWS_BINARY					(count>0)
 #define LWS_SQUARE				    (count*count)
-#define LWS_LOG				 (count?(log(count)+1):0)
+#define LWS_LOG				 (count?(log( (double) count)+1):0)
 /*--------------------------------------------------------------*/
 #define PRENORM_NONE				      (p->weight)
 #define PRENORM_MAX			  (p->weight/docstat.max)
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index 64bc5d7b8e5..fd327b96e6d 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -458,7 +458,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
       /* Check that there isn't a row with auto_increment = 0 in the table */
       mi_extra(info,HA_EXTRA_KEYREAD);
       bzero(info->lastkey,keyinfo->seg->length);
-      if (!mi_rkey(info, info->rec_buff, key, info->lastkey,
+      if (!mi_rkey(info, info->rec_buff, key, (const byte*) info->lastkey,
 		   keyinfo->seg->length, HA_READ_KEY_EXACT))
       {
 	/* Don't count this as a real warning, as myisamchk can't correct it */
@@ -2075,7 +2075,7 @@ static int sort_key_read(SORT_INFO *sort_info, void *key)
 			 "Found too many records; Can`t continue");
     DBUG_RETURN(1);
   }
-  (void) _mi_make_key(info,sort_info->key,key,sort_info->record,
+  (void) _mi_make_key(info,sort_info->key,(uchar*)key,sort_info->record,
                       sort_info->filepos);
   DBUG_RETURN(sort_write_record(sort_info));
 } /* sort_key_read */
diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c
index 59b9ceb266e..ae09bd4142e 100644
--- a/myisam/mi_test1.c
+++ b/myisam/mi_test1.c
@@ -18,8 +18,7 @@
 
 #include "myisam.h"
 #include <getopt.h>
-#include <m_ctype.h>
-
+#include <m_string.h>
 
 #define MAX_REC_LENGTH 1024
 
diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c
index 746042554c8..b66b02afdf9 100644
--- a/myisam/mi_test2.c
+++ b/myisam/mi_test2.c
@@ -59,11 +59,11 @@ static MI_KEYSEG glob_keyseg[MYISAM_KEYS][MAX_PARTS];
 
 		/* Test program */
 
-int main(int argc, char **argv)
+int main(int argc, char *argv[])
 {
   uint i;
   int j,n1,n2,n3,error,k;
-  uint write_count,update,dupp_keys,delete,start,length,blob_pos,
+  uint write_count,update,dupp_keys,opt_delete,start,length,blob_pos,
        reclength,ant,found_parts;
   my_off_t lastpos;
   ha_rows range_records,records;
@@ -180,7 +180,7 @@ int main(int argc, char **argv)
     recinfo[6].null_pos=0;
   }
 
-  write_count=update=dupp_keys=delete=0;
+  write_count=update=dupp_keys=opt_delete=0;
   blob_buffer=0;
 
   for (i=1000 ; i>0 ; i--) key1[i]=0;
@@ -280,14 +280,14 @@ int main(int argc, char **argv)
 	printf("can't find key1: \"%s\"\n",key);
 	goto err;
       }
-      if (delete == (uint) remove_count)		/* While testing */
+      if (opt_delete == (uint) remove_count)		/* While testing */
 	goto end;
       if (mi_delete(file,read_record))
       {
 	printf("error: %d; can't delete record: \"%s\"\n", my_errno,read_record);
 	goto err;
       }
-      delete++;
+      opt_delete++;
       key1[atoi(read_record+keyinfo[0].seg[0].start)]--;
       key3[atoi(read_record+keyinfo[2].seg[0].start)]=0;
     }
@@ -418,10 +418,10 @@ int main(int argc, char **argv)
   }
   while ((error=mi_rnext(file,read_record3,0)) == 0 && ant < write_count+10)
     ant++;
-  if (ant != write_count - delete || error != HA_ERR_END_OF_FILE)
+  if (ant != write_count - opt_delete || error != HA_ERR_END_OF_FILE)
   {
     printf("next: I found: %d records of %d (error: %d)\n",
-	   ant, write_count - delete, error);
+	   ant, write_count - opt_delete, error);
     goto end;
   }
   if (mi_rlast(file,read_record2,0) ||
@@ -435,7 +435,7 @@ int main(int argc, char **argv)
   ant=1;
   while (mi_rprev(file,read_record3,0) == 0 && ant < write_count+10)
     ant++;
-  if (ant != write_count - delete)
+  if (ant != write_count - opt_delete)
   {
     printf("prev: I found: %d records of %d\n",ant,write_count);
     goto end;
@@ -495,7 +495,7 @@ int main(int argc, char **argv)
     if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err;
     if (mi_rnext(file,read_record3,0)) goto err;
     if (mi_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=1;
     while (mi_rnext(file,read_record3,0) == 0 &&
 	   bcmp(read_record3+start,key,length) == 0) ant++;
@@ -513,7 +513,7 @@ int main(int argc, char **argv)
     if (mi_rprev(file,read_record3,0)) goto err;
     if (mi_rprev(file,read_record3,0)) goto err;
     if (mi_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=1;
     while (mi_rprev(file,read_record3,0) == 0 &&
 	   bcmp(read_record3+start,key,length) == 0) ant++;
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
     DBUG_PRINT("progpos",("first - delete - next -> last"));
     if (mi_rkey(file,read_record3,0,key,0,HA_READ_KEY_EXACT)) goto err;
     if (mi_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=1;
     if (mi_rnext(file,read_record,0))
       goto err;					/* Skall finnas poster */
@@ -547,7 +547,7 @@ int main(int argc, char **argv)
     DBUG_PRINT("progpos",("last - delete - prev -> first"));
     if (mi_rprev(file,read_record3,0)) goto err;
     if (mi_delete(file,read_record3)) goto err;
-    delete++;
+    opt_delete++;
     ant=0;
     while (mi_rprev(file,read_record3,0) == 0 &&
 	   bcmp(read_record3+start,key,length) == 0) ant++;
@@ -641,7 +641,7 @@ int main(int argc, char **argv)
   if (!silent)
     printf("- mi_info\n");
   mi_status(file,&info,HA_STATUS_VARIABLE | HA_STATUS_CONST);
-  if (info.records != write_count-delete || info.deleted > delete + update
+  if (info.records != write_count-opt_delete || info.deleted > opt_delete + update
       || info.keys != keys)
   {
     puts("Wrong info from mi_info");
@@ -678,10 +678,10 @@ int main(int argc, char **argv)
   while ((error=mi_rrnd(file,record,HA_OFFSET_ERROR)) != HA_ERR_END_OF_FILE &&
 	 ant < write_count + 10)
 	ant+= error ? 0 : 1;
-  if (ant != write_count-delete)
+  if (ant != write_count-opt_delete)
   {
     printf("rrnd with cache: I can only find: %d records of %d\n",
-	   ant,write_count-delete);
+	   ant,write_count-opt_delete);
     goto end;
   }
   if (mi_extra(file,HA_EXTRA_NO_CACHE))
@@ -695,10 +695,10 @@ int main(int argc, char **argv)
   while ((error=mi_scan(file,record)) != HA_ERR_END_OF_FILE &&
 	 ant < write_count + 10)
 	ant+= error ? 0 : 1;
-  if (ant != write_count-delete)
+  if (ant != write_count-opt_delete)
   {
     printf("scan with cache: I can only find: %d records of %d\n",
-	   ant,write_count-delete);
+	   ant,write_count-opt_delete);
     goto end;
   }
 
@@ -724,7 +724,7 @@ int main(int argc, char **argv)
     lastpos=info.recpos;
     if (error == 0)
     {
-      if (delete == (uint) remove_count)		/* While testing */
+      if (opt_delete == (uint) remove_count)		/* While testing */
 	goto end;
       if (mi_rsame(file,read_record,-1))
       {
@@ -751,19 +751,19 @@ int main(int argc, char **argv)
       if (mi_delete(file,read_record))
       {
 	printf("can't delete record: %6.6s,  delete_count: %d\n",
-	       read_record, delete);
+	       read_record, opt_delete);
 	goto err;
       }
-      delete++;
+      opt_delete++;
     }
     else
       found_parts++;
   }
   if (my_errno != HA_ERR_END_OF_FILE && my_errno != HA_ERR_RECORD_DELETED)
     printf("error: %d from mi_rrnd\n",my_errno);
-  if (write_count != delete)
+  if (write_count != opt_delete)
   {
-    printf("Deleted only %d of %d records (%d parts)\n",delete,write_count,
+    printf("Deleted only %d of %d records (%d parts)\n",opt_delete,write_count,
 	   found_parts);
     goto err;
   }
@@ -774,7 +774,7 @@ end:
   if (!silent)
   {
     printf("\nFollowing test have been made:\n");
-    printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,delete);
+    printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete);
     if (rec_pointer_size)
       printf("Record pointer size: %d\n",rec_pointer_size);
     if (key_cacheing)
diff --git a/myisam/mi_test_all.sh b/myisam/mi_test_all.sh
index dfa2e1d0fdd..ccc9c39c64e 100755
--- a/myisam/mi_test_all.sh
+++ b/myisam/mi_test_all.sh
@@ -1,5 +1,10 @@
+#!/bin/sh
+#
+# Execute some simple basic test on MyISAM libary to check if things
+# works at all.
+
 silent="-s"
-suffix=$MACH
+if test -f mi_test1$MACH ; then suffix=$MACH else suffix=""; fi
 mi_test1$suffix $silent
 myisamchk$suffix -se test1
 mi_test1$suffix $silent -N -S
diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c
index ca2c4f27a74..a6094cfd489 100644
--- a/myisam/myisamlog.c
+++ b/myisam/myisamlog.c
@@ -21,7 +21,7 @@
 #endif
 
 #include "myisamdef.h"
-#include "my_tree.h"
+#include <my_tree.h>
 #include <stdarg.h>
 #ifdef HAVE_GETRUSAGE
 #include <sys/resource.h>
@@ -251,12 +251,12 @@ static void get_options(register int *argc, register char ***argv)
 	/* Fall through */
       case 'I':
       case '?':
-	printf("%s  Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
+	printf("%s  Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
 	       MACHINE_TYPE);
 	puts("By Monty, for your professional use\n");
 	if (version)
 	  break;
-	puts("Write info about whats in a myisam log file.");
+	puts("Write info about whats in a MyISAM log file.");
 	printf("If no file name is given %s is used\n",log_filename);
 	puts("");
 	printf(usage,my_progname);
@@ -266,7 +266,7 @@ static void get_options(register int *argc, register char ***argv)
 	puts("         -o \"offset\"         -p # \"remove # components from path\"");
 	puts("         -r \"recover\"        -R \"file recordposition\"");
 	puts("         -u \"update\"         -v \"verbose\"   -w \"write file\"");
-	puts("         -D \"myisam compileled with DBUG\"   -P \"processes\"");
+	puts("         -D \"myisam compiled with DBUG\"   -P \"processes\"");
 	puts("\nOne can give a second and a third '-v' for more verbose.");
 	puts("Normaly one does a update (-u).");
 	puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted.");
@@ -376,10 +376,8 @@ static int examine_log(my_string file_name, char **table_names)
       }
 
       if (curr_file_info)
-      {
 	printf("\nWarning: %s is opened with same process and filenumber\nMaybe you should use the -P option ?\n",
 	       curr_file_info->show_name);
-      }
       if (my_b_read(&cache,(byte*) head,2))
 	goto err;
       file_info.name=0;
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index 0e4b6eafbde..557b4887b82 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -229,12 +229,12 @@ int main(int argc, char **argv)
 #endif
 }
 
-enum options {OPT_CHARSETS_DIR=256};
+enum options {OPT_CHARSETS_DIR_MP=256};
 
 static struct option long_options[] =
 {
   {"backup",	no_argument,	   0, 'b'},
-  {"character-sets-dir",required_argument,0,  OPT_CHARSETS_DIR},
+  {"character-sets-dir",required_argument,0,  OPT_CHARSETS_DIR_MP},
   {"debug",	optional_argument, 0, '#'},
   {"force",	no_argument,	   0, 'f'},
   {"join",	required_argument, 0, 'j'},
@@ -334,7 +334,7 @@ static void get_options(int *argc,char ***argv)
     case '#':
       DBUG_PUSH(optarg ? optarg : "d:t:o");
       break;
-    case OPT_CHARSETS_DIR:
+    case OPT_CHARSETS_DIR_MP:
       charsets_dir = optarg;
       break;
     case 'V': print_version(); exit(0);
@@ -1167,7 +1167,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
 {
   uint i,found,bits_packed,first,last;
   my_off_t bytes_packed;
-  HUFF_ELEMENT *a,*b,*new;
+  HUFF_ELEMENT *a,*b,*new_huff_el;
 
   first=last=0;
   if (huff_counts->tree_buff)
@@ -1247,23 +1247,23 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
     {
       if (huff_counts->counts[i])
       {
-	new=huff_tree->element_buffer+(found++);
-	new->count=huff_counts->counts[i];
-	new->a.leaf.null=0;
-	new->a.leaf.element_nr=i;
-	queue.root[found]=(byte*) new;
+	new_huff_el=huff_tree->element_buffer+(found++);
+	new_huff_el->count=huff_counts->counts[i];
+	new_huff_el->a.leaf.null=0;
+	new_huff_el->a.leaf.element_nr=i;
+	queue.root[found]=(byte*) new_huff_el;
       }
     }
     while (found < 2)
     {			/* Our huff_trees request at least 2 elements */
-      new=huff_tree->element_buffer+(found++);
-      new->count=0;
-      new->a.leaf.null=0;
+      new_huff_el=huff_tree->element_buffer+(found++);
+      new_huff_el->count=0;
+      new_huff_el->a.leaf.null=0;
       if (last)
-	new->a.leaf.element_nr=huff_tree->min_chr=last-1;
+	new_huff_el->a.leaf.element_nr=huff_tree->min_chr=last-1;
       else
-	new->a.leaf.element_nr=huff_tree->max_chr=last+1;
-      queue.root[found]=(byte*) new;
+	new_huff_el->a.leaf.element_nr=huff_tree->max_chr=last+1;
+      queue.root[found]=(byte*) new_huff_el;
     }
   }
   queue.elements=found;
@@ -1275,13 +1275,13 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
   {
     a=(HUFF_ELEMENT*) queue_remove(&queue,0);
     b=(HUFF_ELEMENT*) queue.root[1];
-    new=huff_tree->element_buffer+found+i;
-    new->count=a->count+b->count;
-    bits_packed+=(uint) (new->count & 7);
-    bytes_packed+=new->count/8;
-    new->a.nod.left=a;			/* lesser in left  */
-    new->a.nod.right=b;
-    queue.root[1]=(byte*) new;
+    new_huff_el=huff_tree->element_buffer+found+i;
+    new_huff_el->count=a->count+b->count;
+    bits_packed+=(uint) (new_huff_el->count & 7);
+    bytes_packed+=new_huff_el->count/8;
+    new_huff_el->a.nod.left=a;			/* lesser in left  */
+    new_huff_el->a.nod.right=b;
+    queue.root[1]=(byte*) new_huff_el;
     queue_replaced(&queue);
   }
   huff_tree->root=(HUFF_ELEMENT*) queue.root[1];
@@ -1303,14 +1303,14 @@ static int compare_tree(register const uchar *s, register const uchar *t)
 static int save_counts_in_queue(byte *key, element_count count,
 				HUFF_TREE *tree)
 {
-  HUFF_ELEMENT *new;
+  HUFF_ELEMENT *new_huff_el;
 
-  new=tree->element_buffer+(tree->elements++);
-  new->count=count;
-  new->a.leaf.null=0;
-  new->a.leaf.element_nr= (uint) (key- tree->counts->tree_buff) /
+  new_huff_el=tree->element_buffer+(tree->elements++);
+  new_huff_el->count=count;
+  new_huff_el->a.leaf.null=0;
+  new_huff_el->a.leaf.element_nr= (uint) (key- tree->counts->tree_buff) /
     tree->counts->field_length;
-  queue.root[tree->elements]=(byte*) new;
+  queue.root[tree->elements]=(byte*) new_huff_el;
   return 0;
 }
 
@@ -1352,14 +1352,14 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts,
     _downheap(&queue,i);
   for (i=0 ; i < found-1 ; i++)
   {
-    HUFF_ELEMENT *a,*b,*new;
+    HUFF_ELEMENT *a,*b,*new_huff_el;
     a=(HUFF_ELEMENT*) queue_remove(&queue,0);
     b=(HUFF_ELEMENT*) queue.root[1];
-    new=element_buffer+i;
-    new->count=a->count+b->count;
-    bits_packed+=(uint) (new->count & 7);
-    bytes_packed+=new->count/8;
-    queue.root[1]=(byte*) new;
+    new_huff_el=element_buffer+i;
+    new_huff_el->count=a->count+b->count;
+    bits_packed+=(uint) (new_huff_el->count & 7);
+    bytes_packed+=new_huff_el->count/8;
+    queue.root[1]=(byte*) new_huff_el;
     queue_replaced(&queue);
   }
   DBUG_RETURN(bytes_packed+(bits_packed+7)/8);
diff --git a/myisam/sort.c b/myisam/sort.c
index e6c7d61e39a..39874d05640 100644
--- a/myisam/sort.c
+++ b/myisam/sort.c
@@ -28,6 +28,9 @@
 #include <queues.h>
 
 	/* static variabels */
+#undef MIN_SORT_MEMORY
+#undef MYF_RW
+#undef DISK_BUFFER_SIZE
 
 #define MERGEBUFF 15
 #define MERGEBUFF2 31
@@ -36,10 +39,10 @@
 #define DISK_BUFFER_SIZE (IO_SIZE*16)
 
 typedef struct st_buffpek {
-  my_off_t file_pos;			/* position to buffer */
-  ha_rows count;			/* keys in buffer */
-  uchar *base,*key;			/* Pekare inom sort_key - indexdel */
-  uint mem_count;			/* keys left in memory */
+  my_off_t file_pos;			/* Where we are in the sort file */
+  ha_rows count;			/* Number of rows in table */
+  uchar *base,*key;			/* Key pointers */
+  uint mem_count;			/* numbers of keys in memory */
   uint max_keys;			/* Max keys in buffert */
 } BUFFPEK;
 
@@ -361,7 +364,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
 						sort_length));
     if (error == -1)
       goto err; /* purecov: inspected */
-    queue_insert(&queue,(void*) buffpek);
+    queue_insert(&queue,(char*) buffpek);
   }
 
   while (queue.elements > 1)
diff --git a/myisammrg/myrg_delete.c b/myisammrg/myrg_delete.c
index a470b4876cf..9ac32655172 100644
--- a/myisammrg/myrg_delete.c
+++ b/myisammrg/myrg_delete.c
@@ -18,9 +18,9 @@
 
 #include "mymrgdef.h"
 
-int myrg_delete(info,record)
-MYRG_INFO *info;
-const byte *record;
+int myrg_delete(
+MYRG_INFO *info,
+const byte *record)
 {
   if (!info->current_table)
   {
diff --git a/myisammrg/myrg_locking.c b/myisammrg/myrg_locking.c
index fc03df9bf63..c89acca3918 100644
--- a/myisammrg/myrg_locking.c
+++ b/myisammrg/myrg_locking.c
@@ -20,9 +20,9 @@
 
 #include "mymrgdef.h"
 
-int myrg_lock_database(info,lock_type)
-MYRG_INFO *info;
-int lock_type;
+int myrg_lock_database(
+MYRG_INFO *info,
+int lock_type)
 {
   int error,new_error;
   MYRG_TABLE *file;
diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c
index f73339f63c8..f70d33feb2b 100644
--- a/myisammrg/myrg_open.c
+++ b/myisammrg/myrg_open.c
@@ -30,10 +30,10 @@
 */
 
 
-MYRG_INFO *myrg_open(name,mode,handle_locking)
-const char *name;
-int mode;
-int handle_locking;
+MYRG_INFO *myrg_open(
+const char *name,
+int mode,
+int handle_locking)
 {
   int save_errno,i,errpos;
   uint files,dir_length,length;
diff --git a/myisammrg/myrg_panic.c b/myisammrg/myrg_panic.c
index 8b6169c896b..99a1f6828d1 100644
--- a/myisammrg/myrg_panic.c
+++ b/myisammrg/myrg_panic.c
@@ -24,8 +24,7 @@
 	   done for all single user files to get changes in database */
 
 
-int myrg_panic(flag)
-enum ha_panic_function flag;
+int myrg_panic(enum ha_panic_function flag)
 {
   int error=0;
   LIST *list_element,*next_open;
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index e55ed4ca17b..43ea6fd19ad 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -4,7 +4,7 @@ connection con1;
 set SQL_LOG_BIN=0;
 drop table if exists t1;
 create table t1(n int);
---replace_result "errno = 2" "errno = X" "errno = 22" "errno = X"
+--replace_result "errno = 2" "errno = X" "errno = 22" "errno = X" "errno = 23" "errno = X"
 backup table t1 to '../bogus';
 backup table t1 to '../tmp';
 drop table t1;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 476d8dcdf0d..0f07d577c0c 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -9,7 +9,7 @@ optimize table t1;
 check table t1,t2;
 repair table t1,t2;
 check table t2,t1;
-lock tables t1 read;
+lock tables t1 write;
 check table t2,t1;
 show columns from t1;
 show full columns from t1;
diff --git a/mysys/charset.c b/mysys/charset.c
index c17c6113b57..f778afb4144 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -393,16 +393,16 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags)
 
 my_bool set_default_charset(uint cs, myf flags)
 {
-  CHARSET_INFO *new;
+  CHARSET_INFO *new_charset;
   DBUG_ENTER("set_default_charset");
   DBUG_PRINT("enter",("character set: %d",(int) cs));
-  new = get_charset(cs, flags);
-  if (!new)
+  new_charset = get_charset(cs, flags);
+  if (!new_charset)
   {
     DBUG_PRINT("error",("Couldn't set default character set"));
     DBUG_RETURN(TRUE);   /* error */
   }
-  default_charset_info = new;
+  default_charset_info = new_charset;
   DBUG_RETURN(FALSE);
 }
 
@@ -424,17 +424,17 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
 
 my_bool set_default_charset_by_name(const char *cs_name, myf flags)
 {
-  CHARSET_INFO *new;
+  CHARSET_INFO *new_charset;
   DBUG_ENTER("set_default_charset_by_name");
   DBUG_PRINT("enter",("character set: %s", cs_name));
-  new = get_charset_by_name(cs_name, flags);
-  if (!new)
+  new_charset = get_charset_by_name(cs_name, flags);
+  if (!new_charset)
   {
     DBUG_PRINT("error",("Couldn't set default character set"));
     DBUG_RETURN(TRUE);   /* error */
   }
 
-  default_charset_info = new;
+  default_charset_info = new_charset;
   DBUG_RETURN(FALSE);
 }
 
diff --git a/mysys/default.c b/mysys/default.c
index 126c0270a17..e2e80f36a68 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -146,7 +146,7 @@ void load_defaults(const char *conf_file, const char **groups,
 			    &group))
       goto err;
 #endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined(OS2)
     if (getenv("ETC") &&
         search_default_file(&args, &alloc, getenv("ETC"), conf_file, 
                             default_ext, &group))
@@ -363,7 +363,7 @@ void print_defaults(const char *conf_file, const char **groups)
     GetWindowsDirectory(name,sizeof(name));
     printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
 #endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined(OS2)
     if (getenv("ETC"))
       printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
 #endif
diff --git a/mysys/getopt.c b/mysys/getopt.c
index a2a3b5bbec9..774cf3b82f4 100644
--- a/mysys/getopt.c
+++ b/mysys/getopt.c
@@ -38,7 +38,7 @@ Cambridge, MA 02139, USA.  */
 #include <config.h>
 #endif
 
-#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS)
+#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
 /* This is a separate conditional since some stdc systems
    reject `defined (const)'.  */
 #ifndef const
@@ -176,7 +176,9 @@ static char *posixly_correct;
 /* Avoid depending on library functions or files
    whose names are inconsistent.  */
 
+#ifndef OS2
 char *getenv (const char *);
+#endif
 
 static char *
 my_index (const char *str, int chr)
diff --git a/mysys/getopt1.c b/mysys/getopt1.c
index 6068a036e7b..bff76d6e5b2 100644
--- a/mysys/getopt1.c
+++ b/mysys/getopt1.c
@@ -27,7 +27,7 @@ Cambridge, MA 02139, USA.  */
 #include <global.h>
 #include "getopt.h"
 
-#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS)
+#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
 /* This is a separate conditional since some stdc systems
    reject `defined (const)'.  */
 #ifndef const
diff --git a/mysys/list.c b/mysys/list.c
index 0a6d900d6b9..c9c863d4cc2 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -72,11 +72,11 @@ void list_free(LIST *root, pbool free_data)
 
 LIST *list_cons(void *data, LIST *list)
 {
-  LIST *new=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
-  if (!new)
+  LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
+  if (!new_charset)
     return 0;
-  new->data=data;
-  return list_add(list,new);
+  new_charset->data=data;
+  return list_add(list,new_charset);
 }
 
 
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c
index f4b9e011215..399082a238b 100644
--- a/mysys/mf_dirname.c
+++ b/mysys/mf_dirname.c
@@ -24,7 +24,7 @@ uint dirname_length(const char *name)
 {
   register my_string pos,gpos;
 #ifdef FN_DEVCHAR
-  if ((pos=strrchr(name,FN_DEVCHAR)) == 0)
+  if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
 #endif
     pos=(char*) name-1;
 
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index c4425806e01..7dac46cf0d0 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -65,7 +65,7 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
     pack_dirname(dev,dev);			/* Put in ./.. and ~/.. */
   if (flag & 4)
     (void) unpack_dirname(dev,dev);		/* Replace ~/.. with dir */
-  if ((pos=strchr(name,FN_EXTCHAR)) != NullS)
+  if ((pos=(char*)strchr(name,FN_EXTCHAR)) != NullS)
   {
     if ((flag & 2) == 0)			/* Skall vi byta extension ? */
     {
diff --git a/mysys/mf_path.c b/mysys/mf_path.c
index 3158c45470c..9a88b938e2c 100644
--- a/mysys/mf_path.c
+++ b/mysys/mf_path.c
@@ -74,7 +74,7 @@ my_string my_path(my_string to, const char *progname,
 	/* test if file without filename is found in path */
 	/* Returns to if found and to has dirpart if found, else NullS */
 
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
 #define F_OK 0
 #define PATH_SEP ';'
 #define PROGRAM_EXTENSION ".exe"
diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c
index 7074abac96e..032a1a28a72 100644
--- a/mysys/mf_qsort.c
+++ b/mysys/mf_qsort.c
@@ -52,7 +52,7 @@
 #define MAX_THRESH 8
 
 /* Stack node declarations used to store unfulfilled partition obligations. */
-typedef struct
+typedef struct _qsort_stack_node
   {
     char *lo;
     char *hi;
@@ -109,7 +109,7 @@ qsort_t qsort(void *base_ptr, size_t total_elems, size_t size, qsort_cmp cmp)
 
   if (total_elems > MAX_THRESH)
   {
-    char       *lo = base_ptr;
+    char       *lo = (char*) base_ptr;
     char       *hi = &lo[size * (total_elems - 1)];
     stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */
     stack_node *top = stack + 1;
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index b2c0e89b9e4..2cdd720edbd 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -25,7 +25,7 @@
 #endif
 
 #ifdef HAVE_TEMPNAM
-#ifndef MSDOS
+#if !defined( MSDOS) && !defined(OS2)
 extern char **environ;
 #endif
 #endif
@@ -122,12 +122,19 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
       to[1]= 0;
       dir=to;
     }
-    old_env=environ;
+#ifdef OS2
+    // changing environ variable doesn't work with VACPP
+    char  buffer[256];
+    sprintf( buffer, "TMP=%s", dir);
+    putenv( buffer);
+#else
+    old_env= (char**) environ;
     if (dir)
     {				/* Don't use TMPDIR if dir is given */
-      environ=temp_env;
+      environ=(const char**) temp_env;
       temp_env[0]=0;
     }
+#endif
     if ((res=tempnam((char*) dir, (char*) prefix)))
     {    
       strmake(to,res,FN_REFLEN-1);
@@ -142,7 +149,9 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
     {
       DBUG_PRINT("error",("Got error: %d from tempnam",errno));
     }
-    environ=old_env;
+#ifndef OS2
+    environ=(const char**) old_env;
+#endif
   }
 #else
   {
diff --git a/mysys/my_clock.c b/mysys/my_clock.c
index d13d69a7b88..e7d1758fa2e 100644
--- a/mysys/my_clock.c
+++ b/mysys/my_clock.c
@@ -18,14 +18,14 @@
 #define USES_TYPES
 #include "global.h"
 
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
+#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(OS2)
 #include "mysys_priv.h"
 #include <sys/times.h>
 #endif
 
 long my_clock(void)
 {
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(OS2)
   struct tms tmsbuf;
   VOID(times(&tmsbuf));
   return (tmsbuf.tms_utime + tmsbuf.tms_stime);
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index be131873118..9b02d84d063 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -81,7 +81,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
     if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
 	DBUG_RETURN(0);			/* File copyed but not stat */
     VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
     VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */
 #endif
 #if !defined(VMS) && !defined(__ZTC__)
diff --git a/mysys/my_create.c b/mysys/my_create.c
index ee5d9aa41f3..5a10b0fd8b5 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -20,7 +20,7 @@
 #include <my_dir.h>
 #include "mysys_err.h"
 #include <errno.h>
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
 #include <share.h>
 #endif
 
@@ -48,7 +48,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
 #elif defined(VMS)
   fd = open((my_string) FileName, access_flags | O_CREAT, 0,
 	    "ctx=stm","ctx=bin");
-#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
   if (access_flags & O_SHARE)
     fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
 	       SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index b49737b2a61..6bdea813fe4 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -28,6 +28,9 @@
 #include <dos.h>
 #include <direct.h>
 #endif
+#if defined(OS2)
+#include <direct.h>
+#endif
 
 #ifdef __EMX__
 // chdir2 support also drive change
@@ -93,16 +96,16 @@ int my_setwd(const char *dir, myf MyFlags)
   int res;
   size_s length;
   my_string start,pos;
-#if defined(VMS) || defined(MSDOS)
+#if defined(VMS) || defined(MSDOS) || defined(OS2)
   char buff[FN_REFLEN];
 #endif
   DBUG_ENTER("my_setwd");
   DBUG_PRINT("my",("dir: '%s'  MyFlags %d", dir, MyFlags));
 
   start=(my_string) dir;
-#if defined(MSDOS)		/* MSDOS chdir can't change drive */
+#if defined(MSDOS) || defined(OS2) /* OS2/MSDOS chdir can't change drive */
 #if !defined(_DDL) && !defined(WIN32)
-  if ((pos=strchr(dir,FN_DEVCHAR)) != 0)
+  if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0)
   {
     uint drive,drives;
 
@@ -110,8 +113,13 @@ int my_setwd(const char *dir, myf MyFlags)
     drive=(uint) (toupper(dir[0])-'A'+1); drives= (uint) -1;
     if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32)
     {
+#ifdef OS2
+      _chdrive(drive);
+      drives = _getdrive();
+#else
       _dos_setdrive(drive,&drives);
       _dos_getdrive(&drives);
+#endif
     }
     if (drive != drives)
     {
diff --git a/mysys/my_init.c b/mysys/my_init.c
index b5005b82478..c3b9cecf86e 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -74,7 +74,7 @@ void my_init(void)
   pthread_init();			/* Must be called before DBUG_ENTER */
 #endif
   my_thread_global_init();
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
   sigfillset(&my_signals);		/* signals blocked by mf_brkhant */
 #endif
 #endif /* THREAD */
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 0f4a5261fba..f9774d8a4aa 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -27,7 +27,9 @@
 # include <dirent.h>
 # define NAMLEN(dirent) strlen((dirent)->d_name)
 #else
+#ifndef OS2
 # define dirent direct
+#endif
 # define NAMLEN(dirent) (dirent)->d_namlen
 # if defined(HAVE_SYS_NDIR_H)
 #  include <sys/ndir.h>
@@ -50,6 +52,11 @@
 #include <iodef.h>
 #include <descrip.h>
 #endif
+
+#ifdef OS2
+#include "my_os2dirsrch.h"
+#endif
+
 #if defined(THREAD) && defined(HAVE_READDIR_R)
 #define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C)
 #else
@@ -337,9 +344,7 @@ my_string directory_file_name (my_string dst, const char *src)
 *****************************************************************************
 */
 
-MY_DIR	*my_dir(path, MyFlags)
-const char	*path;
-myf	MyFlags;
+MY_DIR	*my_dir(const char *path, myf MyFlags)
 {
   struct fileinfo *fnames;
   char	       *buffer, *obuffer, *tempptr;
@@ -475,9 +480,7 @@ error:
 ** At MSDOS you always get stat of files, but time is in packed MSDOS-format
 ******************************************************************************/
 
-MY_DIR	*my_dir(path, MyFlags)
-const char	*path;
-myf	MyFlags;
+MY_DIR	*my_dir(const char* path, myf MyFlags)
 {
   struct fileinfo *fnames;
   char	       *buffer, *obuffer, *tempptr;
diff --git a/mysys/my_lock.c b/mysys/my_lock.c
index a3508018837..c002f447f59 100644
--- a/mysys/my_lock.c
+++ b/mysys/my_lock.c
@@ -38,12 +38,6 @@
 int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
 	    myf MyFlags)
 {
-#ifdef __EMX__
-  FILELOCK LockArea = {0,0}, UnlockArea = {0,0};
-  APIRET rc = 0;
-  fpos_t oldpos;
-  int lockflags = 0;
-#endif
 #ifdef HAVE_FCNTL
   int value;
   ALARM_VARIABLES;
@@ -56,54 +50,12 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
 #else
   if (my_disable_locking)
     DBUG_RETURN(0);
-#if defined(__EMX__)
-  if (locktype == F_UNLCK) {
-    UnlockArea.lOffset = start;
-    if (length)
-      UnlockArea.lRange = length;
-    else
-      UnlockArea.lRange = 0x7FFFFFFFL;
-  } else
-  if (locktype == F_RDLCK || locktype == F_WRLCK) {
-    if (locktype == F_RDLCK) lockflags |= 1;
-    LockArea.lOffset = start;
-    if (length)
-      LockArea.lRange = length;
-    else
-      LockArea.lRange = 0x7FFFFFFFL;
-  } else {
-    my_errno = EINVAL;
-    DBUG_RETURN(-1);
-  }
-  if (!LockArea.lRange && !UnlockArea.lRange)
+
+#if defined(__EMX__) || defined(OS2)
+
+   if (!_lock64( fd, locktype, start, length, MyFlags))
     DBUG_RETURN(0);
-  if (MyFlags & MY_DONT_WAIT) {
-    if (!(rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,0,lockflags)))
-      DBUG_RETURN(0);		/* Lock was OK */
-    if (rc == 175 && locktype == F_RDLCK) {
-      lockflags &= ~1;
-      rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,0,lockflags);
-    }
-    if (rc == 33) {  /* Lock Violation */
-      DBUG_PRINT("info",("Was locked, trying with timeout"));
-      rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,MY_HOW_OFTEN_TO_ALARM * 1000,lockflags);
-    }
-    if (!rc) DBUG_RETURN(0);
-    if (rc == 33) errno = EAGAIN;
-    else {
-      errno = EINVAL;
-      printf("Error: DosSetFileLocks() == %d\n",rc);
-    }
-  } else {
-    while (rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,
-	MY_HOW_OFTEN_TO_ALARM * 1000,lockflags) && (rc == 33 || rc == 175)) {
-      printf(".");
-      if (rc == 175) lockflags &= ~1;
-    }
-    if (!rc) DBUG_RETURN(0);
-    errno = EINVAL;
-    printf("Error: DosSetFileLocks() == %d\n",rc);
-  }
+
 #elif defined(HAVE_LOCKING)
   /* Windows */
   {
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index 6cae6fe3a4d..c2df22ec7ec 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -33,7 +33,7 @@ gptr my_malloc(unsigned int Size, myf MyFlags)
 
   if (!Size)
     Size=1;					/* Safety */
-  if ((point = malloc(Size)) == NULL)
+  if ((point = (char*)malloc(Size)) == NULL)
   {
     my_errno=errno;
     if (MyFlags & MY_FAE)
diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c
index 773cd26cb03..3685312132c 100644
--- a/mysys/my_mkdir.c
+++ b/mysys/my_mkdir.c
@@ -28,8 +28,8 @@ int my_mkdir(const char *dir, int Flags, myf MyFlags)
   DBUG_ENTER("my_dir");
   DBUG_PRINT("enter",("dir: %s",dir));
 
-#ifdef __WIN__
-  if (mkdir(dir))
+#if  defined(__WIN__) || defined(OS2)
+  if (mkdir((char*) dir))
 #else
   if (mkdir((char*) dir, Flags & my_umask_dir))
 #endif
diff --git a/mysys/my_open.c b/mysys/my_open.c
index fcf1be575c8..2ed1af1eca1 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -20,7 +20,7 @@
 #include "mysys_err.h"
 #include <my_dir.h>
 #include <errno.h>
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
 #include <share.h>
 #endif
 
@@ -35,7 +35,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
   DBUG_ENTER("my_open");
   DBUG_PRINT("my",("Name: '%s'  Flags: %d  MyFlags: %d",
 		   FileName, Flags, MyFlags));
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
   if (Flags & O_SHARE)
     fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
 	       MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_os2cond.c b/mysys/my_os2cond.c
new file mode 100644
index 00000000000..c436ad9a0e9
--- /dev/null
+++ b/mysys/my_os2cond.c
@@ -0,0 +1,188 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+/*****************************************************************************
+** The following is a simple implementation of posix conditions
+*****************************************************************************/
+
+#undef SAFE_MUTEX			/* Avoid safe_mutex redefinitions */
+#include "mysys_priv.h"
+#if defined(THREAD) && defined(OS2)
+#include <m_string.h>
+//#undef getpid
+#include <process.h>
+#include <sys/timeb.h>
+
+int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
+{
+   APIRET          rc = 0;
+   HEV             event;
+   cond->waiting=0;
+   /* Warp3 FP29 or Warp4 FP4 or better required */
+   rc = DosCreateEventSem( NULL, &cond->semaphore, 0x0800, 0);
+   if (rc)
+      return ENOMEM;
+
+  return 0;
+}
+
+int pthread_cond_destroy(pthread_cond_t *cond)
+{
+   APIRET   rc;
+
+   do {
+      rc = DosCloseEventSem(cond->semaphore);
+      if (rc == 301) DosPostEventSem(cond->semaphore);
+   } while (rc == 301);
+   if (rc)
+      return EINVAL;
+
+	return 0;
+}
+
+
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+   APIRET   rc;
+   int      rval;
+
+   rval = 0;
+   cond->waiting++;
+
+   if (mutex) pthread_mutex_unlock(mutex);
+
+   rc = DosWaitEventSem(cond->semaphore,SEM_INDEFINITE_WAIT);
+   if (rc != 0)
+      rval = EINVAL;
+
+   if (mutex) pthread_mutex_lock(mutex);
+
+   cond->waiting--;
+
+   return rval;
+}
+
+int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+                           struct timespec *abstime)
+{
+  struct timeb curtime;
+  int result;
+  long timeout;
+   APIRET   rc;
+   int      rval;
+
+   _ftime(&curtime);
+   timeout= ((long) (abstime->ts_sec - curtime.time)*1000L +
+		    (long)((abstime->ts_nsec/1000) - curtime.millitm)/1000L);
+   if (timeout < 0)				/* Some safety */
+      timeout = 0L;
+
+   rval = 0;
+   cond->waiting++;
+
+   if (mutex) pthread_mutex_unlock(mutex);
+
+   rc = DosWaitEventSem(cond->semaphore, timeout);
+   if (rc != 0)
+      rval = ETIME;
+
+   if (mutex) pthread_mutex_lock(mutex);
+
+   cond->waiting--;
+
+   return rval;
+}
+
+
+int pthread_cond_signal(pthread_cond_t *cond)
+{
+   APIRET   rc;
+
+   /* Bring the next thread off the condition queue: */
+   rc = DosPostEventSem(cond->semaphore);
+   return 0;
+}
+
+
+int pthread_cond_broadcast(pthread_cond_t *cond)
+{
+   int      i;
+   APIRET   rc;
+
+                /*
+                 * Enter a loop to bring all threads off the
+                 * condition queue:
+                 */
+   i = cond->waiting;
+   while (i--) rc = DosPostEventSem(cond->semaphore);
+
+   return 0 ;
+}
+
+
+int pthread_attr_init(pthread_attr_t *connect_att)
+{
+  connect_att->dwStackSize	= 0;
+  connect_att->dwCreatingFlag	= 0;
+  connect_att->priority		= 0;
+  return 0;
+}
+
+int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack)
+{
+  connect_att->dwStackSize=stack;
+  return 0;
+}
+
+int pthread_attr_setprio(pthread_attr_t *connect_att,int priority)
+{
+  connect_att->priority=priority;
+  return 0;
+}
+
+int pthread_attr_destroy(pthread_attr_t *connect_att)
+{
+  bzero((gptr) connect_att,sizeof(*connect_att));
+  return 0;
+}
+
+/****************************************************************************
+** Fix localtime_r() to be a bit safer
+****************************************************************************/
+
+struct tm *localtime_r(const time_t *timep,struct tm *tmp)
+{
+  if (*timep == (time_t) -1)			/* This will crash win32 */
+  {
+    bzero(tmp,sizeof(*tmp));
+  }
+  else
+  {
+    struct tm *res=localtime(timep);
+    if (!res)                                   /* Wrong date */
+    {
+      bzero(tmp,sizeof(*tmp));                  /* Keep things safe */
+      return 0;
+    }
+    *tmp= *res;
+  }
+  return tmp;
+}
+#endif /* __WIN__ */
diff --git a/mysys/my_os2dirsrch.c b/mysys/my_os2dirsrch.c
new file mode 100644
index 00000000000..36f56d3ed2e
--- /dev/null
+++ b/mysys/my_os2dirsrch.c
@@ -0,0 +1,182 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+/* Win32 directory search emulation */
+
+#if defined(OS2)
+
+//#define _DEBUG
+
+long  _findfirst( char* path, struct _finddata_t* dos_file)
+{
+   HDIR           hdir = HDIR_CREATE;
+   APIRET         rc;
+   FILEFINDBUF3   buf3;
+   ULONG          entries = 1;
+
+#ifdef _DEBUG
+   printf( "_findfirst path %s\n", path);
+#endif
+
+   memset( &buf3, 0, sizeof( buf3));
+   rc = DosFindFirst(
+               path,  /*  Address of the ASCIIZ path name of the file or subdirectory to be found. */
+               &hdir,        /*  Address of the handle associated with this DosFindFirst request. */
+               FILE_NORMAL | FILE_DIRECTORY,  /*  Attribute value that determines the file objects to be searched for. */
+               &buf3,     /*  Result buffer. */
+               sizeof( buf3),        /*  The length, in bytes, of pfindbuf. */
+               &entries,  /*  Pointer to the number of entries: */
+               FIL_STANDARD);  /*  The level of file information required. */
+
+#ifdef _DEBUG
+   printf( "_findfirst rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName);
+#endif
+
+   if (rc /* && entries == 0 */)
+      return -1;
+
+   if (dos_file) {
+      memset( dos_file, 0, sizeof( struct _finddata_t));
+      strcpy( dos_file->name, buf3.achName);
+      dos_file->size = buf3.cbFile;
+      dos_file->attrib = buf3.attrFile;
+   }
+   return (ULONG) hdir;
+}
+
+
+long  _findnext( long hdir, struct _finddata_t* dos_file)
+{
+   APIRET         rc;
+   FILEFINDBUF3   buf3;
+   ULONG          entries = 1;
+
+   memset( &buf3, 0, sizeof( buf3));
+   rc = DosFindNext(
+               hdir,
+               &buf3,     /*  Result buffer. */
+               sizeof( buf3),        /*  The length, in bytes, of pfindbuf. */
+               &entries);  /*  Pointer to the number of entries: */
+
+#ifdef _DEBUG
+   printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName);
+#endif
+
+   if (rc /* && entries == 0 */)
+      return -1;
+
+   if (dos_file) {
+      memset( dos_file, 0, sizeof( struct _finddata_t));
+      strcpy( dos_file->name, buf3.achName);
+      dos_file->size = buf3.cbFile;
+      dos_file->attrib = buf3.attrFile;
+   }
+   return 0;
+}
+
+void  _findclose( long hdir)
+{
+   APIRET         rc;
+
+   rc = DosFindClose( hdir);
+#ifdef _DEBUG
+   printf( "_findclose rc=%d hdir=%d\n", rc, hdir);
+#endif
+}
+
+DIR* opendir( char* path)
+{
+   DIR* dir = (DIR*) calloc( 1, sizeof( DIR));
+   char buffer[260];
+   APIRET         rc;
+   ULONG          entries = 1;
+
+   strcpy( buffer, path);
+   strcat( buffer, "*.*");
+
+#ifdef _DEBUG
+   printf( "_findfirst path %s\n", buffer);
+#endif
+
+   dir->hdir = HDIR_CREATE;
+   memset( &dir->buf3, 0, sizeof( dir->buf3));
+   rc = DosFindFirst(
+               buffer,  /*  Address of the ASCIIZ path name of the file or subdirectory to be found. */
+               &dir->hdir,        /*  Address of the handle associated with this DosFindFirst request. */
+               FILE_NORMAL | FILE_DIRECTORY,  /*  Attribute value that determines the file objects to be searched for. */
+               &dir->buf3,     /*  Result buffer. */
+               sizeof( dir->buf3),        /*  The length, in bytes, of pfindbuf. */
+               &entries,  /*  Pointer to the number of entries: */
+               FIL_STANDARD);  /*  The level of file information required. */
+
+#ifdef _DEBUG
+   printf( "opendir rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
+#endif
+
+   if (rc /* && entries == 0 */)
+      return NULL;
+
+   return dir;
+}
+
+struct dirent* readdir( DIR* dir)
+{
+   APIRET         rc;
+   //FILEFINDBUF3   buf3;
+   ULONG          entries = 1;
+
+   if (!dir->buf3.achName[0]) // file not found on previous query
+      return NULL;
+
+   // copy last file name
+   strcpy( dir->ent.d_name, dir->buf3.achName);
+
+   // query next file
+   memset( &dir->buf3, 0, sizeof( dir->buf3));
+   rc = DosFindNext(
+               dir->hdir,
+               &dir->buf3,     /*  Result buffer. */
+               sizeof( dir->buf3),        /*  The length, in bytes, of pfindbuf. */
+               &entries);  /*  Pointer to the number of entries: */
+
+#ifdef _DEBUG
+   printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
+#endif
+
+   if (rc /* && entries == 0 */)
+      strcpy( dir->buf3.achName, ""); // reset name for next query
+
+   return &dir->ent;
+}
+
+int closedir (DIR *dir)
+{
+   APIRET         rc;
+
+   rc = DosFindClose( dir->hdir);
+#ifdef _DEBUG
+   printf( "_findclose rc=%d hdir=%d\n", rc, dir->hdir);
+#endif
+   free(dir);
+   return 0;
+}
+
+
+#endif // OS2
diff --git a/mysys/my_os2dirsrch.h b/mysys/my_os2dirsrch.h
new file mode 100644
index 00000000000..2afe0f609f1
--- /dev/null
+++ b/mysys/my_os2dirsrch.h
@@ -0,0 +1,77 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+/* Win32 directory search emulation */
+
+#ifndef __MY_OS2DIRSRCH2_H__
+#define __MY_OS2DIRSRCH2_H__
+
+#ifdef __cplusplus_00
+extern "C" {
+#endif
+
+struct _finddata_t
+{
+	unsigned	attrib;
+	//unsigned long	time_create;	/* -1 for FAT file systems */
+	//unsigned long	time_access;	/* -1 for FAT file systems */
+	//unsigned long	time_write;
+	unsigned long	size;
+	char		name[260];
+	//uint16		wr_date;
+	//uint16		wr_time;
+};
+
+struct dirent
+{
+	//unsigned	attrib;
+	//unsigned long	time_create;	/* -1 for FAT file systems */
+	//unsigned long	time_access;	/* -1 for FAT file systems */
+	//unsigned long	time_write;
+	//unsigned long	size;
+	char		d_name[260];
+	//uint16		wr_date;
+	//uint16		wr_time;
+};
+
+struct DIR
+{
+   HDIR  hdir;
+   FILEFINDBUF3   buf3;
+   struct dirent  ent;
+};
+
+DIR *opendir ( char *);
+struct dirent *readdir (DIR *);
+int closedir (DIR *);
+
+//#define _A_NORMAL	FILE_NORMAL
+//#define _A_SUBDIR	FILE_DIRECTORY
+//#define _A_RDONLY	FILE_READONLY
+
+//long  _findfirst( char*, struct _finddata_t*);
+//long  _findnext( long, struct _finddata_t*);
+//void  _findclose( long);
+
+#ifdef __cplusplus_00
+}
+#endif
+
+#endif // __MY_OS2DIRSRCH2_H__
diff --git a/mysys/my_os2dlfcn.c b/mysys/my_os2dlfcn.c
new file mode 100644
index 00000000000..0b0b5518eff
--- /dev/null
+++ b/mysys/my_os2dlfcn.c
@@ -0,0 +1,74 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+/*
+ *    dlfcn::Unix dynamic loading for OS/2
+ *
+ * Compatibility layer for dynamic loading.
+ * Only minimal implementation
+ *
+*/
+
+#define RTLD_LAZY 0
+#define RTLD_NOW 0
+
+void* dlopen( char* path, int flag);
+char* dlerror( void);
+void* dlsym( void* hmod, char* fn);
+void  dlclose( void* hmod);
+
+char    fail[ 256];
+
+void* dlopen( char* path, int flag)
+{
+   APIRET  rc;
+   HMODULE hmod;
+
+   rc = DosLoadModule( fail, sizeof( fail), path, &hmod);
+   if (rc)
+      return NULL;
+
+   return (void*) hmod;
+}
+
+char* dlerror( void)
+{
+   return fail;
+}
+
+void* dlsym( void* hmod, char* fn)
+{
+   APIRET  rc;
+   PFN     addr;
+
+   rc = DosQueryProcAddr( (HMODULE) hmod, 0l, fn, &addr);
+   if (rc)
+      return NULL;
+
+   return (void*) addr;
+}
+
+void  dlclose( void* hmod)
+{
+   APIRET  rc;
+
+   rc = DosFreeModule( (HMODULE) hmod);
+
+}
diff --git a/mysys/my_os2dlfcn.h0 b/mysys/my_os2dlfcn.h0
new file mode 100644
index 00000000000..7f84d430230
--- /dev/null
+++ b/mysys/my_os2dlfcn.h0
@@ -0,0 +1,39 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+/*
+ *    dlfcn::Unix dynamic loading for OS/2
+ *
+ * Compatibility layer for dynamic loading.
+ * Only minimal implementation
+ *
+*/
+
+#ifndef __DLFCN_H__
+#define __DLFCN_H__
+
+#define RTLD_LAZY 0
+#define RTLD_NOW 0
+
+void* dlopen( char* path, int flag);
+char* dlerror( void);
+void* dlsym( void* hmod, char* fn);
+void  dlclose( void* hmod);
+
+#endif
diff --git a/mysys/my_os2file64.c b/mysys/my_os2file64.c
new file mode 100644
index 00000000000..8964e562ea1
--- /dev/null
+++ b/mysys/my_os2file64.c
@@ -0,0 +1,341 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+void        _OS2errno( APIRET rc);
+longlong    _lseek64( int fd, longlong offset, int seektype);
+int         _lock64( int fd, int locktype, my_off_t start,
+                     my_off_t length, myf MyFlags);
+int         _sopen64( const char *name, int oflag, int shflag, int mask);
+
+//
+// this class is used to define a global c++ variable, that
+// is initialized before main() gets called.
+//
+class File64bit
+{
+   public:
+      File64bit();  /* default constructor */
+} initFile64bit;
+
+static  APIRET (* APIENTRY _DosOpenL)(PCSZ  pszFileName,
+                            PHFILE phf,
+                            PULONG pulAction,
+                            LONGLONG cbFile,
+                            ULONG ulAttribute,
+                            ULONG fsOpenFlags,
+                            ULONG fsOpenMode,
+                            PEAOP2 peaop2);
+static  APIRET (* APIENTRY _DosSetFilePtrL)(HFILE hFile,
+                                   LONGLONG ib,
+                                   ULONG method,
+                                   PLONGLONG ibActual);
+static  APIRET (* APIENTRY _DosSetFileLocksL)(HFILE hFile,
+                                    PFILELOCKL pflUnlock,
+                                    PFILELOCKL pflLock,
+                                    ULONG timeout,
+                                    ULONG flags);
+
+#define  EIO      EINVAL
+#define  ESPIPE   EBADSEEK
+
+
+static unsigned char const errno_tab[] =
+{
+  0     , EINVAL, ENOENT, ENOENT, EMFILE,  /* 0..4 */
+  EACCES, EBADF,  EIO,    ENOMEM, EIO,     /* 5..9 */
+  EINVAL, ENOEXEC,EINVAL, EINVAL, EINVAL,  /* 10..14 */
+  ENOENT, EBUSY,  EXDEV,  ENOENT, EROFS,   /* 15..19 */
+  EIO,    EIO,    EIO,    EIO,    EIO,     /* 20..24 */
+  EIO,    EIO,    EIO,    ENOSPC, EIO,     /* 25..29 */
+  EIO,    EIO,    EACCES, EACCES, EIO,     /* 30..34 */
+  EIO,    EIO,    EIO,    EIO,    ENOSPC,  /* 35..39 */
+  EIO,    EIO,    EIO,    EIO,    EIO,     /* 40..44 */
+  EIO,    EIO,    EIO,    EIO,    EIO,     /* 45..49 */
+  EIO,    EIO,    EIO,    EIO,    EBUSY,   /* 50..54 */
+  EIO,    EIO,    EIO,    EIO,    EIO,     /* 55..59 */
+  EIO,    ENOSPC, ENOSPC, EIO,    EIO,     /* 60..64 */
+  EACCES, EIO,    EIO,    EIO,    EIO,     /* 65..69 */
+  EIO,    EIO,    EIO,    EROFS,  EIO,     /* 70..74 */
+  EIO,    EIO,    EIO,    EIO,    EIO,     /* 75..79 */
+  EEXIST, EIO,    ENOENT, EIO,    EIO,     /* 80..84 */
+  EIO,    EIO,    EINVAL, EIO,    EAGAIN,  /* 85..89 */
+  EIO,    EIO,    EIO,    EIO,    EIO,     /* 90..94 */
+  EINTR,  EIO,    EIO,    EIO,    EACCES,  /* 95..99 */
+  ENOMEM, EINVAL, EINVAL, ENOMEM, EINVAL,  /* 100..104 */
+  EINVAL, ENOMEM, EIO,    EACCES, EPIPE,   /* 105..109 */
+  ENOENT, E2BIG,  ENOSPC, ENOMEM, EBADF,   /* 110..114 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 115..119 */
+  EINVAL, EINVAL, EINVAL, ENOENT, EINVAL,  /* 120..124 */
+  ENOENT, ENOENT, ENOENT, ECHILD, ECHILD,  /* 125..129 */
+  EACCES, EINVAL, ESPIPE, EINVAL, EINVAL,  /* 130..134 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 135..139 */
+  EINVAL, EINVAL, EBUSY,  EINVAL, EINVAL,  /* 140..144 */
+  EINVAL, EINVAL, EINVAL, EBUSY,  EINVAL,  /* 145..149 */
+  EINVAL, EINVAL, ENOMEM, EINVAL, EINVAL,  /* 150..154 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 155..159 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN,  /* 160..164 */
+  EINVAL, EINVAL, EACCES, EINVAL, EINVAL,  /* 165..169 */
+  EBUSY,  EINVAL, EINVAL, EINVAL, EINVAL,  /* 170..174 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 175..179 */
+  EINVAL, EINVAL, EINVAL, EINVAL, ECHILD,  /* 180..184 */
+  EINVAL, EINVAL, ENOENT, EINVAL, EINVAL,  /* 185..189 */
+  ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC, /* 190..194 */
+  ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC, /* 195..199 */
+  ENOEXEC,ENOEXEC,ENOEXEC,ENOENT, EINVAL,  /* 200..204 */
+  EINVAL, ENAMETOOLONG, EINVAL, EINVAL, EINVAL,  /* 205..209 */
+  EINVAL, EINVAL, EACCES, ENOEXEC,ENOEXEC, /* 210..214 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 215..219 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 220..224 */
+  EINVAL, EINVAL, EINVAL, ECHILD, EINVAL,  /* 225..229 */
+  EINVAL, EBUSY,  EAGAIN, ENOTCONN, EINVAL, /* 230..234 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 235..239 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 240..244 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 245..249 */
+  EACCES, EACCES, EINVAL, ENOENT, EINVAL,  /* 250..254 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 255..259 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 260..264 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 265..269 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 270..274 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 275..279 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EEXIST,  /* 280..284 */
+  EEXIST, EINVAL, EINVAL, EINVAL, EINVAL,  /* 285..289 */
+  ENOMEM, EMFILE, EINVAL, EINVAL, EINVAL,  /* 290..294 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EINVAL,  /* 295..299 */
+  EINVAL, EBUSY,  EINVAL, ESRCH,  EINVAL,  /* 300..304 */
+  ESRCH,  EINVAL, EINVAL, EINVAL, ESRCH,   /* 305..309 */
+  EINVAL, ENOMEM, EINVAL, EINVAL, EINVAL,  /* 310..314 */
+  EINVAL, E2BIG,  ENOENT, EIO,    EIO,     /* 315..319 */
+  EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN,  /* 320..324 */
+  EINVAL, EINVAL, EINVAL, EIO,    ENOENT,  /* 325..329 */
+  EACCES, EACCES, EACCES, ENOENT, ENOMEM   /* 330..334 */
+};
+
+/*
+ * Initialize 64bit file access: dynamic load of WSeB API
+*/
+            File64bit :: File64bit()
+{
+   HMODULE hDoscalls;
+
+   if (DosQueryModuleHandle("DOSCALLS", &hDoscalls) != NO_ERROR)
+      return;
+
+   if (DosQueryProcAddr(hDoscalls, 981, NULL, (PFN *)&_DosOpenL) != NO_ERROR)
+      return;
+
+   if (DosQueryProcAddr(hDoscalls, 988, NULL, (PFN *)&_DosSetFilePtrL) != NO_ERROR) {
+      _DosOpenL = NULL;
+      return;
+   }
+
+   if (DosQueryProcAddr(hDoscalls, 986, NULL, (PFN *)&_DosSetFileLocksL) != NO_ERROR) {
+      _DosOpenL = NULL;
+      _DosSetFilePtrL = NULL;
+      return;
+   }
+   // notify success
+#ifdef MYSQL_SERVER
+   printf( "WSeB 64bit file API loaded.\n");
+#endif
+}
+
+void        _OS2errno( APIRET rc)
+{
+  if (rc >= sizeof (errno_tab))
+    errno = EINVAL;
+  else
+    errno = errno_tab[rc];
+}
+
+longlong    _lseek64( int fd, longlong offset, int seektype)
+{
+   APIRET   rc;
+   longlong actual;
+
+   if (_DosSetFilePtrL)
+      rc = _DosSetFilePtrL( fd, offset, seektype, &actual);
+   else {
+      ULONG ulActual;
+      rc = DosSetFilePtr( fd, (long) offset, seektype, &ulActual);
+      actual = ulActual;
+   }
+
+   if (!rc)
+      return( actual);/* NO_ERROR */
+
+   // set errno
+   _OS2errno( rc);
+   // seek failed
+   return(-1);
+}
+
+inline _SetFileLocksL(HFILE hFile,
+                          PFILELOCKL pflUnlock,
+                          PFILELOCKL pflLock,
+                          ULONG timeout,
+                          ULONG flags)
+{
+   if (_DosSetFileLocksL)
+      return _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags);
+
+   FILELOCK flUnlock = { pflUnlock->lOffset, pflUnlock->lRange };
+   FILELOCK flLock = { pflLock->lOffset, pflLock->lRange };
+   return DosSetFileLocks( hFile, &flUnlock, &flLock, timeout, flags);
+}
+
+int         _lock64( int fd, int locktype, my_off_t start,
+                     my_off_t length, myf MyFlags)
+{
+   FILELOCKL LockArea = {0,0}, UnlockArea = {0,0};
+   ULONG     readonly = 0;
+   APIRET    rc = -1;
+
+   switch( locktype) {
+   case F_UNLCK:
+      UnlockArea.lOffset = start;
+      UnlockArea.lRange = length ? length : LONGLONG_MAX;
+      break;
+
+   case F_RDLCK:
+   case F_WRLCK:
+      LockArea.lOffset = start;
+      LockArea.lRange = length ? length : LONGLONG_MAX;
+      readonly = (locktype == F_RDLCK ? 1 : 0);
+      break;
+
+   default:
+      errno = EINVAL;
+      rc = -1;
+      break;
+   }
+
+   if (MyFlags & MY_DONT_WAIT) {
+
+      rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly);
+      //printf( "fd %d, locktype %d, rc %d (dont_wait)\n", fd, locktype, rc);
+      if (rc == 33) {  /* Lock Violation */
+
+         DBUG_PRINT("info",("Was locked, trying with timeout"));
+         rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly);
+         //printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc);
+      }
+
+   } else {
+
+      while( rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly) && (rc == 33)) {
+         printf(".");
+         DosSleep(1 * 1000);
+      }
+      //printf( "fd %d, locktype %d, rc %d (wait2)\n", fd, locktype, rc);
+   }
+
+   if (!rc)
+      return( 0);/* NO_ERROR */
+
+   // set errno
+   _OS2errno( rc);
+   // lock failed
+   return(-1);
+}
+
+int         _sopen64( const char *name, int oflag, int shflag, int mask)
+{
+   int      fail_errno;
+   APIRET   rc = 0;
+   HFILE    hf = 0;
+   ULONG    ulAction = 0;
+   LONGLONG cbFile = 0;
+   ULONG    ulAttribute = FILE_NORMAL;
+   ULONG    fsOpenFlags = 0;
+   ULONG    fsOpenMode = 0;
+
+   /* Extract the access mode and sharing mode bits. */
+   fsOpenMode = (shflag & 0xFF) | (oflag & 0x03);
+
+   /* Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see
+      below). */
+   fail_errno = ENOENT;
+
+   /* Compute `open_flag' depending on `flags'.  Note that _SO_CREAT is
+      set for O_CREAT. */
+
+   if (oflag & O_CREAT)
+   {
+      if (oflag & O_EXCL)
+      {
+         fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
+         fail_errno = EEXIST;
+      }
+      else if (oflag & O_TRUNC)
+        fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
+      else
+        fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
+
+      if (mask & S_IWRITE)
+         ulAttribute = FILE_NORMAL;
+      else
+         ulAttribute = FILE_READONLY;
+
+   }
+   else if (oflag & O_TRUNC)
+      fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
+   else
+      fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
+
+   /* Try to open the file and handle errors. */
+   if (_DosOpenL)
+      rc = _DosOpenL( name, &hf, &ulAction, cbFile,
+                     ulAttribute, fsOpenFlags, fsOpenMode, NULL);
+   else
+      rc = DosOpen( name, &hf, &ulAction, (LONG) cbFile,
+                     ulAttribute, fsOpenFlags, fsOpenMode, NULL);
+
+   if (rc == ERROR_OPEN_FAILED)
+   {
+      errno = fail_errno;
+      return -1;
+   }
+   if (rc != 0)
+   {
+      // set errno
+      _OS2errno( rc);
+      return -1;
+   }
+
+   if (oflag & O_APPEND)
+      _lseek64( hf, 0L, SEEK_END);
+
+   return hf;
+}
+
+inline int   open( const char *name, int oflag)
+{
+   return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE);
+}
+
+inline int   open( const char *name, int oflag, int mask)
+{
+   return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, mask);
+}
+
+inline int   sopen( const char *name, int oflag, int shflag, int mask)
+{
+   return _sopen64( name, oflag, shflag, mask);
+}
diff --git a/mysys/my_os2mutex.c b/mysys/my_os2mutex.c
new file mode 100644
index 00000000000..0ae6ae86d8c
--- /dev/null
+++ b/mysys/my_os2mutex.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
+ * All rights reserved.
+ *
+ * Modified and extended by Antony T Curtis <antony.curtis@olcs.net>
+ * for use with OS/2.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by John Birrell.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <stdlib.h>
+#include <errno.h>
+#ifdef _THREAD_SAFE
+//#include <pthread.h>
+//#include "pthread_private.h"
+
+int
+pthread_mutex_init(pthread_mutex_t * mutex,
+		   const pthread_mutexattr_t * mutex_attr)
+{
+	APIRET		rc = 0;
+
+	rc = DosCreateMutexSem(NULL,mutex,0,0);
+
+	/* Return the completion status: */
+	return (0);
+}
+
+int
+pthread_mutex_destroy(pthread_mutex_t * mutex)
+{
+	APIRET		rc = 0;
+
+
+	do {
+		rc = DosCloseMutexSem(*mutex);
+		if (rc == 301) DosReleaseMutexSem(*mutex);
+	} while (rc == 301);
+
+	*mutex = 0;
+
+	/* Return the completion status: */
+	return (0);
+}
+
+
+int
+pthread_mutex_lock(pthread_mutex_t * mutex)
+{
+	int             ret = 0;
+	int             status = 0;
+	APIRET		rc = 0;
+
+   rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT);
+	if (rc)
+      return(EINVAL);
+	/* Return the completion status: */
+	return (0);
+}
+
+int
+pthread_mutex_unlock(pthread_mutex_t * mutex)
+{
+	int             ret = 0;
+	APIRET		rc = 0;
+	int             status;
+
+   rc = DosReleaseMutexSem(*mutex);
+
+	/* Return the completion status: */
+	return (0);
+}
+#endif
diff --git a/mysys/my_os2thread.c b/mysys/my_os2thread.c
new file mode 100644
index 00000000000..017ba7f316b
--- /dev/null
+++ b/mysys/my_os2thread.c
@@ -0,0 +1,126 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+/*****************************************************************************
+** Simulation of posix threads calls for OS/2
+*****************************************************************************/
+
+#include "mysys_priv.h"
+#if defined(THREAD) && defined(OS2)
+#include <m_string.h>
+#include <process.h>
+
+static pthread_mutex_t THR_LOCK_thread;
+
+struct pthread_map
+{
+  HANDLE          pthreadself;
+  pthread_handler func;
+  void *          param;
+};
+
+void win_pthread_init(void)
+{
+  pthread_mutex_init(&THR_LOCK_thread,NULL);
+}
+
+/*
+** We have tried to use '_beginthreadex' instead of '_beginthread' here
+** but in this case the program leaks about 512 characters for each
+** created thread !
+** As we want to save the created thread handler for other threads to
+** use and to be returned by pthread_self() (instead of the Win32 pseudo
+** handler), we have to go trough pthread_start() to catch the returned handler
+** in the new thread.
+*/
+
+static pthread_handler_decl(pthread_start,param)
+{
+  pthread_handler func=((struct pthread_map *) param)->func;
+  void *func_param=((struct pthread_map *) param)->param;
+  my_thread_init();			/* Will always succeed in windows */
+  pthread_mutex_lock(&THR_LOCK_thread);	  /* Wait for beginthread to return */
+  win_pthread_self=((struct pthread_map *) param)->pthreadself;
+  pthread_mutex_unlock(&THR_LOCK_thread);
+  free((char*) param);			  /* Free param from create */
+  pthread_exit((void*) (*func)(func_param));
+  return 0;				  /* Safety */
+}
+
+
+int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
+		   pthread_handler func, void *param)
+{
+  HANDLE hThread;
+  struct pthread_map *map;
+  DBUG_ENTER("pthread_create");
+
+  if (!(map=(struct pthread_map *)malloc(sizeof(*map))))
+    DBUG_RETURN(-1);
+  map->func=func;
+  map->param=param;
+  pthread_mutex_lock(&THR_LOCK_thread);
+#ifdef __BORLANDC__
+  hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start,
+			       attr->dwStackSize ? attr->dwStackSize :
+			       65535, (void*) map);
+#elif defined( OS2)
+  hThread=(HANDLE)_beginthread((void( _Optlink *)(void *)) pthread_start, NULL,
+			       attr->dwStackSize ? attr->dwStackSize :
+			       65535, (void*) map);
+#else
+  hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start,
+			       attr->dwStackSize ? attr->dwStackSize :
+			       65535, (void*) map);
+#endif
+  DBUG_PRINT("info", ("hThread=%lu",(long) hThread));
+  *thread_id=map->pthreadself=hThread;
+  pthread_mutex_unlock(&THR_LOCK_thread);
+
+  if (hThread == (HANDLE) -1)
+  {
+    int error=errno;
+    DBUG_PRINT("error",
+	       ("Can't create thread to handle request (error %d)",error));
+    DBUG_RETURN(error ? error : -1);
+  }
+#ifdef OS2
+  my_pthread_setprio(hThread, attr->priority);
+#else
+  VOID(SetThreadPriority(hThread, attr->priority)) ;
+#endif
+  DBUG_RETURN(0);
+}
+
+
+void pthread_exit(void *a)
+{
+  _endthread();
+}
+
+/* This is neaded to get the macro pthread_setspecific to work */
+
+int win_pthread_setspecific(void *a,void *b,uint length)
+{
+  memcpy(a,b,length);
+  return 0;
+}
+
+#endif
diff --git a/mysys/my_os2tls.c b/mysys/my_os2tls.c
new file mode 100644
index 00000000000..25d543d0768
--- /dev/null
+++ b/mysys/my_os2tls.c
@@ -0,0 +1,144 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+   All the above parties has a full, independent copyright to
+   the following code, including the right to use the code in
+   any manner without any demands from the other parties.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with this library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA */
+
+DWORD    TlsAlloc( void);
+BOOL     TlsFree( DWORD);
+PVOID    TlsGetValue( DWORD);
+BOOL     TlsSetValue( DWORD, PVOID);
+
+#define TLS_MINIMUM_AVAILABLE   64
+
+
+PULONG           tls_storage;   /* TLS local storage */
+DWORD            tls_bits[2];   /* TLS in-use bits   */
+pthread_mutex_t  tls_mutex;     /* TLS mutex for in-use bits */
+
+DWORD    TlsAlloc( void)
+{
+   DWORD index = -1;
+   DWORD mask, tibidx;
+   int   i;
+
+   if (tls_storage == NULL) {
+
+      APIRET rc;
+
+      // allocate memory for TLS storage
+      rc = DosAllocThreadLocalMemory( 1, &tls_storage);
+      if (rc) {
+         fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n", rc);
+      }
+
+      // create a mutex
+      if (pthread_mutex_init( &tls_mutex, NULL))
+         fprintf( stderr, "Failed to init TLS mutex\n");
+   }
+
+   pthread_mutex_lock( &tls_mutex);
+
+   tibidx = 0;
+   if (tls_bits[0] == 0xFFFFFFFF) {
+      if (tls_bits[1] == 0xFFFFFFFF) {
+            fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid);
+            pthread_mutex_unlock( &tls_mutex);
+            return -1;
+      }
+      tibidx = 1;
+   }
+   for( i=0; i<32; i++) {
+      mask = (1 << i);
+      if ((tls_bits[ tibidx] & mask) == 0) {
+         tls_bits[ tibidx] |= mask;
+         index = (tibidx*32) + i;
+         break;
+      }
+   }
+   tls_storage[index] = 0;
+
+   pthread_mutex_unlock( &tls_mutex);
+
+   //fprintf( stderr, "tid#%d, TlsAlloc index %d\n", _threadid, index);
+
+   return index;
+}
+
+BOOL     TlsFree( DWORD index)
+{
+   int    tlsidx;
+   DWORD  mask;
+
+   if (index >= TLS_MINIMUM_AVAILABLE)
+      return NULL;
+
+   pthread_mutex_lock( &tls_mutex);
+
+   tlsidx = 0;
+   if (index > 32) {
+      tlsidx++;
+   }
+   mask = (1 << index);
+   if (tls_bits[ tlsidx] & mask) {
+      tls_bits[tlsidx] &= ~mask;
+      tls_storage[index] = 0;
+      pthread_mutex_unlock( &tls_mutex);
+      return TRUE;
+   }
+
+   pthread_mutex_unlock( &tls_mutex);
+   return FALSE;
+}
+
+
+PVOID    TlsGetValue( DWORD index)
+{
+   if (index >= TLS_MINIMUM_AVAILABLE)
+      return NULL;
+
+   // verify if memory has been allocated for this thread
+   if (*tls_storage == NULL) {
+      // allocate memory for indexes
+      *tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
+      //fprintf( stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage);
+   }
+
+   ULONG* tls_array = (ULONG*) *tls_storage;
+   return (PVOID) tls_array[ index];
+}
+
+BOOL     TlsSetValue( DWORD index, PVOID val)
+{
+
+   // verify if memory has been allocated for this thread
+   if (*tls_storage == NULL) {
+      // allocate memory for indexes
+      *tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
+      //fprintf( stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage);
+   }
+
+   if (index >= TLS_MINIMUM_AVAILABLE)
+      return FALSE;
+
+   ULONG* tls_array = (ULONG*) *tls_storage;
+   //fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x (old)\n", _threadid, tls_array, index, tls_array[ index]);
+   tls_array[ index] = (ULONG) val;
+   //fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x\n", _threadid, tls_array, index, val);
+
+   return TRUE;
+}
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index a3a193650df..8bdbc0f7fd8 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -145,7 +145,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
 ** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty
 ****************************************************************************/
 
-#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
+#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(OS2)
 
 #if !defined(DONT_USE_SIGSUSPEND)
 
diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c
index c9d8edd6ddf..7ab75d47619 100644
--- a/mysys/my_realloc.c
+++ b/mysys/my_realloc.c
@@ -49,7 +49,7 @@ gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags)
     free(oldpoint);
   }
 #else
-  if ((point = realloc(oldpoint,Size)) == NULL)
+  if ((point = (char*)realloc(oldpoint,Size)) == NULL)
   {
     if (MyFlags & MY_FREE_ON_ERROR)
       my_free(oldpoint,MyFLAGS);
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 0cc17481dab..16ec77394d2 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -91,7 +91,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
     return 1;
   VOID(chmod(to, statbuf.st_mode & 07777));		/* Copy modes */
 
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
   if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
   {
     if (MyFlags & MY_LINK_WARNING)
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 3fc68455841..00061893cdc 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -20,7 +20,7 @@
   a shared library
 */
 
-#ifndef stdin
+#if !defined(stdin) || defined(OS2)
 #include "mysys_priv.h"
 #include "my_static.h"
 #include "my_alarm.h"
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
index ac982538668..7da037e8d49 100644
--- a/mysys/my_tempnam.c
+++ b/mysys/my_tempnam.c
@@ -26,7 +26,7 @@
 #endif
 
 #ifdef HAVE_TEMPNAM
-#ifndef MSDOS
+#if !defined( MSDOS) && !defined(OS2)
 extern char **environ;
 #endif
 #endif
@@ -91,14 +91,23 @@ my_string my_tempnam(const char *dir, const char *pfx,
     temp[1]= 0;
     dir=temp;
   }
-  old_env=environ;
+#ifdef OS2
+  // changing environ variable doesn't work with VACPP
+  char  buffer[256];
+  sprintf( buffer, "TMP=%s", dir);
+  putenv( buffer);
+#else
+  old_env=(char**)environ;
   if (dir)
   {				/* Don't use TMPDIR if dir is given */
-    environ=temp_env;
+    environ=(const char**)temp_env;
     temp_env[0]=0;
   }
+#endif
   res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
-  environ=old_env;
+#ifndef OS2
+  environ=(const char**)old_env;
+#endif
   if (!res)
     DBUG_PRINT("error",("Got error: %d from tempnam",errno));
   return res;
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index dab281e4dc6..e1f9e23912e 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -72,7 +72,7 @@ my_bool my_thread_global_init(void)
   pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
   pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST);
   pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST);
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   win_pthread_init();
 #endif
 #ifndef HAVE_LOCALTIME_R
@@ -160,11 +160,11 @@ void my_thread_end(void)
     pthread_cond_destroy(&tmp->suspend);
 #endif
     pthread_mutex_destroy(&tmp->mutex);
-#if !defined(__WIN__) || defined(USE_TLS)
+#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
     free(tmp);
 #endif
   }
-#if !defined(__WIN__) || defined(USE_TLS)
+#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
   pthread_setspecific(THR_KEY_mysys,0);
 #endif
 }
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 61d6c7d2180..640043192ef 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -19,6 +19,46 @@
 #include "mysys_err.h"
 #include <errno.h>
 
+#ifdef OS2
+
+int      _write64( int fd, const void *buffer, unsigned int count)
+{
+   APIRET   rc;
+   ULONG    actual;
+
+   rc = DosWrite( fd, (PVOID) buffer, count, &actual);
+
+   switch (rc) {
+   case 0:  /* NO_ERROR */
+      errno = 0;
+      return( actual);
+      break;
+   case ERROR_INVALID_FUNCTION:
+      errno = EPERM;
+      break;
+   case ERROR_ACCESS_DENIED:
+      errno = EACCESS;
+      break;
+   case ERROR_INVALID_HANDLE:
+      errno = EBADF;
+      break;
+   case ERROR_DISK_FULL:
+      errno = ENOSPC;
+      break;
+   default:
+      errno = EINVAL;
+      break;
+   }
+   // write failed
+   return(-1);
+}
+
+// redirect call
+#define write _write64
+
+#endif // OS2
+
+
 	/* Write a chunk of bytes to a file */
 
 uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
diff --git a/mysys/test_charset.c b/mysys/test_charset.c
index a04bdbd9a58..6a5183d2cd3 100644
--- a/mysys/test_charset.c
+++ b/mysys/test_charset.c
@@ -22,7 +22,7 @@
 
 #include <stdio.h>
 
-extern void _print_csinfo();
+extern void _print_csinfo(CHARSET_INFO *cs);
 
 int main(int argc, char **argv) {
   const char *the_set = MYSQL_CHARSET;
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 3c641e01d7b..f51f27b7f51 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -37,7 +37,7 @@
 static my_bool alarm_aborted=1;
 my_bool thr_alarm_inited=0;
 
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
 
 static pthread_mutex_t LOCK_alarm;
 static sigset_t full_signal_set;
@@ -460,7 +460,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
 **  thr_alarm for OS/2
 *****************************************************************************/
 
-#elif defined(__EMX__)
+#elif defined(__EMX__) || defined(OS2)
 
 #define INCL_BASE
 #define INCL_NOPMAPI
@@ -775,8 +775,10 @@ static sig_handler print_signal_warning(int sig)
 #ifdef DONT_REMEMBER_SIGNAL
   sigset(sig,print_signal_warning);		/* int. thread system calls */
 #endif
+#ifndef OS2
   if (sig == SIGALRM)
     alarm(2);					/* reschedule alarm */
+#endif
 }
 #endif /* USE_ONE_SIGNAL_HAND */
 
@@ -793,6 +795,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
   VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
   pthread_mutex_unlock(&LOCK_thread_count);
 
+#ifndef OS2
   sigemptyset(&set);				/* Catch all signals */
   sigaddset(&set,SIGINT);
   sigaddset(&set,SIGQUIT);
@@ -809,6 +812,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
 #else
   puts("Starting signal handling thread");
 #endif
+#endif /* OS2 */
   printf("server alarm: %d  thread alarm: %d\n",
 	 THR_SERVER_ALARM,THR_CLIENT_ALARM);
   DBUG_PRINT("info",("Starting signal and alarm handling thread"));
@@ -831,7 +835,9 @@ static void *signal_hand(void *arg __attribute__((unused)))
     case SIGINT:
     case SIGQUIT:
     case SIGTERM:
+#ifndef OS2
     case SIGHUP:
+#endif
       printf("Aborting nicely\n");
       end_thr_alarm();
       break;
@@ -841,11 +847,13 @@ static void *signal_hand(void *arg __attribute__((unused)))
       exit(1);
       return 0;					/* Keep some compilers happy */
 #endif
+#ifndef OS2
 #ifdef USE_ONE_SIGNAL_HAND
      case THR_SERVER_ALARM:
        process_alarm(sig);
       break;
 #endif
+#endif /* OS2 */
     }
   }
 }
@@ -866,6 +874,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
   pthread_cond_init(&COND_thread_count,NULL);
 
   /* Start a alarm handling thread */
+#ifndef OS2
   sigemptyset(&set);
   sigaddset(&set,SIGINT);
   sigaddset(&set,SIGQUIT);
@@ -883,6 +892,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
   sigaddset(&set,THR_CLIENT_ALARM);
   VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
 #endif
+#endif /* OS2 */
 
   pthread_attr_init(&thr_attr);
   pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
diff --git a/mysys/tree.c b/mysys/tree.c
index 002062d9f0e..cd05a17fd72 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -133,7 +133,7 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element)
     if (tree->free)
       (*tree->free)(ELEMENT_KEY(tree,element));
     if (tree->with_delete)
-      my_free((void*) element,MYF(0));
+      my_free((char*) element,MYF(0));
   }
 }
 
diff --git a/os2/ChangeLog.os2 b/os2/ChangeLog.os2
new file mode 100644
index 00000000000..34547262fe2
--- /dev/null
+++ b/os2/ChangeLog.os2
@@ -0,0 +1,23 @@
+
+2001/06/12
+	- fixed support for > 2GB file size, needs also DosOpenL
+	- mixed 64bit/32bit file size support, dinamic loading of
+	  64bit API.
+
+2001/06/03
+	- added support for > 2GB file size
+
+2001/06/02
+	- fixed file locking code
+
+2001/05/29
+	- 3.23.38 build
+
+2001/05/20
+	- rint fix
+	- isam O_RDONLY table handled fix
+
+2001/05/19
+	- new TLS code, fixed parser crashes and many other problems.
+	- fixed pthread_cond_timedwait, now handle manager expires
+
diff --git a/os2/MySQL-All.icc b/os2/MySQL-All.icc
new file mode 100644
index 00000000000..1bd8a1dd89f
--- /dev/null
+++ b/os2/MySQL-All.icc
@@ -0,0 +1,13 @@
+
+// create directories
+for dir in "..\\bin", "..\\lib", "..\\obj", "..\\obj\\zlib", "..\\obj\\readline" {
+   run "if not exist "dir" mkdir "dir
+}
+
+// build sequence
+run "vacbld MySQL-Lib.icc -showprogress=10 -showwarning"
+run "vacbld MySQL-Client.icc -showprogress=10 -showwarning"
+run "vacbld MySQL-Sql.icc -showprogress=10 -showwarning"
+
+// need only for utilities and test applications
+run "vacbld MySQL-Util.icc -showprogress=10 -showwarning"
diff --git a/os2/MySQL-Client.icc b/os2/MySQL-Client.icc
new file mode 100644
index 00000000000..e00fe28a3c9
--- /dev/null
+++ b/os2/MySQL-Client.icc
@@ -0,0 +1,87 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+                        //, link(defaultlibsname, "readline.lib")
+{
+
+   option file(genobject, "..\\OBJ\\ZLIB\\")
+   {
+      target "..\\bin\\mysql.dll"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+         // target source files
+         source zlib
+         if debug_build  {
+            source type('cpp') dbug
+         }
+         source type('cpp') my_sys
+         source type('cpp') my_sys_cli
+         source type('cpp') strings
+         source type('cpp') mysqlclientlib
+      }
+   }
+
+   option file(genobject, "..\\OBJ\\READLINE\\")
+   {
+      target "..\\bin\\mysql.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         //source readline
+         source type('cpp') "..\\client\\mysql.cc"
+      }
+   }
+
+      target "..\\bin\\mysqladmin.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source type('cpp') "..\\client\\mysqladmin.c"
+      }
+
+      target "..\\bin\\mysqldump.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+         // target source files
+         source type('cpp') "..\\client\\mysqldump.c"
+      }
+
+      target "..\\bin\\mysqlshow.exe"
+      {
+         // target source files
+         source type('cpp') "..\\client\\mysqlshow.c"
+      }
+
+      target "..\\bin\\mysqlimport.exe"
+      {
+         // target source files
+         source type('cpp') "..\\client\\mysqlimport.c"
+      }
+
+      target "..\\bin\\mysqltest.exe"
+      {
+         source type('cpp') "..\\client\\mysqltest.c"
+      }
+
+}
diff --git a/os2/MySQL-Client.irs b/os2/MySQL-Client.irs
new file mode 100644
index 00000000000..4b5a9e3475a
--- /dev/null
+++ b/os2/MySQL-Client.irs
@@ -0,0 +1,2335 @@
+31 Run Specifications: Version 1.1
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+44 E:\rd\mysql\vacpp-3.23.40\bin\mysqladmin.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\mysqldump.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\mysqlshow.exe
+1
+0
+0
+5 Local
+0
+45 E:\rd\mysql\vacpp-3.23.40\bin\mysqlimport.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\mysqltest.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/MySQL-Lib.icc b/os2/MySQL-Lib.icc
new file mode 100644
index 00000000000..51f55ed8302
--- /dev/null
+++ b/os2/MySQL-Lib.icc
@@ -0,0 +1,72 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+{
+
+   option file(genobject, "..\\OBJ\\ZLIB\\")
+   {
+      target "..\\lib\\common.lib"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source zlib
+         if debug_build  {
+            source type('cpp') dbug
+         }
+         source type('cpp') heap
+         //source type('cpp') merge
+         source type('cpp') my_sys
+         source type('cpp') my_sys_cli
+         source type('cpp') my_sys_sql
+         source type('cpp') strings
+      }
+   }
+
+/*
+   option file(genobject, "..\\OBJ\\READLINE\\")
+   {
+      target "..\\lib\\readline.lib"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source readline
+      }
+   }
+*/
+
+      target "..\\lib\\myisam.lib"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source type('cpp') myisam
+      }
+
+      target "..\\lib\\isam.lib"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source type('cpp') isam
+      }
+
+}
diff --git a/os2/MySQL-Opt.icc b/os2/MySQL-Opt.icc
new file mode 100644
index 00000000000..5f5cdb7c72f
--- /dev/null
+++ b/os2/MySQL-Opt.icc
@@ -0,0 +1,53 @@
+// set to 1 to enable debug code
+debug_build = 0
+
+// common options
+option BaseOptions =    link(defaultlibsname, "tcpip32.lib")
+                        ,link(libsearchpath, "..\\lib\\")
+                        ,link(libsearchpath, "..\\bin\\")
+                        ,link(pmtype, vio)
+                        ,link(linkwithmultithreadlib, "yes")
+                        ,link(linkwithsharedlib, "no")
+                        ,gen(initauto, "yes")
+                        ,define("__MT__", )
+                        ,define("HAVE_BSD_SIGNALS", )
+                        ,define("INCL_DOS", )
+                        ,define("INCL_DOSERRORS", )
+                        ,define("INCL_LONGLONG", )
+                        ,define("OS2", )
+                        ,define("USE_TLS", )
+                        ,lang(signedchars, yes)
+                        ,incl(searchpath, "..")
+                        ,incl(searchpath, "..\\include")
+                        ,incl(searchpath, "..\\my_sys")
+                        ,incl(searchpath, "..\\regex")
+                        ,incl(searchpath, "..\\sql")
+                        ,incl(searchpath, "\\rd\\mysql\\zlib-1.1.3")
+                        ,incl(searchpath, "\\rd\\mysql\\ufc")
+                        ,incl(searchpath, "..\\os2")
+
+option ReleaseOptions =   link(debug, "no")
+                        , define("DBUG_OFF", )
+                        , gen(arch, "pentium")
+                        , opt(tune, "pentium2")
+                        , opt(level, "0")
+                        , opt(stackchaining, no)
+                        , opt(size, yes)
+                        , opt(autoinline, InlineCode)
+                        , opt(inline, InlineCode)
+                        , opt(schedule, no)
+
+option DebugOptions =     link(debug, "yes")
+                        , gen(debug, "yes")
+                        , define("DBUG_ON", )
+
+
+if debug_build {
+
+option MySQLOptions =   BaseOptions, DebugOptions
+
+} else {
+
+option MySQLOptions =   BaseOptions, ReleaseOptions
+
+}
diff --git a/os2/MySQL-ReadLine.icc b/os2/MySQL-ReadLine.icc
new file mode 100644
index 00000000000..3f63b0815e6
--- /dev/null
+++ b/os2/MySQL-ReadLine.icc
@@ -0,0 +1,27 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+{
+
+
+
+   option file(genobject, "..\\OBJ\\READLINE\\")
+   {
+      target "..\\lib\\readline.lib"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source readline
+      }
+   }
+   
+}
diff --git a/os2/MySQL-Source.icc b/os2/MySQL-Source.icc
new file mode 100644
index 00000000000..48780857185
--- /dev/null
+++ b/os2/MySQL-Source.icc
@@ -0,0 +1,298 @@
+group client_pch =
+            'os2.h',
+            'assert.h', 'direct.h', 'errno.h', 'nerrno.h',
+            'limits.h', 'io.h', 'math.h',
+            'stdio.h', 'stdlib.h', 'stddef.h',
+            'sys/stat.h', 'sys/types.h', 'sys/time.h',
+            'types.h', 'string.h', 'stdarg.h',
+
+            'my_base.h', 'config-os2.h', 'my_dir.h',
+            'global.h', 'thr_alarm.h', 'm_string.h',
+            'mysql.h', 'zconf.h', 'zlib.h', 'mysys_err.h',
+            //'my_os2dirsrch.h',
+            'm_ctype.h',
+            'mysqld_error.h',
+            'my_list.h', 'my_sys.h', 'my_net.h',
+            'myisam.h', 'myisampack.h', '.\myisam\myisamdef.h'
+
+group mysqlclientlib =
+               "..\\client\\readline.cc",
+               "..\\client\\sql_string.cc",
+               "..\\client\\completion_hash.cc",
+               //"..\\libmysql\\dll.c",
+               "..\\libmysql\\libmysql.c",
+               "..\\libmysql\\errmsg.c",
+               "..\\libmysql\\get_password.c",
+               "..\\libmysql\\net.c",
+               "..\\libmysql\\password.c",
+               "..\\libmysql\\violite.c"
+
+group zlib =
+               "\\rd\\mysql\\zlib-1.1.3\\compress.c", "\\rd\\mysql\\zlib-1.1.3\\crc32.c",
+               "\\rd\\mysql\\zlib-1.1.3\\deflate.c", "\\rd\\mysql\\zlib-1.1.3\\gzio.c", "\\rd\\mysql\\zlib-1.1.3\\infblock.c",
+               "\\rd\\mysql\\zlib-1.1.3\\infcodes.c", "\\rd\\mysql\\zlib-1.1.3\\inffast.c",
+               "\\rd\\mysql\\zlib-1.1.3\\inflate.c", "\\rd\\mysql\\zlib-1.1.3\\inftrees.c",
+               "\\rd\\mysql\\zlib-1.1.3\\infutil.c", "\\rd\\mysql\\zlib-1.1.3\\trees.c", "\\rd\\mysql\\zlib-1.1.3\\uncompr.c",
+               "\\rd\\mysql\\zlib-1.1.3\\zutil.c", "\\rd\\mysql\\zlib-1.1.3\\adler32.c"
+
+group ufc =
+               "\\rd\\mysql\\ufc\\crypt.c",
+               "\\rd\\mysql\\ufc\\crypt_util.c",
+               "\\rd\\mysql\\ufc\\crypt-entry.c"
+
+group sql =
+               "..\\sql\\convert.cc",
+               "..\\sql\\derror.cc",
+               "..\\sql\\field.cc",
+               "..\\sql\\field_conv.cc",
+               "..\\sql\\filesort.cc",
+               "..\\sql\\ha_heap.cc",
+               "..\\sql\\ha_isam.cc",
+               "..\\sql\\ha_isammrg.cc",
+               "..\\sql\\ha_myisam.cc",
+               "..\\sql\\ha_myisammrg.cc",
+               "..\\sql\\handler.cc",
+               "..\\sql\\hash_filo.cc",
+               "..\\sql\\hostname.cc",
+               "..\\sql\\init.cc",
+               "..\\sql\\item.cc",
+               "..\\sql\\item_buff.cc",
+               "..\\sql\\item_cmpfunc.cc",
+               "..\\sql\\item_create.cc",
+               "..\\sql\\item_func.cc",
+               "..\\sql\\item_strfunc.cc",
+               "..\\sql\\item_sum.cc",
+               "..\\sql\\item_timefunc.cc",
+               "..\\sql\\item_uniq.cc",
+               "..\\sql\\key.cc",
+               "..\\sql\\lock.cc",
+               "..\\sql\\log.cc",
+               "..\\sql\\log_event.cc",
+               "..\\sql\\md5.c",
+               "..\\sql\\mf_iocache.cc",
+               "..\\sql\\mini_client.cc",
+               "..\\sql\\mini_client_errors.c",
+               "..\\sql\\mysqld.cc",
+               "..\\sql\\net_pkg.cc",
+               "..\\sql\\net_serv.cc",
+               "..\\sql\\opt_ft.cc",
+               "..\\sql\\opt_range.cc",
+               "..\\sql\\OPT_SUM.cc",
+               "..\\sql\\password.c",
+               "..\\sql\\procedure.cc",
+               "..\\sql\\records.cc",
+               "..\\sql\\slave.cc",
+               "..\\sql\\sql_acl.cc",
+               "..\\sql\\sql_analyse.cc",
+               "..\\sql\\sql_base.cc",
+               "..\\sql\\sql_cache.cc",
+               "..\\sql\\sql_class.cc",
+               "..\\sql\\sql_crypt.cc",
+               "..\\sql\\sql_db.cc",
+               "..\\sql\\sql_delete.cc",
+               "..\\sql\\sql_insert.cc",
+               "..\\sql\\sql_lex.cc",
+               "..\\sql\\sql_list.cc",
+               "..\\sql\\sql_load.cc",
+               "..\\sql\\sql_manager.cc",
+               "..\\sql\\sql_map.cc",
+               "..\\sql\\sql_parse.cc",
+               "..\\sql\\sql_rename.cc",
+               "..\\sql\\sql_repl.cc",
+               "..\\sql\\sql_select.cc",
+               "..\\sql\\sql_show.cc",
+               "..\\sql\\sql_string.cc",
+               "..\\sql\\sql_table.cc",
+               "..\\sql\\sql_test.cc",
+               "..\\sql\\sql_update.cc",
+               "..\\sql\\sql_udf.cc",
+               "..\\sql\\sql_yacc.cc",
+               "..\\sql\\table.cc",
+               "..\\sql\\thr_malloc.cc",
+               "..\\sql\\time.cc",
+               "..\\sql\\unireg.cc",
+               "..\\sql\\violite.c"
+
+group isam =
+                      "..\\isam\\changed.c", "..\\isam\\close.c",
+                      "..\\isam\\create.c", "..\\isam\\delete.c", "..\\isam\\extra.c",
+                      "..\\isam\\info.c", "..\\isam\\log.c", "..\\isam\\open.c",
+                      "..\\isam\\panic.c", "..\\isam\\range.c",
+                      "..\\isam\\rfirst.c", "..\\isam\\rkey.c", "..\\isam\\rlast.c",
+                      "..\\isam\\rnext.c", "..\\isam\\rprev.c", "..\\isam\\rrnd.c",
+                      "..\\isam\\rsame.c", "..\\isam\\rsamepos.c",
+                      "..\\isam\\static.c", "..\\isam\\update.c",
+                      "..\\isam\\write.c", "..\\isam\\_cache.c",
+                      "..\\isam\\_dbug.c", "..\\isam\\_dynrec.c",
+                      "..\\isam\\_key.c", "..\\isam\\_locking.c",
+                      "..\\isam\\_packrec.c", "..\\isam\\_page.c",
+                      "..\\isam\\_search.c", "..\\isam\\_statrec.c"
+
+group strings =
+               "..\\strings\\bchange.c",
+               "..\\strings\\bmove.c",
+               "..\\strings\\bmove_upp.c",
+               "..\\strings\\ctype-big5.c",
+               "..\\strings\\ctype-czech.c",
+               "..\\strings\\ctype-euc_kr.c",
+               "..\\strings\\ctype-gb2312.c",
+               "..\\strings\\ctype-gbk.c",
+               "..\\strings\\ctype-sjis.c",
+               "..\\strings\\ctype-tis620.c",
+               "..\\strings\\ctype-ujis.c",
+               "..\\strings\\ctype_extra_sources.c",
+               "..\\strings\\ctype_autoconf.c",
+               "..\\strings\\ctype.c",
+               "..\\strings\\int2str.c",
+               "..\\strings\\is_prefix.c",
+               "..\\strings\\llstr.c",
+               "..\\strings\\longlong2str.c",
+               "..\\strings\\str2int.c",
+               "..\\strings\\strappend.c",
+               "..\\strings\\strcend.c",
+               "..\\strings\\strcont.c",
+               "..\\strings\\strend.c",
+               "..\\strings\\strfill.c",
+               "..\\strings\\strinstr.c",
+               "..\\strings\\strmake.c",
+               "..\\strings\\strmov.c",
+               "..\\strings\\strnlen.c",
+               "..\\strings\\strnmov.c",
+               "..\\strings\\strtoull.c",
+               "..\\strings\\strxmov.c",
+               "..\\strings\\strxnmov.c"
+
+
+   group heap = "..\\heap\\hp_block.c", "..\\heap\\hp_clear.c",
+                "..\\heap\\hp_close.c", "..\\heap\\hp_create.c", "..\\heap\\hp_delete.c",
+                "..\\heap\\hp_extra.c", "..\\heap\\hp_hash.c",
+                "..\\heap\\hp_info.c", "..\\heap\\hp_open.c",
+                "..\\heap\\hp_panic.c", "..\\heap\\hp_rename.c",
+                "..\\heap\\hp_rfirst.c", "..\\heap\\hp_rkey.c",
+                "..\\heap\\hp_rlast.c", "..\\heap\\hp_rnext.c",
+                "..\\heap\\hp_rprev.c", "..\\heap\\hp_rrnd.c",
+                "..\\heap\\hp_rsame.c", "..\\heap\\hp_scan.c",
+                "..\\heap\\hp_static.c", "..\\heap\\hp_update.c",
+                "..\\heap\\hp_write.c", "..\\heap\\_check.c", "..\\heap\\_rectest.c"
+
+
+   group merge = "..\\merge\\close.c", "..\\merge\\create.c", "..\\merge\\delete.c",
+                 "..\\merge\\extra.c", "..\\merge\\info.c", "..\\merge\\open.c",
+                 "..\\merge\\panic.c", "..\\merge\\rrnd.c", "..\\merge\\rsame.c",
+                 "..\\merge\\static.c", "..\\merge\\update.c",
+                 "..\\merge\\_locking.c"
+
+
+   group myisammrg = "..\\myisammrg\\myrg_close.c",
+                     "..\\myisammrg\\myrg_create.c", "..\\myisammrg\\myrg_delete.c",
+                     "..\\myisammrg\\myrg_extra.c", "..\\myisammrg\\myrg_info.c",
+                     "..\\myisammrg\\myrg_locking.c",
+                     "..\\myisammrg\\myrg_open.c", "..\\myisammrg\\myrg_panic.c",
+                     "..\\myisammrg\\myrg_queue.c",
+                     "..\\myisammrg\\myrg_rfirst.c", "..\\myisammrg\\myrg_rkey.c",
+                     "..\\myisammrg\\myrg_rlast.c", "..\\myisammrg\\myrg_rnext.c",
+                     "..\\myisammrg\\myrg_rprev.c", "..\\myisammrg\\myrg_rrnd.c",
+                     "..\\myisammrg\\myrg_rsame.c",
+                     "..\\myisammrg\\myrg_static.c",
+                     "..\\myisammrg\\myrg_update.c"
+
+   group my_sys =  "..\\mysys\\array.c", "..\\mysys\\charset.c",
+                   "..\\mysys\\checksum.c", "..\\mysys\\default.c", "..\\mysys\\errors.c",
+                   "..\\mysys\\getopt.c", "..\\mysys\\getopt1.c",
+                   "..\\mysys\\getvar.c", "..\\mysys\\hash.c", "..\\mysys\\list.c",
+                   "..\\mysys\\mf_brkhant.c", "..\\mysys\\mf_cache.c",
+                   "..\\mysys\\mf_casecnv.c", "..\\mysys\\mf_dirname.c",
+                   "..\\mysys\\mf_fn_ext.c", "..\\mysys\\mf_format.c",
+                   "..\\mysys\\mf_getdate.c",
+                   "..\\mysys\\mf_iocache2.c", "..\\mysys\\mf_keycache.c",
+                   "..\\mysys\\mf_loadpath.c", "..\\mysys\\mf_pack.c",
+                   "..\\mysys\\mf_pack2.c", "..\\mysys\\mf_path.c",
+                   "..\\mysys\\mf_qsort2.c",
+                   //"..\\mysys\\mf_qsort.c",
+                   "..\\mysys\\mf_radix.c", "..\\mysys\\mf_same.c",
+                   "..\\mysys\\mf_sort.c", "..\\mysys\\mf_soundex.c",
+                   "..\\mysys\\mf_stripp.c", "..\\mysys\\mf_tempfile.c",
+                   "..\\mysys\\mf_unixpath.c", "..\\mysys\\mf_wcomp.c",
+                   "..\\mysys\\mf_wfile.c", "..\\mysys\\mulalloc.c",
+                   "..\\mysys\\my_alarm.c", "..\\mysys\\my_alloc.c",
+                   "..\\mysys\\my_append.c", "..\\mysys\\my_bitmap.c",
+                   "..\\mysys\\my_chsize.c", "..\\mysys\\my_clock.c",
+                   "..\\mysys\\my_compress.c", "..\\mysys\\my_copy.c",
+                   "..\\mysys\\my_create.c", "..\\mysys\\my_delete.c",
+                   "..\\mysys\\my_div.c", "..\\mysys\\my_error.c",
+                   "..\\mysys\\my_fopen.c", "..\\mysys\\my_fstream.c",
+                   "..\\mysys\\my_getwd.c", "..\\mysys\\my_init.c",
+                   "..\\mysys\\my_lib.c", "..\\mysys\\my_lock.c",
+                   "..\\mysys\\my_lockmem.c", "..\\mysys\\my_lread.c",
+                   "..\\mysys\\my_lwrite.c", "..\\mysys\\my_malloc.c",
+                   "..\\mysys\\my_messnc.c", "..\\mysys\\my_mkdir.c",
+                   "..\\mysys\\my_net.c", "..\\mysys\\my_once.c",
+                   "..\\mysys\\my_open.c",
+                   "..\\mysys\\my_os2cond.c",
+                   "..\\mysys\\my_os2dlfcn.c",
+                   "..\\mysys\\my_os2dirsrch.c",
+                   "..\\mysys\\my_os2mutex.c", "..\\mysys\\my_os2thread.c",
+                   "..\\mysys\\my_os2tls.c",
+                   "..\\mysys\\my_os2file64.c",
+                   "..\\mysys\\my_pread.c", "..\\mysys\\my_pthread.c",
+                   "..\\mysys\\my_quick.c", "..\\mysys\\my_read.c",
+                   "..\\mysys\\my_realloc.c", "..\\mysys\\my_redel.c",
+                   "..\\mysys\\my_rename.c", "..\\mysys\\my_seek.c",
+                   "..\\mysys\\my_static.c", "..\\mysys\\my_tempnam.c",
+                   "..\\mysys\\my_thr_init.c", "..\\mysys\\my_vsnprintf.c",
+                   "..\\mysys\\my_write.c", "..\\mysys\\ptr_cmp.c",
+                   "..\\mysys\\queues.c", "..\\mysys\\raid.cc",
+                   "..\\mysys\\safemalloc.c", "..\\mysys\\string.c",
+                   "..\\mysys\\thr_alarm.c",
+                   "..\\mysys\\thr_mutex.c", "..\\mysys\\thr_rwlock.c",
+                   "..\\mysys\\tree.c", "..\\mysys\\typelib.c"
+
+   group my_sys_cli = "..\\mysys\\mf_iocache.c"
+   group my_sys_sql = "..\\mysys\\thr_lock.c"
+
+   group myisam = "..\\myisam\\ft_parser.c",
+                  "..\\myisam\\ft_search.c", "..\\myisam\\ft_static.c",
+                  "..\\myisam\\ft_stopwords.c", "..\\myisam\\ft_update.c",
+                  "..\\myisam\\mi_cache.c", "..\\myisam\\mi_changed.c",
+                  "..\\myisam\\mi_check.c", "..\\myisam\\mi_checksum.c",
+                  "..\\myisam\\mi_close.c", "..\\myisam\\mi_create.c",
+                  "..\\myisam\\mi_dbug.c", "..\\myisam\\mi_delete.c",
+                  "..\\myisam\\mi_delete_all.c", "..\\myisam\\mi_delete_table.c",
+                  "..\\myisam\\mi_dynrec.c", "..\\myisam\\mi_extra.c",
+                  "..\\myisam\\mi_info.c", "..\\myisam\\mi_key.c",
+                  "..\\myisam\\mi_locking.c", "..\\myisam\\mi_log.c",
+                  "..\\myisam\\mi_open.c", "..\\myisam\\mi_packrec.c",
+                  "..\\myisam\\mi_page.c", "..\\myisam\\mi_panic.c",
+                  "..\\myisam\\mi_range.c", "..\\myisam\\mi_rename.c",
+                  "..\\myisam\\mi_rfirst.c", "..\\myisam\\mi_rkey.c",
+                  "..\\myisam\\mi_rlast.c", "..\\myisam\\mi_rnext.c",
+                  "..\\myisam\\mi_rnext_same.c", "..\\myisam\\mi_rprev.c",
+                  "..\\myisam\\mi_rrnd.c", "..\\myisam\\mi_rsame.c",
+                  "..\\myisam\\mi_rsamepos.c", "..\\myisam\\mi_scan.c",
+                  "..\\myisam\\mi_search.c", "..\\myisam\\mi_static.c",
+                  "..\\myisam\\mi_statrec.c", "..\\myisam\\mi_unique.c",
+                  "..\\myisam\\mi_update.c", "..\\myisam\\mi_write.c",
+                  "..\\myisam\\sort.c"
+
+   group dbug =   "..\\dbug\\dbug.c", "..\\dbug\\factorial.c", "..\\dbug\\sanity.c"
+
+   group readline = "..\\readline\\bind.c", "..\\readline\\callback.c",
+                          "..\\readline\\complete.c", "..\\readline\\display.c",
+                          //"..\\readline\\emacs_keymap.c",
+                          "..\\readline\\funmap.c", "..\\readline\\histexpand.c",
+                          "..\\readline\\histfile.c", "..\\readline\\history.c",
+                          "..\\readline\\histsearch.c", "..\\readline\\input.c",
+                          "..\\readline\\isearch.c", "..\\readline\\keymaps.c",
+                          "..\\readline\\kill.c", "..\\readline\\macro.c",
+                          "..\\readline\\nls.c", "..\\readline\\parens.c",
+                          "..\\readline\\readline.c", "..\\readline\\rltty.c",
+                          "..\\readline\\search.c", "..\\readline\\shell.c",
+                          "..\\readline\\signals.c", "..\\readline\\terminal.c",
+                          "..\\readline\\tilde.c", "..\\readline\\undo.c",
+                          "..\\readline\\util.c",
+                          //"..\\readline\\vi_keymap.c",
+                          "..\\readline\\vi_mode.c", "..\\readline\\xmalloc.c"
+
+group regex =     "..\\regex\\regcomp.c", "..\\regex\\regerror.c",
+                  "..\\regex\\regexec.c", "..\\regex\\regfree.c", "..\\regex\\reginit.c"
+
diff --git a/os2/MySQL-Sql.icc b/os2/MySQL-Sql.icc
new file mode 100644
index 00000000000..0c3fc69d68c
--- /dev/null
+++ b/os2/MySQL-Sql.icc
@@ -0,0 +1,117 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+                        , define( "MYSQL_SERVER", "")
+{
+
+   option file(genobject, "..\\OBJ\\ZLIB\\")
+   {
+      target "..\\bin\\mysqld.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            //source type('cpp') gpch
+            source type('cpp') 'os2.h'
+            source type('cpp')
+               //'ctype.h',
+               'string.h', 'assert.h', 'share.h', 'stdarg.h', 'stdio.h',
+               'stdlib.h', 'stddef.h', 'math.h', 'io.h', 'limits.h',
+               'process.h', 'errno.h', 'nerrno.h', 'sys/types.h',
+               'sys/time.h', 'sys/stat.h', 'sys/param.h', 'sys/ioccom.h',
+               'sys/filio.h', 'sys/sockio.h', 'sys/ioctlos2.h','sys/ioctl.h', 'types.h'
+
+            source type('cpp')
+               'global.h', 'my_base.h', 'config-os2.h',
+               'my_dir.h', 'my_sys.h', 'mysql.h',
+               'my_bitmap.h', 'violite.h', 'mysql_priv.h',
+               'm_string.h', 'm_ctype.h'
+
+            source type('cpp') 'myisam.h'
+            source type('cpp') 'myisampack.h'
+            source type('cpp') '.\myisam\myisamdef.h'
+
+            source type('cpp') 'sql_string.h'
+            source type('cpp') 'item.h'
+            source type('cpp') 'unireg.h'
+            source type('cpp') 'field.h'
+            source type('cpp') 'sql_lex.h'
+            source type('cpp') 'sql_list.h'
+            source type('cpp') 'md5.h'
+            source type('cpp') 'sql_acl.h'
+            source type('cpp') 'slave.h'
+            source type('cpp') 'ha_myisam.h'
+            source type('cpp') 'procedure.h'
+            source type('cpp') 'sql_select.h'
+            source type('cpp') 'errmsg.h'
+            source type('cpp') 't_ctype.h'
+            source type('cpp') 'direct.h'
+            source type('cpp') 'mysys_err.h'
+            source type('cpp') 'zconf.h'
+            source type('cpp') 'zlib.h'
+            source type('cpp') 'my_tree.h'
+            source type('cpp') '..\mysys\my_static.h'
+            source type('cpp') 'netdb.h'
+            source type('cpp') 'thr_alarm.h'
+            source type('cpp') 'heap.h'
+            source type('cpp') '..\myisam\fulltext.h'
+            source type('cpp') '..\myisam\ftdefs.h'
+            source type('cpp') 'myisammrg.h'
+
+         }
+         source type('cpp') 'sys/un.h'
+         source type('cpp') 'ha_heap.h'
+         source type('cpp') 'ha_myisammrg.h'
+         source type('cpp') 'opt_ft.h'
+         source type('cpp') 'hash_filo.h'
+         source type('cpp') 'mini_client.h'
+         source type('cpp') 'sql_repl.h'
+         source type('cpp') 'netinet/in_systm.h'
+         source type('cpp') 'netinet/tcp.h'
+         source type('cpp') 'sql_analyse.h'
+         source type('cpp') 'item_create.h'
+         source type('cpp') '..\mysys\mysys_priv.h'
+         source type('cpp') 'sys/utime.h'
+         source type('cpp') 'sys/select.h'
+
+         // target source files
+         source "rint.obj"
+         source zlib, ufc, regex
+         if debug_build  {
+            source type('cpp') dbug
+         }
+         source type('cpp') heap
+         source type('cpp') isam
+         source type('cpp') merge
+         source type('cpp') myisam
+         source type('cpp') myisammrg
+         source type('cpp') my_sys
+         source type('cpp') my_sys_sql
+         source type('cpp') strings
+         source type('cpp') sql
+      }
+   }
+/*
+   option define( "MYSQL_SERVER", "")
+   {
+      target "..\\bin\\mysqlbinlog.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            //source type('cpp') client_pch //, 'sql_string.h'
+         }
+         // target source files
+         source type('cpp')
+                     "..\\sql\\mysqlbinlog.cc",
+                     "..\\sql\\mini_client.cc",
+                     "..\\sql\\net_serv.cc"
+      }
+   }
+*/
+}
diff --git a/os2/MySQL-Util.icc b/os2/MySQL-Util.icc
new file mode 100644
index 00000000000..61b1f53bc5f
--- /dev/null
+++ b/os2/MySQL-Util.icc
@@ -0,0 +1,134 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+                        , link(defaultlibsname, "common.lib")
+                        , link(defaultlibsname, "myisam.lib")
+                        , link(defaultlibsname, "isam.lib")
+                        , link(defaultlibsname, "mysql.lib")
+{
+
+      target "..\\bin\\myisamchk.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+         source type('cpp') "..\\myisam\\myisamchk.c"
+      }
+
+      target "..\\bin\\myisamlog.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+
+         // target source files
+         source type('cpp') "..\\myisam\\myisamlog.c"
+      }
+
+      target "..\\bin\\myisampack.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+         // target source files
+         source type('cpp') "..\\myisam\\myisampack.c"
+      }
+
+      target "..\\bin\\test\\is_test1.exe"
+      {
+         // target source files
+         source type('cpp') "..\\isam\\test1.c"
+      }
+      target "..\\bin\\test\\is_test2.exe"
+      {
+         // target source files
+         source type('cpp') "..\\isam\\test2.c"
+      }
+      target "..\\bin\\test\\mi_test1.exe"
+      {
+         // target source files
+         source type('cpp') "..\\myisam\\mi_test1.c"
+      }
+      target "..\\bin\\test\\mi_test2.exe"
+      {
+         // target source files
+         source type('cpp') "..\\myisam\\mi_test2.c"
+      }
+      target "..\\bin\\test\\ft_eval.exe"
+      {
+         // target source files
+         source type('cpp') "..\\myisam\\ft_eval.c"
+      }
+      target "..\\bin\\test\\ft_test1.exe"
+      {
+         // target source files
+         source type('cpp') "..\\myisam\\ft_test1.c"
+      }
+
+      //target "..\\bin\\test\\testhash.exe"
+      {
+         // target source files
+         //source type('cpp') "..\\mysys\\testhash.c"
+      }
+
+      target "..\\bin\\test\\test_charset.exe"
+      {
+         // target source files
+         source type('cpp') "..\\mysys\\test_charset.c"
+      }
+
+      target "..\\bin\\test\\hp_test1.exe"
+      {
+         // target source files
+         source type('cpp') "..\\heap\\hp_test1.c"
+      }
+      target "..\\bin\\test\\hp_test2.exe"
+      {
+         // target source files
+         source type('cpp') "..\\heap\\hp_test2.c"
+      }
+
+      option define( "MAIN", "")
+      {
+         target "..\\bin\\test\\thr_lock.exe"
+         {
+            // target source files
+            source type('cpp') "..\\mysys\\thr_lock.c"
+         }
+      }
+
+      target "..\\bin\\test\\insert_test.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+         source type('cpp') "..\\client\\insert_test.c"
+      }
+      target "..\\bin\\test\\select_test.exe"
+      {
+         source type('cpp') "..\\client\\select_test.c"
+      }
+      target "..\\bin\\test\\thread_test.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') client_pch
+         }
+         source type('cpp') "..\\client\\thread_test.c"
+      }
+
+}
diff --git a/os2/MySQL-Util.irs b/os2/MySQL-Util.irs
new file mode 100644
index 00000000000..01a1f62a483
--- /dev/null
+++ b/os2/MySQL-Util.irs
@@ -0,0 +1,3067 @@
+31 Run Specifications: Version 1.1
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamlog.exe
+1
+0
+0
+5 Local
+0
+44 E:\rd\mysql\vacpp-3.23.40\bin\myisampack.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\is_test1.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\is_test2.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\mi_test1.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\mi_test2.exe
+1
+0
+0
+5 Local
+0
+46 E:\rd\mysql\vacpp-3.23.40\bin\test\ft_eval.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\ft_test1.exe
+1
+0
+0
+5 Local
+0
+51 E:\rd\mysql\vacpp-3.23.40\bin\test\test_charset.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\hp_test1.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\hp_test2.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\thr_lock.exe
+1
+0
+0
+5 Local
+0
+50 E:\rd\mysql\vacpp-3.23.40\bin\test\insert_test.exe
+1
+0
+0
+5 Local
+0
+50 E:\rd\mysql\vacpp-3.23.40\bin\test\select_test.exe
+1
+0
+0
+5 Local
+0
+50 E:\rd\mysql\vacpp-3.23.40\bin\test\thread_test.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/MySQL-binlog.icc b/os2/MySQL-binlog.icc
new file mode 100644
index 00000000000..d441198f5e0
--- /dev/null
+++ b/os2/MySQL-binlog.icc
@@ -0,0 +1,68 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+                        , define( "MYSQL_SERVER", "")
+                        , link(defaultlibsname, "common.lib")
+                        , link(defaultlibsname, "myisam.lib")
+                        , link(defaultlibsname, "isam.lib")
+                        , link(defaultlibsname, "mysql.lib")
+{
+   option define( "MYSQL_SERVER", "")
+   {
+      target "..\\bin\\mysqlbinlog.exe"
+      {
+         // optimized precompiled headers
+         option macros('global', 'yes')
+         {
+            source type('cpp') 'os2.h'
+            source type('cpp') 'errno.h', 'nerrno.h'
+            source type('cpp') 'config-os2.h', 'mysql_com.h'
+/*
+            source type('cpp')
+               'global.h', 'my_base.h', 'config-os2.h',
+               'my_dir.h', 'my_sys.h', 'mysql.h',
+               'my_bitmap.h', 'violite.h',
+               'mysql_priv.h',
+               'm_string.h'
+*/
+         }
+         // target source files
+         source type('cpp')
+                     "..\\sql\\mysqlbinlog.cc"
+         option macros('global', 'yes')
+         {
+            source type('cpp') 'sys/stat.h'
+         }
+         source type('cpp') "..\\sql\\mini_client.cc"
+         option macros('global', 'yes')
+         {
+            source type('cpp') 'os2.h'
+            source type('cpp') 'math.h'
+            source type('cpp') 'stdio.h'
+            source type('cpp') 'stdlib.h'
+            source type('cpp') 'stddef.h'
+            source type('cpp') 'limits.h'
+            source type('cpp') 'sys/types.h'
+            source type('cpp') 'sys/time.h'
+            source type('cpp') 'types.h'
+            source type('cpp') 'stdarg.h'
+            source type('cpp') 'string.h'
+         }
+         source type('cpp') "..\\sql\\net_serv.cc",
+                            "..\\sql\\mini_client_errors.c"
+                            option macros('global', 'yes')
+                            {
+                               source type('cpp') 'assert.h'
+                            }
+                            source type('cpp') "..\\sql\\violite.c",
+                            "..\\sql\\password.c"
+                            //"..\\sql\\thr_malloc.cc"
+      }
+   }
+
+}
diff --git a/os2/MySQL-binlog.irs b/os2/MySQL-binlog.irs
new file mode 100644
index 00000000000..8d094544f1c
--- /dev/null
+++ b/os2/MySQL-binlog.irs
@@ -0,0 +1,7 @@
+31 Run Specifications: Version 1.1
+45 E:\rd\mysql\vacpp-3.23.40\bin\mysqlbinlog.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/MySQL-sql.irs b/os2/MySQL-sql.irs
new file mode 100644
index 00000000000..dc0b016d8d4
--- /dev/null
+++ b/os2/MySQL-sql.irs
@@ -0,0 +1,13 @@
+31 Run Specifications: Version 1.1
+40 E:\rd\mysql\vacpp-3.23.40\bin\mysqld.exe
+1
+0
+0
+5 Local
+0
+40 E:\rd\mysql\vacpp-3.23.40\bin\mysqld.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/build-all.cmd b/os2/build-all.cmd
new file mode 100644
index 00000000000..9cb9ef6ea44
--- /dev/null
+++ b/os2/build-all.cmd
@@ -0,0 +1,11 @@
+
+mkdir ..\bin
+mkdir ..\bin\test
+mkdir ..\lib
+mkdir ..\obj
+mkdir ..\obj\zlib
+
+vacbld MySQL-Lib.icc -showprogress=10 -showwarning >> build-all.log
+vacbld MySQL-Client.icc -showprogress=10 -showwarning >> build-all.log
+vacbld MySQL-Sql.icc -showprogress=10 -showwarning >> build-all.log
+vacbld MySQL-Util.icc -showprogress=10 -showwarning >> build-all.log
diff --git a/os2/build-all.log b/os2/build-all.log
new file mode 100644
index 00000000000..a5a64db316f
--- /dev/null
+++ b/os2/build-all.log
@@ -0,0 +1,39 @@
+Item 237 of 47475 (0%) ... source file ..\mysys\list.c
+Item 4357 of 29226 (15%) ... source region "extern int          _Optlink  _spawnve(int, const char *, const char ..."
+Item 10021 of 16290 (62%) ... initializer [0x7319920] for uchar to_upper_latin1[]
+Item 11487 of 15248 (75%) ... kernel-provided extension source file \rd\mysql\zlib-1.1.3\crc32.c
+Item 12920 of 15380 (84%) ... body of function [0x6dca980] int my_strcoll_czech(const uchar *, const uchar *)
+Item 13952 of 16411 (85%) ... output object file E:\rd\mysql\vacpp-3.23.33\os2\ft_search.obj
+Item 14083 of 16542 (85%) ... publish library or executable marker
+Item 1278 of 16668 (8%) ... source region "typedef STARTDATA *PSTARTDATA;"
+Item 6013 of 8617 (70%) ... kernel-provided extension source file \rd\mysql\zlib-1.1.3\trees.c
+Item 6962 of 8581 (81%) ... initializer [0x229bf00] for const char @485 (static target)[23] "Failed in mysql_init()"
+Item 7519 of 9019 (83%) ... initializer [0x2337bc0] for const char @630 (static target)[20] "No query specified
+"
+Item 8502 of 10001 (85%) ... publish library or executable marker
+Item 182 of 49201 (0%) ... source file ..\myisam\mi_statrec.c
+Item 2136 of 46089 (5%) ... source region "class Item_sum_udf_float :public Item_udf_sum {  public:   Item_sum_udf_float ..."
+Item 11112 of 25912 (43%) ... source region "extern uint _nisam_get_key(N_KEYDEF *keyinfo ..."
+Item 13919 of 24304 (57%) ... initializer [0x1ec6f10] for const short yypgoto[]
+Item 15179 of 23800 (64%) ... kernel-provided extension source file \rd\mysql\zlib-1.1.3\trees.c
+Item 17342 of 24056 (72%) ... initializer [0x29d1180] for __vftType __vft10Field_date5Field[46]
+Item 17912 of 24406 (73%) ... body of function [0x1d1df40] void Item_func_case::print(String *)
+Item 18247 of 24721 (74%) ... template instantiation  (0x2b9dd20) of declaration of class I_List<thread_info> (2b9dc20)
+Item 18775 of 25165 (75%) ... initializer [0x2c45600] for __vftType __vft18Item_func_get_lock4Item[34]
+Item 19066 of 25369 (75%) ... initializer [0x2c800d0] for const char @2105 (static target)[22] "parser stack overflow"
+Item 19395 of 25535 (76%) ... body of function [0x171eef0] db_type ha_checktype(db_type)
+Item 19682 of 25654 (77%) ... body of function [0x17f1860] void kill_mysql()
+Item 20070 of 25717 (78%) ... body of function [0x183e570] Item *create_func_date_format(Item *, Item *)
+Item 20541 of 25764 (80%) ... body of function [0x1802b40] uint acl_get(const char *, const char *, const char *, const char *, const char *)
+Item 21017 of 25874 (81%) ... body of function [0x2c55180] String *field_str::get_max_arg(String *)
+Item 21406 of 25988 (82%) ... initializer [0x372d950] for const char @2567 (static target)[7] "%s(%d)"
+Item 22411 of 25867 (87%) ... body of function [0x161b160] Item_func_udf_int::Item_func_udf_int(udf_func *)
+Item 23345 of 25805 (90%) ... initializer [0x3447840] for const char @2709 (static target)[27] "waiting for handler insert"
+Item 23783 of 26226 (91%) ... initializer [0x39a95b0] for const char @2766 (static target)[25] "Creating delayed handler"
+Item 24887 of 27330 (91%) ... body of function [0x2b075a0] Item_load_file::~Item_load_file()
+Item 25018 of 27461 (91%) ... body of function [0x2cf5e50] Item_sum::Item_sum()
+Item 25267 of 27710 (91%) ... body of function [0x1c93d80] bool select_export::send_data(List<Item> &)
+Item 25484 of 27927 (91%) ... body of function [0x116e840] Item *create_func_ascii(Item *)
+Item 3212 of 9073 (35%) ... source region "extern int _mi_cmp_static_record(MI_INFO *info,const byte ..."
+Item 7171 of 8564 (84%) ... code csect _test_handle from library E:\bin\IBMCPP40\LIB\CPPRMS40.LIB
+Item 8345 of 9738 (86%) ... target E:\rd\mysql\vacpp-3.23.33\os2\..\bin\test\testhash.exe
diff --git a/os2/mysql.base b/os2/mysql.base
new file mode 100644
index 00000000000..4f0886e0697
--- /dev/null
+++ b/os2/mysql.base
@@ -0,0 +1,127 @@
+#include "mysql.ih"
+
+<WARPIN VERSION <$WARPIN_VERSION>>
+<HEAD>
+
+<PCK INDEX=1 
+     PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\SQL Database Engine\<$MySQL\Ver>"
+     TARGET="?:\usr\local\mysql" BASE
+     TITLE="SQL Database Engine"
+     EXECUTE="$(1)\bootstrap.cmd [bootstrap]"
+     CONFIG.SYS="SET EMXOPT=-h1024 | UNIQUE(-h)"
+     CREATEOBJECT="WPFolder|MySQL <$MySQL.Ver>|<WP_DESKTOP>|OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>"
+     CREATEOBJECT="WPProgram|Console|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(1)\bin\mysql.exe;STARTUPDIR=$(1)\bin;ICONFILE=$(1)\bin\icons\mysql-client.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_CONSOLE>;"
+     CREATEOBJECT="WPProgram|Start server|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(1)\bin\mysqld.exe;ICONFILE=$(1)\bin\icons\mysql-startserver.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_START>;"
+     CREATEOBJECT="WPProgram|Shutdown server|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(1)\bin\mysqladmin.exe;STARTUPDIR=$(1)\bin;PARAMETERS=-u root shutdown;ICONFILE=$(1)\bin\icons\mysql-shutdownserver.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_SHUTDOWN>;"
+     CREATEOBJECT="WPProgram|Readme first|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=e.exe;PARAMETERS=$(1)\readme.os2;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_README>;"
+     SELECT
+     >This package will install MySQL for OS/2 SQL engine
+</PCK>
+
+<PCK INDEX=2
+     PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\Developement Kit\<$MySQL\Ver>"
+     TARGET="?:\usr\local\mysql"
+     TITLE="Developement Kit"
+     SELECT
+     >This package will install MySQL for OS/2 sdk
+</PCK>
+
+<PCK INDEX=3
+     PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\PDF manual\<$MySQL\Ver>"
+     TARGET="?:\usr\local\mysql"
+     TITLE="PDF manual"
+     EXTERNAL="mysql-3-23-28-gamma-pdf.wpi"
+     CREATEOBJECT="WPShadow|PDF Manual|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|SHADOWID=$(1)\docs\manual.pdf"
+     SELECT
+     >This package will install MySQL for OS/2 documentation
+</PCK>
+
+<PCK INDEX=4
+     PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\INF manual\<$MySQL\Ver>"
+     TARGET="?:\usr\local\mysql"
+     TITLE="INF manual"
+     EXTERNAL="mysql-3-23-28-gamma-inf.wpi"
+     CREATEOBJECT="WPProgram|MySQL Manual|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=view.exe;PARAMETERS=$(1)\docs\manual.inf;ICONFILE=$(1)\bin\icons\mysql-manual.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_INFMANUAL>;"
+     SELECT
+     >This package will install MySQL for OS/2 documentation
+</PCK>
+
+<PCK INDEX=5
+     PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\Test suite\<$MySQL\Ver>"
+     TARGET="?:\usr\local\mysql"
+     TITLE="Test suite"
+     EXTERNAL="mysql-<$MySQL-Ver>-test.wpi"
+     CREATEOBJECT="WPProgram|Run MySQL Test Suite|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(5)\mysql-test\mysql-test.cmd;PARAMETERS=$(1)\docs\manual.inf;ICONFILE=$(1)\bin\icons\mysql-manual.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_TESTSUITE>;"
+     SELECT
+     >This package will install MySQL for OS/2 test suite
+</PCK>
+
+</HEAD>
+
+<!-- Here come the different pages. They are linked by
+     the <NEXTBUTTON> tags, which must have a target.
+     Each page must have a TYPE= attribute, which tells
+     WarpIn what will be visible on that page. -->
+
+<BODY>
+
+<!-- page1: introduction ->>
+<PAGE INDEX=1 TYPE=README>
+<TEXT>
+</TEXT>
+<NEXTBUTTON TARGET=2>~Next</NEXTBUTTON>
+<README FORMAT=HTML>
+
+<P>Welcome to the latest port of MySQL for <B>OS/2 and eComStation</B>.
+
+<P>You are about to install <B>MySQL <$MySQL.Ver></B>
+
+<BR>
+<BR>
+<P>Select "Next" to continue.
+
+<P>Select "Cancel" to abort installation.
+</README>
+</PAGE>
+
+<!-- show readme.os2 -->
+<PAGE INDEX=2 TYPE=README>
+<NEXTBUTTON TARGET=3>~Next</NEXTBUTTON>
+<TEXT>
+</TEXT>
+<README FORMAT=PLAIN EXTRACTFROMPCK="1">readme.os2</README>
+</PAGE>
+
+<!-- show GPL license -->
+<PAGE INDEX=3 TYPE=README>
+<NEXTBUTTON TARGET=4>~I agree</NEXTBUTTON>
+<TEXT>
+By pressing the "I agree" button, you agree to all terms and conditions to the below licence agreement.
+</TEXT>
+<README FORMAT=HTML EXTRACTFROMPCK="1">license.htm</README>
+</PAGE>
+
+
+<!-- The TYPE=CONTAINER will list the packages which can be installed. -->
+
+<PAGE INDEX=4 TYPE=CONTAINER>
+<NEXTBUTTON TARGET=5>~Next</NEXTBUTTON>
+<TEXT>
+Please select the packages which are to be installed. You may change the target paths for the packages.
+</TEXT>
+</PAGE>
+
+<!-- Here's another TYPE=TEXT page before we install.
+     The special target "0" indicates that after this page we
+     should start installation.
+     Note that the TYPE=INSTALL page (which we had in Alpha #3)
+     is no longer supported. -->
+
+<PAGE INDEX=5 TYPE=TEXT>
+<NEXTBUTTON TARGET=0>I~nstall</NEXTBUTTON>
+<TEXT>
+Press "Install" to begin installing this archive.</TEXT>
+</PAGE>
+
+</BODY>
+</WARPIN>
diff --git a/os2/mysql.ih b/os2/mysql.ih
new file mode 100644
index 00000000000..71978c4135a
--- /dev/null
+++ b/os2/mysql.ih
@@ -0,0 +1,7 @@
+#define WARPIN_VERSION "0.9.12" 
+#define MySQL.Major 3 
+#define MySQL.Minor 23 
+#define MySQL.Rev 40 
+#define MySQL\VER 3\23\40 
+#define MySQL.VER 3.23.40 
+#define MySQL-VER 3-23-40 
diff --git a/os2/readme.os2 b/os2/readme.os2
new file mode 100644
index 00000000000..9936dd15369
--- /dev/null
+++ b/os2/readme.os2
@@ -0,0 +1,190 @@
+MySQL 3.23.40 for OS/2 Warp build 1 
+====================================================
+
+Contents
+--------
+Welcome to the latest port of MySQL for OS/2 and eComStation.
+
+Modules included in this build:
+	- protocol data compression
+	- transaction support
+	- perl BDB/BDI support (not in this package)
+	- Library and header files for C/CPP developers included
+
+This package has been built using IBM VAC++ 4.0
+
+The MySQL server is distributed under the GPL license. Please refer to
+the file COPYING for the license information.
+
+The MySQL client library is distributed under the LGPL license.
+Please refer to the file COPYING for the license information.
+
+Most of the MySQL clients are distributed under the GPL license, but
+some files may be in the public domain.
+
+The latest information about MySQL can be found at: http://www.mysql.com
+
+To get the latest information about this port please subscribe to our
+newsgroup/mailinglist mysql2 at www.egroups.com.
+
+To see what MySQL can do, take a look at the features section in the
+manual. For future plans see the TODO appendix in the manual.
+
+New features/bug fixes history is in the news appendix in the manual.
+
+For the currently known bugs/misfeatures (known errors) see the bugs
+appendix in the manual.  The OS/2 section contains notes that are
+specific to the MySQL OS/2 and eComStation version.
+
+Please note that MySQL is a constantly moving target. New builds for
+Linux are made available every week. This port may therefore be a few
+minor versions after the latest Linux/Win32 builds but its generally
+more stable than the "latest and greates" port.
+
+MySQL is brought to you by: TcX DataKonsult AB & MySQL Finland AB
+
+This port is brought to you by:
+
+Yuri Dario <mc6530@mclink.it>, development, porting
+Timo Maier <tam@gmx.de>, documentation, testing
+John M Alfredsson <jma@jmast.se>, documentation, testing
+
+
+Installation
+------------
+Prerequisite:
+
+- OS/2 Warp 3 with FP ?? or later, 
+  OS/2 Warp 4 with FP ?? or later,
+  OS/2 Warp Server for e-Business,
+  eComStation 1.0 (prev 1/2 OK)
+- TCPIP 4.x installed (requires 32-bit tcpip stack)
+- WarpIN installer 0.9.12 (ftp://ftp.os2.org/xworkplace/warpin-0-9-12.zip)
+
+Note: probably some fixpak level is required on both Warp3&Warp4 to
+      support >2GB file sizes.
+
+Save the installation archives into a temporary folder and double click 
+on the main package; otherwise you can drop the mysql package in your 
+WarpIN object or type 
+
+	WARPIN MYSQL-3-23-??-B1.WPI 
+
+from the command line.
+The configuration file for MySQL is named my.cnf and it is placed into
+your %ETC% directory. Usually it located into the boot driver under
+
+	x:\MPTN\ETC
+
+If the installation detect an existing configuration file, this will be
+renamed to my.cnf.bak; your current settings aren't migrated to current 
+installation. This file is not deleted by uninstall process.
+Startup options for MySQL daemon could be added there.
+
+As default, client connections uses data compression: if you don't like it,
+remove the following from your %ETC%\my.cnf
+
+	[client]
+	compress
+
+The server switches automatically compression mode on client request.
+
+SMP systems: while my developement system is a SMP one, and here MySQL seems
+to run fine with two processors enabled, keep in mind that both EMX runtime
+and current thread model are not SMP safe.
+
+This release comes with DLL client library MYSQL.DLL: it is installed by
+default into mysql\bin together with client applications. Copy it to your
+x:\OS2\DLL or another directory in your LIBPATH to run command line 
+utilities from every place.
+
+
+Documentation
+-------------
+Documentation is provided in separate files. You can use either
+the PDF documentation (requires Adobe Acrobat Reader) or the
+INF documentation (requires OS/2 view or NewView).
+
+The PDF documentation is found in MYSQL-3-23-28-PDF.WPI and 
+the INF documentation is found in MYSQL-3-23-28-INF.WPI
+
+The latest documentation can always be downloaded from 
+http://www.mysql.com. However this documentation may
+no fully apply to this port.
+The INF documentation could contain errors because of semi-automatic
+translation from texi original. 
+
+Support
+-------
+Since MySQL is a OpenSource freeware product there are no
+formal support options available.
+
+Please subscribe to mysql2 at www.egroups.com to get in contact
+with other users using this port.
+
+http://www.egroups.com/group/mysql2
+
+This newsgroup/mailinglist is the official "home" of this port.
+
+
+Know problems
+-------------
+alter_table.test and show_check are failing, reporting a different status 
+message: actually seems only a different text, no bugs in table checking.
+
+
+Apache/2 + PHP
+--------------
+To avoid problems with different socket when you use PHP and Apache
+webserver, get the PHP4 module from the Apache Server for OS/2 homepage
+http://silk.apana.org.au/apache/ 
+
+
+Developing MySQL
+----------------
+If you want to help us develop MySQL for OS2/eComStation please join
+the mysql2 mailinglist at www.egroups.com and ask for help to set up 
+your environment!
+
+All questions that are specific to the OS2/eComStation version should 
+be posted to this list!  Please remember to include all relevant
+information that may help solve your problem.
+
+
+Building MySQL (EMX)
+--------------------
+NOTE: these instructions are outdated
+
+db-3.2.x: before compiling MySQL, you need to setup Berkeley DB. Untar
+the distribution, enter dist directory and run
+
+attrib -r * /s
+sh -c s_config
+
+to create proper aclocal macros and configure headers.
+
+In the src directory you will find patches used to build this release
+of MySQL.
+You can run 'sh -c config.status' to create current makefiles without
+running autoconf & configure.
+
+apply previous patches 		(if not already included)
+sh -c autoconf			(upgrade scripts)
+sh -c configure.os2		(config system)
+edit config.status: 
+	s%@MYSQL_UNIX_ADDR@%\\socket\\MySQL%g
+	s%@LN_CP_F@%cp.exe%g
+	replace -O2 -m486 with -mpentiumpro
+sh -c config.status		(upgrade makefiles again)
+edit libmysql\Makefile
+	remove all occurences of -Zexe
+	replace libmysqlclient with libmysql (case sensitive search)
+edit client\Makefile
+	replace libmysqlclient with libmysql (case sensitive search)
+make
+
+After config.status, you have to edit include\mysql_version.h and correct
+the socket definition (\\socket\\MySQL is correct).
+If you go with configure, you have to change LN_CP_F macro from 'ln -s' to
+'cp' and correct all makefiles (sh -c config.status will do it).
+
diff --git a/os2/rint.cmd b/os2/rint.cmd
new file mode 100644
index 00000000000..522eff166bf
--- /dev/null
+++ b/os2/rint.cmd
@@ -0,0 +1,4 @@
+REM  -DLONG_DOUBLE
+REM  -DFLOAT
+REM  none -> double
+gcc -Zomf -c -x assembler-with-cpp rint.s
diff --git a/os2/rint.obj b/os2/rint.obj
new file mode 100644
index 0000000000000000000000000000000000000000..41c766c66610a459109acd9042d18b23241ec597
GIT binary patch
literal 334
zcmZqRV&Evs%q!8$Ps;M>U}I=l$n4>>YgzyU16zn|M2N8wn~P(Jqp=aIQ*f}c5vPhu
zaHOx3zfUl`ib_aifNL;|v%iZg3rGz!Pz9Tds}oQGhyu#8xcNASu(`Mg`G*D+&tPX*
zsl&j;&e#NEF)%Q5Fs^~HSU4G1fmq@UtXzx}A!2OYjLT**G4MppVq@U_&-|Y$U;+;V
zBO_}($gK<v42~Tv3=WGJCoV8xU}Ruue#4S>vqps>t=k1isQ&+)*6E_cly);mh3T$~
z3dhYqASOfe5thRfChS`v%D}?FAmG5rq5uR8JZek~BCHqLeHU;sun01+3Ia`M(4Nb|
i;KC@tc!H^C{ZthOkR1>p3S$6ikRUwln7Wx57>WUyS55%{

literal 0
HcmV?d00001

diff --git a/os2/rint.s b/os2/rint.s
new file mode 100644
index 00000000000..7f6569ed72c
--- /dev/null
+++ b/os2/rint.s
@@ -0,0 +1,32 @@
+/ rint.s (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
+
+#include <emx/asm386.h>
+
+#define FUNC    MATHSUFFIX2(rint)
+
+        .globl  LABEL(FUNC)
+
+        .text
+
+        ALIGN
+
+/ double _rint (double x)
+
+#define cw1       0(%esp)
+#define cw2       2(%esp)
+/define ret_addr  4(%esp)
+#define x         8(%esp)
+
+LABEL(FUNC):
+        PROFILE_NOFRAME
+        subl    $4, %esp
+        fstcww  cw1
+        movw    cw1, %ax
+        andw    $0xf3ff, %ax            /* round to nearest or even */
+        movw    %ax, cw2
+        fldcww  cw2
+        FLD     x                       /* x */
+        frndint
+        fldcww  cw1
+        addl    $4, %esp
+        EPILOGUE(FUNC)
diff --git a/sql/field.cc b/sql/field.cc
index 894ef2ab013..01178efbdb1 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2295,7 +2295,7 @@ void Field_timestamp::store(longlong nr)
   }
   else
 #endif
-    longstore(ptr,timestamp);
+    longstore(ptr,(ulong)timestamp);
 }
 
 
diff --git a/sql/field.h b/sql/field.h
index ee18d2fa7ae..fc0bfdc75d5 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -38,8 +38,8 @@ public:
   static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */
 
   enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
-	       CHECK,EMPTY,UNKNOWN,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,BIT_FIELD,
-	       TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD};
+	       CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,
+	       BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD};
   char	*ptr;				// Position to field in record
   uchar		*null_ptr;		// Byte where null_bit is
   uint8		null_bit;		// And position to it
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 6bb43ec2970..5eee5c6163a 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -472,7 +472,7 @@ int main(int argc,char **argv)
   int error;
 
   MY_INIT(argv[0]);
-  start_value=8214901L;  best_t1=4099790L;  best_t2=2406115L;  best_type=4; /* mode=4799  add=2  type: 0 */
+  start_value=487844L;  best_t1=4969454L;  best_t2=2266538L;  best_type=2; /* mode=4567  add=5  type: 0 */
   if (get_options(argc,(char **) argv))
     exit(1);
 
diff --git a/sql/hostname.cc b/sql/hostname.cc
index fed9e60b574..bc812341337 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -26,7 +26,7 @@
 #ifdef	__cplusplus
 extern "C" {					// Because of SCO 3.2V4.2
 #endif
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
 #include <sys/resource.h>
 #ifdef HAVE_SYS_UN_H
 #include <sys/un.h>
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ef3372629f6..989d7709513 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1489,8 +1489,14 @@ longlong Item_func_get_lock::val_int()
   thd->mysys_var->current_cond=  &ull->cond;
   pthread_mutex_unlock(&thd->mysys_var->mutex);
 
+#ifdef HAVE_TIMESPEC_TS_SEC
+  abstime.ts_sec=time((time_t*) 0)+(time_t) timeout;
+  abstime.ts_nsec=0;
+#else
   abstime.tv_sec=time((time_t*) 0)+(time_t) timeout;
   abstime.tv_nsec=0;
+#endif
+
   while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
 	 != ETIME && error != ETIMEDOUT && ull->locked)
   {
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 80f72c30e57..bd7fde79629 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1009,8 +1009,8 @@ String *Item_func_encrypt::val_str(String *str)
   if (arg_count == 1)
   {					// generate random salt
     time_t timestamp=current_thd->query_start();
-    salt[0] = bin_to_ascii(timestamp & 0x3f);
-    salt[1] = bin_to_ascii((timestamp >> 5) & 0x3f);
+    salt[0] = bin_to_ascii( (ulong) timestamp & 0x3f);
+    salt[1] = bin_to_ascii(( (ulong) timestamp >> 5) & 0x3f);
     salt[2] = 0;
     salt_ptr=salt;
   }
@@ -1103,7 +1103,7 @@ void Item_func_soundex::fix_length_and_dec()
     */
 
 extern "C" {
-extern char *soundex_map;		// In mysys/static.c
+extern const char *soundex_map;		// In mysys/static.c
 }
 
 static char get_scode(char *ptr)
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 1263d361b7f..41efa0f5658 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -55,7 +55,7 @@ int Log_event::write_header(IO_CACHE* file)
   // make sure to change this when the header gets bigger
   char buf[LOG_EVENT_HEADER_LEN];
   char* pos = buf;
-  int4store(pos, when); // timestamp
+  int4store(pos, (ulong) when); // timestamp
   pos += 4;
   *pos++ = get_type_code(); // event type code
   int4store(pos, server_id);
diff --git a/sql/md5.c b/sql/md5.c
index 0775ba3bd1a..4c2e80107b8 100644
--- a/sql/md5.c
+++ b/sql/md5.c
@@ -123,10 +123,10 @@ void MD5Init (MD5_CTX *context)      /* context */
   operation, processing another message block, and updating the
   context.
  */
-void MD5Update (context, input, inputLen)
-MD5_CTX *context;                                        /* context */
-unsigned char *input;                                /* input block */
-unsigned int inputLen;                     /* length of input block */
+void MD5Update (
+MD5_CTX *context,                                        /* context */
+unsigned char *input,                                /* input block */
+unsigned int inputLen)                     /* length of input block */
 {
   unsigned int i, idx, partLen;
 
@@ -164,9 +164,9 @@ unsigned int inputLen;                     /* length of input block */
 /* MD5 finalization. Ends an MD5 message-digest operation, writing the
   the message digest and zeroizing the context.
  */
-void MD5Final (digest, context)
-unsigned char digest[16];                         /* message digest */
-MD5_CTX *context;                                       /* context */
+void MD5Final (
+unsigned char digest[16],                         /* message digest */
+MD5_CTX *context)                                       /* context */
 {
   unsigned char bits[8];
   unsigned int idx, padLen;
@@ -193,9 +193,9 @@ MD5_CTX *context;                                       /* context */
 
 /* MD5 basic transformation. Transforms state based on block.
  */
-static void MD5Transform (state, block)
-UINT4 state[4];
-unsigned char block[64];
+static void MD5Transform (
+UINT4 state[4],
+unsigned char block[64])
 {
   UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
 
@@ -287,10 +287,10 @@ unsigned char block[64];
 /* Encodes input (UINT4) into output (unsigned char). Assumes len is
   a multiple of 4.
  */
-static void Encode (output, input, len)
-unsigned char *output;
-UINT4 *input;
-unsigned int len;
+static void Encode (
+unsigned char *output,
+UINT4 *input,
+unsigned int len)
 {
   unsigned int i, j;
 
@@ -306,10 +306,10 @@ unsigned int len;
 /* Decodes input (unsigned char) into output (UINT4). Assumes len is
   a multiple of 4.
  */
-static void Decode (output, input, len)
-UINT4 *output;
-unsigned char *input;
-unsigned int len;
+static void Decode (
+UINT4 *output,
+unsigned char *input,
+unsigned int len)
 {
   unsigned int i, j;
 
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 2886b6e02d2..88a02e227a3 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -82,6 +82,9 @@ static void mc_free_old_query(MYSQL *mysql);
 #if defined(MSDOS) || defined(__WIN__)
 #define ERRNO WSAGetLastError()
 #define perror(A)
+#elif defined(OS2)
+#define ERRNO sock_errno()
+#define SOCKET_ERROR -1
 #else
 #include <sys/errno.h>
 #define ERRNO errno
@@ -235,7 +238,7 @@ static void mc_free_old_query(MYSQL *mysql)
 static int mc_sock_connect(my_socket s, const struct sockaddr *name,
 			   uint namelen, uint to)
 {
-#if defined(__WIN__)
+#if defined(__WIN__) || defined(OS2)
   return connect(s, (struct sockaddr*) name, namelen);
 #else
   int flags, res, s_err;
@@ -330,18 +333,18 @@ mc_net_safe_read(MYSQL *mysql)
   {
     DBUG_PRINT("error",("Wrong connection or packet. fd: %s  len: %d",
 			vio_description(net->vio),len));
-    if(errno != EINTR)
+    if (socket_errno != EINTR)
+    {
+      mc_end_server(mysql);
+      if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
       {
-        mc_end_server(mysql);
-	if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
-	  {
-            net->last_errno=CR_SERVER_LOST;
-            strmov(net->last_error,ER(net->last_errno));
-	  }
-	else
-	  strmov(net->last_error, "Packet too large - increase \
+	net->last_errno=CR_SERVER_LOST;
+	strmov(net->last_error,ER(net->last_errno));
+      }
+      else
+	strmov(net->last_error, "Packet too large - increase \
 max_allowed_packet on this server");
-      }	
+    }	
     return(packet_error);
   }
   if (net->read_pos[0] == 255)
@@ -451,7 +454,7 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command,
   if (net_write_command(net,(uchar) command,arg,
 			length ? length :(uint) strlen(arg)))
   {
-    DBUG_PRINT("error",("Can't send command to server. Error: %d",errno));
+    DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno));
     mc_end_server(mysql);
     if (mc_mysql_reconnect(mysql) ||
 	net_write_command(net,(uchar) command,arg,
@@ -535,9 +538,9 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
     if (mc_sock_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
 			mysql->options.connect_timeout) <0)
     {
-      DBUG_PRINT("error",("Got error %d on connect to local server",ERRNO));
+      DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno));
       net->last_errno=CR_CONNECTION_ERROR;
-      sprintf(net->last_error,ER(net->last_errno),unix_socket,ERRNO);
+      sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno);
       goto error;
     }
   }
@@ -585,7 +588,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
     if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
     {
       net->last_errno=CR_IPSOCK_ERROR;
-      sprintf(net->last_error,ER(net->last_errno),ERRNO);
+      sprintf(net->last_error,ER(net->last_errno),socket_errno);
       goto error;
     }
     net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE);
@@ -622,7 +625,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
       if (!(hp=gethostbyname(host)))
       {
 	net->last_errno=CR_UNKNOWN_HOST;
-	sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, errno);
+	sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno);
 	goto error;
       }
       memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
@@ -630,11 +633,12 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
 #endif
     sock_addr.sin_port = (ushort) htons((ushort) port);
     if (mc_sock_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
-		 mysql->options.connect_timeout) <0)
+			mysql->options.connect_timeout) <0)
     {
-      DBUG_PRINT("error",("Got error %d on connect to '%s'",ERRNO,host));
+      DBUG_PRINT("error",("Got error %d on connect to '%s'",
+			  socket_errno,host));
       net->last_errno= CR_CONN_HOST_ERROR;
-      sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, ERRNO);
+      sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno);
       if (thr_alarm_in_use(&alarmed))
 	thr_end_alarm(&alarmed);
       goto error;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 19af3af8c68..06d0b1528f4 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -28,7 +28,9 @@
 #include <my_bitmap.h>
 #include <violite.h>
 
+#ifdef __EMX__
 #undef write  // remove pthread.h macro definition for EMX
+#endif
 
 typedef ulong table_map;		/* Used for table bits in join */
 typedef ulong key_map;			/* Used for finding keys */
@@ -110,7 +112,7 @@ void kill_one_thread(THD *thd, ulong id);
 #define FLUSH_TIME		0		/* Don't flush tables */
 #define MAX_CONNECT_ERRORS	10		// errors before disabling host
 
-#ifdef	__WIN__
+#if defined(__WIN__) || defined(OS2)
 #define IF_WIN(A,B) (A)
 #undef	FLUSH_TIME
 #define FLUSH_TIME	1800			/* Flush every half hour */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 57e65025c8f..35aeaecc6e1 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -57,7 +57,9 @@ extern "C" {					// Because of SCO 3.2V4.2
 #include <grp.h>
 #endif
 
-#ifndef __WIN__
+#if defined(OS2)
+#  include <sys/un.h>
+#elif !defined( __WIN__)
 #include <sys/resource.h>
 #ifdef HAVE_SYS_UN_H
 #  include <sys/un.h>
@@ -358,6 +360,10 @@ HANDLE hEventShutdown;
 static	 NTService  Service;	      // Service object for WinNT
 #endif
 
+#ifdef OS2
+pthread_cond_t eventShutdown;
+#endif
+
 static void start_signal_handler(void);
 static void *signal_hand(void *arg);
 static void set_options(void);
@@ -405,7 +411,7 @@ static void close_connections(void)
   (void) pthread_mutex_unlock(&LOCK_manager);
 
   /* kill connection thread */
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
   DBUG_PRINT("quit",("waiting for select thread: %lx",select_thread));
   (void) pthread_mutex_lock(&LOCK_thread_count);
 
@@ -576,6 +582,8 @@ void kill_mysql(void)
     // SetEvent(hEventShutdown);
     // CloseHandle(hEvent);
   }
+#elif defined(OS2)
+  pthread_cond_signal( &eventShutdown);		// post semaphore
 #elif defined(HAVE_PTHREAD_KILL)
   if (pthread_kill(signal_thread,MYSQL_KILL_SIGNAL))// End everything nicely
   {
@@ -592,7 +600,10 @@ void kill_mysql(void)
 
 	/* Force server down. kill all connections and threads and exit */
 
-#ifndef __WIN__
+#if defined(OS2)
+extern "C" void kill_server(int sig_ptr)
+#define RETURN_FROM_KILL_SERVER return
+#elif !defined(__WIN__)
 static void *kill_server(void *sig_ptr)
 #define RETURN_FROM_KILL_SERVER return 0
 #else
@@ -615,7 +626,7 @@ static void __cdecl kill_server(int sig_ptr)
   else
     sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
 
-#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__)
+#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)
   my_thread_init();				// If this is a new thread
 #endif
   close_connections();
@@ -623,7 +634,9 @@ static void __cdecl kill_server(int sig_ptr)
     unireg_abort(1);				/* purecov: inspected */
   else
     unireg_end(0);
+#ifndef OS2
   pthread_exit(0);				/* purecov: deadcode */
+#endif
   RETURN_FROM_KILL_SERVER;
 }
 
@@ -645,7 +658,7 @@ static sig_handler print_signal_warning(int sig)
 #ifdef DONT_REMEMBER_SIGNAL
   sigset(sig,print_signal_warning);		/* int. thread system calls */
 #endif
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
   if (sig == SIGALRM)
     alarm(2);					/* reschedule alarm */
 #endif
@@ -655,7 +668,9 @@ static sig_handler print_signal_warning(int sig)
 void unireg_end(int signal_number __attribute__((unused)))
 {
   clean_up();
+#ifndef OS2
   pthread_exit(0);				// Exit is in main thread
+#endif
 }
 
 
@@ -746,7 +761,7 @@ static void set_ports()
 
 static void set_user(const char *user)
 {
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
     struct passwd *ent;
 
   // don't bother if we aren't superuser
@@ -794,7 +809,7 @@ static void set_user(const char *user)
 
 static void set_root(const char *path)
 {
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
   if (chroot(path) == -1)
   {
     sql_perror("chroot");
@@ -853,7 +868,7 @@ static void server_init(void)
     }
     if (listen(ip_sock,(int) back_log) < 0)
       sql_print_error("Warning:  listen() on TCP/IP failed with error %d",
-		      errno);
+		      socket_errno);
   }
 
   if (mysqld_chroot)
@@ -940,7 +955,7 @@ static void server_init(void)
 #endif
     if (listen(unix_sock,(int) back_log) < 0)
       sql_print_error("Warning:  listen() on Unix socket failed with error %d",
-		      errno);
+		      socket_errno);
   }
 #endif
   DBUG_PRINT("info",("server started"));
@@ -1088,13 +1103,17 @@ static sig_handler abort_thread(int sig __attribute__((unused)))
 ** the signal thread is ready before continuing
 ******************************************************************************/
 
-#ifdef __WIN__
+#if defined(__WIN__) || defined(OS2)
 static void init_signals(void)
 {
   int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT } ;
   for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++)
     signal( signals[i], kill_server) ;
+#if defined(__WIN__)
   signal(SIGBREAK,SIG_IGN);	//ignore SIGBREAK for NT
+#else
+  signal(SIGBREAK, kill_server);
+#endif
 }
 
 static void start_signal_handler(void)
@@ -1473,6 +1492,29 @@ int __stdcall handle_kill(ulong ctrl_type)
 }
 #endif
 
+#ifdef OS2
+pthread_handler_decl(handle_shutdown,arg)
+{
+  my_thread_init();
+
+  // wait semaphore
+  pthread_cond_wait( &eventShutdown, NULL);
+
+  // close semaphore and kill server
+  pthread_cond_destroy( &eventShutdown);
+
+  // exit main loop on main thread, so kill will be done from
+  // main thread (this is thread 2)
+  abort_loop = 1;
+
+  // unblock select()
+  so_cancel( ip_sock);
+  so_cancel( unix_sock);
+
+  return 0;
+}
+#endif
+
 const char *load_default_groups[]= { "mysqld","server",0 };
 
 #ifdef HAVE_LIBWRAP
@@ -1558,7 +1600,7 @@ int main(int argc, char **argv)
   load_defaults("my",load_default_groups,&argc,&argv);
   defaults_argv=argv;
   mysql_tmpdir=getenv("TMPDIR");	/* Use this if possible */
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   if (!mysql_tmpdir)
     mysql_tmpdir=getenv("TEMP");
   if (!mysql_tmpdir)
@@ -1646,7 +1688,7 @@ int main(int argc, char **argv)
     my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
   pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
 
-#ifdef SET_RLIMIT_NOFILE
+#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
   /* connections and databases neads lots of files */
   {
     uint wanted_files=10+(uint) max(max_connections*5,
@@ -1854,6 +1896,14 @@ The server will not act as a slave.");
     Service.SetShutdownEvent(hEventShutdown);
   }
 #endif
+#ifdef OS2
+  {
+    pthread_cond_init( &eventShutdown, NULL);
+    pthread_t hThread;
+    if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
+      sql_print_error("Warning: Can't create thread to handle shutdown requests");
+  }
+#endif
 
   if (
 #ifdef HAVE_BERKELEY_DB
@@ -2192,7 +2242,9 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
   }
 #ifdef HAVE_SYS_UN_H
   FD_SET(unix_sock,&clientFDs);
+#ifdef HAVE_FCNTL
   socket_flags=fcntl(unix_sock, F_GETFL, 0);
+#endif
 #endif
 
   DBUG_PRINT("general",("Waiting for connections."));
@@ -2205,10 +2257,10 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
 #else
     if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
     {
-      if (errno != EINTR)
+      if (socket_errno != EINTR)
       {
 	if (!select_errors++ && !abort_loop)	/* purecov: inspected */
-	  sql_print_error("mysqld: Got error %d from select",errno); /* purecov: inspected */
+	  sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */
       }
       continue;
     }
@@ -2344,6 +2396,11 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
     create_new_thread(thd);
   }
 
+#ifdef OS2
+  // kill server must be invoked from thread 1!
+  kill_server(MYSQL_KILL_SIGNAL);
+#endif
+
 #ifdef __NT__
   pthread_mutex_lock(&LOCK_thread_count);
   handler_count--;
@@ -4385,6 +4442,29 @@ static uint set_maximum_open_files(uint max_file_limit)
 }
 #endif
 
+#ifdef OS2
+static uint set_maximum_open_files(uint max_file_limit)
+{
+   LONG     cbReqCount;
+   ULONG    cbCurMaxFH, cbCurMaxFH0;
+   APIRET   ulrc;
+
+   // get current limit
+   cbReqCount = 0;
+   DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0);
+
+   // set new limit
+   cbReqCount = max_file_limit - cbCurMaxFH0;
+   ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH);
+   if (ulrc) {
+      sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d",
+         cbCurMaxFH0);
+      cbCurMaxFH = cbCurMaxFH0;
+   }
+
+   return cbCurMaxFH;
+}
+#endif
 
 	/*
 	  Return a bitfield from a string of substrings separated by ','
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 4c4642034e1..ba0944a2516 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -50,7 +50,7 @@ ulong net_buffer_length=8192;	/* Default length. Enlarged if necessary */
 #if !defined(__WIN__) && !defined(MSDOS)
 #include <sys/socket.h>
 #else
-#undef MYSQL_SERVER			// Win32 can't handle interrupts
+#undef MYSQL_SERVER			/* Win32 can't handle interrupts */
 #endif
 #if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__)
 #include <netinet/in_systm.h>
@@ -68,9 +68,15 @@ void sql_print_error(const char *format,...);
 #define RETRY_COUNT mysqld_net_retry_count
 extern ulong mysqld_net_retry_count;
 #else
+
+#ifdef OS2				/* avoid name conflict */
+#define thr_alarm_t  thr_alarm_t_net
+#define ALARM        ALARM_net
+#endif
+
 typedef my_bool thr_alarm_t;
 typedef my_bool ALARM;
-#define thr_alarm_init(A) (*A)=0
+#define thr_alarm_init(A) (*(A))=0
 #define thr_alarm_in_use(A) (*(A))
 #define thr_end_alarm(A)
 #define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
@@ -124,7 +130,7 @@ int my_net_init(NET *net, Vio* vio)
   if (vio != 0)					/* If real connection */
   {
     net->fd  = vio_fd(vio);			/* For perl DBI/DBD */
-#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__)
+#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
     if (!(test_flags & TEST_BLOCKING))
       vio_blocking(vio, FALSE);
 #endif
@@ -271,7 +277,7 @@ net_real_write(NET *net,const char *packet,ulong len)
   int length;
   char *pos,*end;
   thr_alarm_t alarmed;
-#if !defined(__WIN__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
   ALARM alarm_buff;
 #endif
   uint retry_count=0;
@@ -329,7 +335,7 @@ net_real_write(NET *net,const char *packet,ulong len)
     if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
     {
       my_bool interrupted = vio_should_retry(net->vio);
-#if (!defined(__WIN__) && !defined(__EMX__))
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
       if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
       {
         if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
@@ -418,7 +424,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
   {
     if (!thr_alarm(alarmed,net->timeout,&alarm_buff) ||
 	(!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0))
-      return;					// Can't setup, abort
+      return;					/* Can't setup, abort */
   }
   while (remain > 0)
   {
@@ -448,7 +454,7 @@ my_real_read(NET *net, ulong *complen)
   uint i,retry_count=0;
   ulong len=packet_error;
   thr_alarm_t alarmed;
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
   ALARM alarm_buff;
 #endif
   my_bool net_blocking=vio_is_blocking(net->vio);
@@ -475,7 +481,7 @@ my_real_read(NET *net, ulong *complen)
 
 	  DBUG_PRINT("info",("vio_read returned %d,  errno: %d",
 			     length, vio_errno(net->vio)));
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
 	  /*
 	    We got an error that there was no data on the socket. We now set up
 	    an alarm to not 'read forever', change the socket to non blocking
diff --git a/sql/slave.cc b/sql/slave.cc
index 7cb9bdfd3fc..f6e8822ea14 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -703,7 +703,7 @@ static int init_slave_thread(THD* thd)
 
   thd->mysys_var=my_thread_var;
   thd->dbug_thread_id=my_thread_id();
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
   sigset_t set;
   VOID(sigemptyset(&set));			// Get mask in use
   VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index a38829f3605..d885d308770 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1401,7 +1401,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
   {
     int error;
 
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
     /* Win32 can't drop a file that is open */
     if (lock_type == TL_WRITE_ALLOW_READ
 #ifdef HAVE_GEMINI_DB
@@ -1411,7 +1411,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
     {
       lock_type= TL_WRITE;
     }
-#endif /* __WIN__ */
+#endif /* __WIN__ || OS2 */
 
     table_list->table=table;
     table->grant= table_list->grant;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 7cd892f6079..d0300b57bdb 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -338,7 +338,9 @@ bool mysql_change_db(THD *thd,const char *name)
   }
 
   (void) sprintf(path,"%s/%s",mysql_data_home,dbname);
-  unpack_dirname(path,path);			// Convert if not unix
+  length=unpack_dirname(path,path);		// Convert if not unix
+  if (length && path[length-1] == FN_LIBCHAR)
+    path[length-1]=0;				// remove ending '\'
   if (access(path,F_OK))
   {
     net_printf(&thd->net,ER_BAD_DB_ERROR,dbname);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 50e4a6dedd4..c14fbda3bc5 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -876,7 +876,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
   pthread_mutex_unlock(&LOCK_thread_count);
 
   pthread_mutex_lock(&di->mutex);
-#ifndef __WIN__	/* Win32 calls this in pthread_create */
+#if !defined( __WIN__) && !defined(OS2)	/* Win32 calls this in pthread_create */
   if (my_thread_init())
   {
     strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES));
@@ -895,7 +895,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
   }
   thd->mysys_var=my_thread_var;
   thd->dbug_thread_id=my_thread_id();
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
   sigset_t set;
   VOID(sigemptyset(&set));			// Get mask in use
   VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index ce8e34b9265..274b1814674 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -156,7 +156,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
     else
     {
       unpack_filename(name,ex->file_name);
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
       MY_STAT stat_info;
       if (!my_stat(name,&stat_info,MYF(MY_WME)))
 	DBUG_RETURN(-1);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 796b571722f..2e5333925e7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -62,9 +62,13 @@ extern VioSSLAcceptorFd* ssl_acceptor_fd;
 #ifdef __WIN__
 static void  test_signal(int sig_ptr)
 {
-#ifndef DBUG_OFF
+#if !defined( DBUG_OFF)
   MessageBox(NULL,"Test signal","DBUG",MB_OK);
 #endif
+#if defined(OS2)
+  fprintf( stderr, "Test signal %d\n", sig_ptr);
+  fflush( stderr);
+#endif
 }
 static void init_signals(void)
 {
@@ -477,7 +481,7 @@ pthread_handler_decl(handle_one_connection,arg)
 
   pthread_detach_this_thread();
 
-#ifndef __WIN__	/* Win32 calls this in pthread_create */
+#if !defined( __WIN__) && !defined(OS2)	/* Win32 calls this in pthread_create */
   if (my_thread_init()) // needed to be called first before we call
     // DBUG_ macros
   {
@@ -499,9 +503,9 @@ pthread_handler_decl(handle_one_connection,arg)
 		      thd->thread_id));
   // now that we've called my_thread_init(), it is safe to call DBUG_*
 
-#ifdef __WIN__
+#if defined(__WIN__)
   init_signals();				// IRENA; testing ?
-#else
+#elif !defined(OS2)
   sigset_t set;
   VOID(sigemptyset(&set));			// Get mask in use
   VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -602,7 +606,7 @@ pthread_handler_decl(handle_bootstrap,arg)
   thd->thread_stack= (char*) &thd;
   thd->mysys_var=my_thread_var;
   thd->dbug_thread_id=my_thread_id();
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
   sigset_t set;
   VOID(sigemptyset(&set));			// Get mask in use
   VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -940,7 +944,9 @@ bool do_command(THD *thd)
 #ifdef __WIN__
     sleep(1);					// must wait after eof()
 #endif
+#ifndef OS2
     send_eof(net);				// This is for 'quit request'
+#endif
     close_connection(net);
     close_thread_tables(thd);			// Free before kill
     free_root(&thd->mem_root,MYF(0));
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1728427370f..5c3d8def542 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1073,19 +1073,31 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
 
 int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
 {
+#ifdef OS2
+  thr_lock_type lock_type = TL_WRITE;
+#else
+  thr_lock_type lock_type = TL_READ_NO_INSERT;
+#endif
+
   DBUG_ENTER("mysql_analyze_table");
   DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
-				"analyze",TL_READ_NO_INSERT, 1,0,0,
+				"analyze", lock_type, 1,0,0,
 				&handler::analyze));
 }
 
 
 int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
 {
+#ifdef OS2
+  thr_lock_type lock_type = TL_WRITE;
+#else
+  thr_lock_type lock_type = TL_READ_NO_INSERT;
+#endif
+
   DBUG_ENTER("mysql_check_table");
   DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
-				"check",
-				TL_READ_NO_INSERT, 0, 0, HA_OPEN_FOR_REPAIR,
+				"check", lock_type,
+				0, 0, HA_OPEN_FOR_REPAIR,
 				&handler::check));
 }
 
@@ -1543,7 +1555,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
     }
   }
 
-#if defined( __WIN__) || defined( __EMX__)
+#if defined( __WIN__) || defined( __EMX__) || defined( OS2)
   // Win32 can't rename an open table, so we must close the org table!
   table_name=thd->strdup(table_name);		// must be saved
   if (close_cached_table(thd,table))
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 2ba937be50a..8184ae3b15e 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -53,7 +53,7 @@ extern "C"
     FreeLibrary((HMODULE)lib);
   }
   
-#else
+#elif !defined(OS2)
 #include <dlfcn.h>
 #endif
   
diff --git a/sql/violite.c b/sql/violite.c
index 902110ff072..aff4224e5a3 100644
--- a/sql/violite.c
+++ b/sql/violite.c
@@ -39,7 +39,7 @@
 #include <sys/ioctl.h>
 #endif
 
-#if defined(__EMX__)
+#if defined(__EMX__) || defined(OS2)
 #define ioctlsocket ioctl
 #endif	/* defined(__EMX__) */
 
@@ -105,7 +105,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
     sprintf(vio->desc,
 	    (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
 	    vio->sd);
-#if !defined(___WIN__) && !defined(__EMX__)
+#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
 #if !defined(NO_FCNTL_NONBLOCK)
     vio->fcntl_mode = fcntl(sd, F_GETFL);
 #elif defined(HAVE_SYS_IOCTL_H)			/* hpux */
@@ -116,7 +116,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
     {
       /* set to blocking mode by default */
       ulong arg=0, r;
-      r = ioctlsocket(sd,FIONBIO,(void*) &arg, sizeof(arg));
+      r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg));
     }
 #endif
   }
@@ -154,7 +154,7 @@ void vio_delete(Vio * vio)
 
 int vio_errno(Vio *vio __attribute__((unused)))
 {
-  return errno;			/* On Win32 this mapped to WSAGetLastError() */
+  return socket_errno;		/* On Win32 this mapped to WSAGetLastError() */
 }
 
 
@@ -163,12 +163,17 @@ int vio_read(Vio * vio, gptr buf, int size)
   int r;
   DBUG_ENTER("vio_read");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   if (vio->type == VIO_TYPE_NAMEDPIPE)
   {
     DWORD length;
+#ifdef OS2
+    if (!DosRead((HFILE)vio->hPipe, buf, size, &length))
+      DBUG_RETURN(-1);
+#else
     if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
       DBUG_RETURN(-1);
+#endif
     DBUG_RETURN(length);
   }
   r = recv(vio->sd, buf, size,0);
@@ -179,7 +184,7 @@ int vio_read(Vio * vio, gptr buf, int size)
 #ifndef DBUG_OFF
   if (r < 0)
   {
-    DBUG_PRINT("vio_error", ("Got error %d during read",errno));
+    DBUG_PRINT("vio_error", ("Got error %d during read",socket_errno));
   }
 #endif /* DBUG_OFF */
   DBUG_PRINT("exit", ("%d", r));
@@ -192,12 +197,17 @@ int vio_write(Vio * vio, const gptr buf, int size)
   int r;
   DBUG_ENTER("vio_write");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
   if ( vio->type == VIO_TYPE_NAMEDPIPE)
   {
     DWORD length;
+#ifdef OS2
+    if (!DosWrite((HFILE)vio->hPipe, (char*) buf, size, &length))
+      DBUG_RETURN(-1);
+#else
     if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
       DBUG_RETURN(-1);
+#endif
     DBUG_RETURN(length);
   }
   r = send(vio->sd, buf, size,0);
@@ -207,7 +217,7 @@ int vio_write(Vio * vio, const gptr buf, int size)
 #ifndef DBUG_OFF
   if (r < 0)
   {
-    DBUG_PRINT("vio_error", ("Got error on write: %d",errno));
+    DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno));
   }
 #endif /* DBUG_OFF */
   DBUG_PRINT("exit", ("%d", r));
@@ -221,7 +231,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode)
   DBUG_ENTER("vio_blocking");
   DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode));
 
-#if !defined(___WIN__) && !defined(__EMX__)
+#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
 #if !defined(NO_FCNTL_NONBLOCK)
 
   if (vio->sd >= 0)
@@ -346,7 +356,7 @@ int vio_close(Vio * vio)
   }
   if (r)
   {
-    DBUG_PRINT("vio_error", ("close() failed, error: %d",errno));
+    DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno));
     /* FIXME: error handling (not critical for MySQL) */
   }
   vio->type= VIO_CLOSED;
@@ -385,7 +395,7 @@ my_bool vio_peer_addr(Vio * vio, char *buf)
     if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)),
 		    &addrLen) != 0)
     {
-      DBUG_PRINT("exit", ("getpeername, error: %d", errno));
+      DBUG_PRINT("exit", ("getpeername, error: %d", socket_errno));
       DBUG_RETURN(1);
     }
     my_inet_ntoa(vio->remote.sin_addr,buf);
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 1fb98273fec..cccf6730046 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -236,7 +236,7 @@ int my_strnncoll_big5(const uchar * s1, int len1, const uchar * s2, int len2)
   return (int) (len1-len2);
 }
 
-int my_strnxfrm_big5(uchar * dest, uchar * src, int len, int srclen)
+int my_strnxfrm_big5(uchar * dest, const uchar * src, int len, int srclen)
 {
   uint16 e;
   /*uchar *d = dest; XXX: unused*/
@@ -276,7 +276,7 @@ int my_strcoll_big5(const uchar * s1, const uchar * s2)
   return 0;
 }
 
-int my_strxfrm_big5(uchar * dest, uchar * src, int len)
+int my_strxfrm_big5(uchar * dest, const uchar * src, int len)
 {
   uint16 e;
   uchar *d = dest;
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 9628f21b8d4..a5d55789bb8 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -2610,7 +2610,7 @@ int my_strcoll_gbk(const uchar * s1, const uchar * s2)
 			  s2, (uint) strlen((char*) s2));
 }
 
-int my_strnxfrm_gbk(uchar * dest, uchar * src, int len, int srclen)
+int my_strnxfrm_gbk(uchar * dest, const uchar * src, int len, int srclen)
 {
   uint16 e;
 
@@ -2630,7 +2630,7 @@ int my_strnxfrm_gbk(uchar * dest, uchar * src, int len, int srclen)
   return srclen;
 }
   
-int my_strxfrm_gbk(uchar * dest, uchar * src, int len)
+int my_strxfrm_gbk(uchar * dest, const uchar * src, int len)
 {
   return my_strnxfrm_gbk(dest,src,len,(uint) strlen((char*) src));
 }
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 9a5a91f9265..566271be845 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -228,10 +228,10 @@ int my_strcoll_sjis(const uchar *s1, const uchar *s2)
 				  s2,(uint) strlen((char*) s2));
 }
 
-int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
+int my_strnxfrm_sjis(uchar *dest, const uchar *src, int len, int srclen)
 {
   uchar *d_end = dest + len;
-  uchar *s_end = src + srclen;
+  uchar *s_end = (uchar*) src + srclen;
   while (dest < d_end && src < s_end) {
     if (ismbchar_sjis((char*) src, (char*) s_end)) {
       *dest++ = *src++;
@@ -244,7 +244,7 @@ int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
   return srclen;
 }
 
-int my_strxfrm_sjis(uchar *dest, uchar *src, int len)
+int my_strxfrm_sjis(uchar *dest, const uchar *src, int len)
 {
   return my_strnxfrm_sjis(dest, src, len, (uint) strlen((char*) src));
 }
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 321487c85cb..1c0acc38e24 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -535,7 +535,7 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
    Arg: Destination buffer, source string, dest length and source length
    Ret: Conveted string size
 */
-int my_strnxfrm_tis620(uchar * dest, uchar * src, int len, int srclen)
+int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
 {
   uint bufSize;
   uchar *tmp;
@@ -567,7 +567,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
    Arg: Destination buffer, String and	dest buffer size
    Ret: Converting string size
 */
-int my_strxfrm_tis620(uchar * dest, uchar * src, int len)
+int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
 {
   uint bufSize;
   uchar *tmp;
diff --git a/strings/ctype.c b/strings/ctype.c
index 16b652d42f1..d6f02ec5054 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -47,7 +47,7 @@ CHARSET_INFO *find_compiled_charset_by_name(const char *name)
   return NULL;
 }
 
-uint8 compiled_charset_number(const char *name)
+uint compiled_charset_number(const char *name)
 {
   CHARSET_INFO *cs;
   for (cs = compiled_charsets; cs->number > 0; cs++)
@@ -57,7 +57,7 @@ uint8 compiled_charset_number(const char *name)
   return 0;   /* this mimics find_type() */
 }
 
-const char *compiled_charset_name(uint8 charset_number)
+const char *compiled_charset_name(uint charset_number)
 {
   CHARSET_INFO *cs;
   for (cs = compiled_charsets; cs->number > 0; cs++)
diff --git a/strings/strnlen.c b/strings/strnlen.c
index 6eb872ee08d..3d625f7d48a 100644
--- a/strings/strnlen.c
+++ b/strings/strnlen.c
@@ -29,7 +29,7 @@
 
 uint strnlen(register const char *s, register uint maxlen)
 {
-  const char *end= memchr(s, '\0', maxlen);
+  const char *end= (const char *)memchr(s, '\0', maxlen);
   return end ? (uint) (end - s) : maxlen;
 }
 

From 3a6db1d65f0459e0b7b993afbe247c8d6f62849b Mon Sep 17 00:00:00 2001
From: unknown <tim@white.box>
Date: Tue, 21 Aug 2001 19:07:28 -0400
Subject: [PATCH 15/51] myisamchk.c	Make --set-character-set actually do
 something.

myisam/myisamchk.c:
  Make --set-character-set actually do something.
---
 myisam/myisamchk.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index 996e4749e53..8ee92debf56 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -39,7 +39,6 @@ static uint decode_bits;
 static char **default_argv;
 static const char *load_default_groups[]= { "myisamchk", 0 };
 static const char *set_charset_name;
-static uint8 set_charset_number;
 static CHARSET_INFO *set_charset;
 
 static const char *type_names[]=
@@ -607,9 +606,9 @@ static int myisamchk(MI_CHECK *param, my_string filename)
 	(((ulonglong) 1L << share->base.keys)-1)) ||
        test_if_almost_full(info) ||
        info->s->state.header.file_version[3] != myisam_file_magic[3] ||
-       (set_charset && set_charset_number != share->state.header.language)))
+       (set_charset && set_charset->number != share->state.header.language)))
   {
-    check_param.language=set_charset_number;
+    check_param.language=set_charset->number;
     if (recreate_table(&check_param, &info,filename))
     {
       VOID(fprintf(stderr,

From 65bc433d812251e87920198b9c3ab981b142cc80 Mon Sep 17 00:00:00 2001
From: unknown <tim@white.box>
Date: Tue, 21 Aug 2001 19:14:04 -0400
Subject: [PATCH 16/51] Portability fix in mysqlbinlog.cc (include
 my_pthread.h)

Clean up 'unused argument' warnings

Add extern "C" { ... } in my_pthread.h




client/mysqlbinlog.cc:
  Include my_pthread.h before thr_alarm.h (otherwise pthread_t isn't
  declared yet).
client/mysqltest.c:
  Fix unused argument warnings.
client/thread_test.c:
  Fix unused argument warnings.
include/my_pthread.h:
  Put extern "C" { ... } wrappers, because this file is included from
  some C++ files.
---
 client/mysqlbinlog.cc | 1 +
 client/mysqltest.c    | 8 ++++----
 client/thread_test.c  | 2 +-
 include/my_pthread.h  | 9 +++++++++
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 757e9dce810..f698ceaf5d4 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -21,6 +21,7 @@
 #include <m_string.h>
 #include <my_sys.h>
 #include <getopt.h>
+#include <my_pthread.h>
 #include <thr_alarm.h>
 #include <mysql.h>
 #include "log_event.h"
diff --git a/client/mysqltest.c b/client/mysqltest.c
index f6d87352a6c..6c5f1c57f6a 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -247,10 +247,10 @@ static int eval_result = 0;
 
 /* Disable functions that only exist in MySQL 4.0 */
 #if MYSQL_VERSION_ID < 40000
-static void mysql_enable_rpl_parse(MYSQL* mysql) {}
-static void mysql_disable_rpl_parse(MYSQL* mysql) {}
-static int mysql_rpl_parse_enabled(MYSQL* mysql) { return 1; }
-static int mysql_rpl_probe(MYSQL *mysql) { return 1; }
+static void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
+static void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
+static int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
+static int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
 #endif
 
 
diff --git a/client/thread_test.c b/client/thread_test.c
index 4d3ae6e7ddd..dbe2acee8db 100644
--- a/client/thread_test.c
+++ b/client/thread_test.c
@@ -19,7 +19,7 @@
 
 #ifndef THREAD
 
-int main(int argc, char **argv)
+int main(void)
 {
   printf("This test must be compiled with multithread support to work\n");
   exit(1);
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 652bdd205c0..767722a2050 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -20,6 +20,10 @@
 #ifndef _my_pthread_h
 #define _my_pthread_h
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <errno.h>
 #ifndef ETIME
 #define ETIME ETIMEDOUT				/* For FreeBSD */
@@ -576,4 +580,9 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
 #endif /* SAFE_STATISTICS */
 #endif /* HAVE_ATOMIC_ADD */
 #endif /* thread_safe_increment */
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _my_ptread_h */

From cca89530143d587fcb3e862e5d51770b727d7eb2 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Wed, 22 Aug 2001 01:57:48 -0500
Subject: [PATCH 17/51] a few fixes per emails clean up PostgreSQL section

---
 Docs/manual.texi | 585 +++++++++++++++++++++++++----------------------
 1 file changed, 316 insertions(+), 269 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 7591af1c00c..6e6c0df5b15 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -5002,25 +5002,24 @@ users.
 
 @cindex PostgreSQL vs. MySQL, overview
 
-When reading the following, please note that both products are
-continually evolving.  We at MySQL AB and the PostgreSQL
-developers are both working on making our respective database as good as
-possible, so we are both a serious choice to any commercial database.
+When reading the following, please note that both products are continually
+evolving.  We at MySQL AB and the PostgreSQL developers are both working
+on making our respective database as good as possible, so we are both a 
+serious choice to any commercial database.
 
 The following comparison is made by us at MySQL AB.  We have tried to be
 as accurate and fair as possible, but because we don't have a full
 knowledge of all PostgreSQL features while we know MySQL througly, we
-may have got some things wrong. We will however correct these when they
+may have got some things wrong.  We will however correct these when they
 come to our attention.
 
-We would first like to note that @code{PostgreSQL} and MySQL
-are both widely used products, but with different design goals, even if
-we are both striving to be ANSI SQL compatible.  This means that for
-some applications MySQL is more suitable and for others
-@code{PostgreSQL} is more suitable.  When choosing which database to
-use, you should first check if the database's feature set satisfies your
-application.  If you need speed, MySQL is probably your best
-choice. If you need some of the extra features that only @code{PostgreSQL}
+We would first like to note that PostgreSQL and MySQL are both widely used
+products, but with different design goals, even if we are both striving to
+be ANSI SQL compatible.  This means that for some applications MySQL is 
+more suited, while for others PostgreSQL is more suited.  When choosing 
+which database to use, you should first check if the database's feature set
+satisfies your application.  If you need raw speed, MySQL is probably your
+best choice.  If you need some of the extra features that only PostgreSQL
 can offer, you should use @code{PostgreSQL}.
 
 @cindex PostgreSQL/MySQL, strategies
@@ -5038,15 +5037,15 @@ When adding things to MySQL we take pride to do an optimal, definite
 solution.  The code should be so good that we shouldn't have any need to
 change it in the foreseeable future.  We also do not like to sacrifice
 speed for features but instead will do our utmost to find a solution
-that will give maximal throughput. This means that development will take
+that will give maximal throughput.  This means that development will take
 a little longer, but the end result will be well worth this.  This kind
 of development is only possible because all server code are checked by
 one of a few (currently two) persons before it's included in the
 MySQL server.
 
 We at MySQL AB believe in frequent releases to be able to push out new
-features quickly to our users. Because of this we do a new small release
-about every 3 weeks, which a major branch every year.  All releases are
+features quickly to our users.  Because of this we do a new small release
+about every three weeks, and a major branch every year.  All releases are
 throughly tested with our testing tools on a lot of different platforms.
 
 PostgreSQL is based on a kernel with lots of contributors. In this setup
@@ -5057,20 +5056,19 @@ later if there arises a need for this.
 Another big difference between MySQL and PostgreSQL is that
 nearly all of the code in the MySQL server are coded by developers that
 are employed by MySQL AB and are still working on the server code. The
-exceptions are the transaction engines and the regexp library.
+exceptions are the transaction engines, and the regexp library.
 
 This is in sharp contrast to the PostgreSQL code where the majority of
 the code is coded by a big group of people with different backgrounds.
-It was only recently that the PostgreSQL developers announced that they
+It was only recently that the PostgreSQL developers announced that their
 current developer group had finally had time to take a look at all
 the code in the current PostgreSQL release.
 
 Both of the above development methods has it's own merits and drawbacks.
-We here at MySQL AB think of course that our model is better
-because our model gives better code consistence, more optimal and
-reusable code and, in our opinion, fewer bugs. Because we are the
-authors of the MySQL server code we are better able to
-coordinate new features and releases.
+We here at MySQL AB think of course that our model is better because our
+model gives better code consistency, more optimal and reusable code, and
+in our opinion, fewer bugs.  Because we are the authors of the MySQL server
+code, we are better able to coordinate new features and releases.
 
 
 @node MySQL-PostgreSQL features, MySQL-PostgreSQL benchmarks, MySQL-PostgreSQL goals, Compare PostgreSQL
@@ -5082,7 +5080,7 @@ On the @uref{http://www.mysql.com/information/crash-me.php, crash-me}
 page you can find a list of those database constructs and limits that
 one can detect automatically with a program.  Note however that a lot of
 the numerical limits may be changed with startup options for respective
-database. The above web page is however extremely useful when you want to
+database.  The above web page is however extremely useful when you want to
 ensure that your applications works with many different databases or
 when you want to convert your application from one datbase to another.
 
@@ -5092,203 +5090,230 @@ MySQL offers the following advantages over PostgreSQL:
 @item
 @code{MySQL} is generally much faster than PostgreSQL.
 @xref{MySQL-PostgreSQL benchmarks}.
+
 @item
-Because MySQL has a much larger user base than PostgreSQL the
+MySQL has a much larger user base than PostgreSQL, therefor the
 code is more tested and has historically been more stable than
-PostgreSQL. MySQL is the much more used in production
+PostgreSQL.  MySQL is the much more used in production
 environments than PostgreSQL, mostly thanks to that MySQL AB,
-former TCX DataKonsult AB, has provided top quality commercial support
+formerly TCX DataKonsult AB, has provided top quality commercial support
 for MySQL from the day it was released, whereas until recently
 PostgreSQL was unsupported.
+
 @item
 MySQL works on more platforms than PostgreSQL. @xref{Which OS}.
+
 @item
-MySQL works better on Windows; MySQL is running as a
-native windows application (a service on NT/Win2000/WinXP), while
-PostgreSQL is run under the cygwin emulation. We have heard that
-PostgreSQL is not yet that stable on windows but we haven't been able to
+MySQL works better on Windows than PostgreSQL does.  MySQL runs as a
+native Windows application (a service on NT/Win2000/WinXP), while
+PostgreSQL is run under the cygwin emulation.  We have heard that
+PostgreSQL is not yet that stable on Windows but we haven't been able to
 verify this ourselves.
+
 @item
-MySQL has more API to other languages and is supported by more
-programs than PostgreSQL. @xref{Contrib}.
+MySQL has more APIs to other languages and is supported by more
+existing programs than PostgreSQL.  @xref{Contrib}.
+
 @item
-MySQL works on 24/7 heavy duty systems. In most circumstances
+MySQL works on 24/7 heavy duty systems.  In most circumstances
 you never have to run any cleanups on @code{MySQL}.  PostgreSQL doesn't
-yet support 24/7 systems because you have have to run @code{vacuum()}
+yet support 24/7 systems because you have to run @code{vacuum()}
 once in a while to reclaim space from @code{UPDATE} and @code{DELETE}
 commands and to perform statistics analyzes that are critical to get
-good performance with PostgreSQL. Vacuum is also needed after adding
-a lot of new rows to a table. On a busy system with lots of changes
+good performance with PostgreSQL.  Vacuum is also needed after adding
+a lot of new rows to a table.  On a busy system with lots of changes,
 vacuum must be run very frequently, in the worst cases even many times a
 day.  During the @code{vacuum()} run, which may take hours if the
-database is big, the database is from a production standpoint
+database is big, the database is from a production standpoint,
 practically dead.  The PostgreSQL team has fixing this on their TODO,
 but we assume that this is not an easy thing to fix permanently.
+
 @item
 A working, tested replication feature used by sites like
-@uref{http://finance.yahoo.com, Yahoo finance},
-@uref{http://www.mobile.de/,mobile.de} and
-@uref{http://www.slashdot.org,Slashdot}.
+@itemize @minus
+@item Yahoo Finance (@uref{http://finance.yahoo.com})
+@item Mobile.de (@uref{http://www.mobile.de/})
+@item Slashdot (@uref{http://www.slashdot.org})
+@end itemize
+
 @item
-Included in the MySQL distribution is included two different
-testing suits (@file{mysql-test-run} and
-@uref{http://www.mysql.com/information/crash-me.php,crash-me}) and a
-benchmark suite. The test system is actively updated with code to test
-each new feature and almost all repeatable bugs that comes to our
-attention. We test MySQL with these on a lot of platforms
-before every release.  These tests are more sofisticated than anything
-have seen from PostgreSQL and ensures that the MySQL code keeps
-at a high standard.
+Included in the MySQL distribution are two different testing suites, 
+@file{mysql-test-run} and 
+@uref{http://www.mysql.com/information/crash-me.php,crash-me}, as well
+as a benchmark suite.  The test system is actively updated with code to
+test each new feature and almost all repeatable bugs that have come to
+our attention.  We test MySQL with these on a lot of platforms before
+every release.  These tests are more sophisticated than anything we have 
+seen from PostgreSQL, and they ensures that the MySQL is kept to a high
+standard.
+
 @item
-There are far moore books in print on MySQL than on PostgreSQL.
+There are far more books in print about MySQL than about PostgreSQL.
 O'Reilly, Sams, Que, and New Riders are all major publishers with books
-about MySQL. All MySQL features is also documented in the
-MySQL on-line manual because when a feature is implemented, the
-MySQL developers are required to document it before it's
-included in the source.
+about MySQL.  All MySQL features are also documented in the MySQL on-line
+manual, because when a new feature is implemented, the MySQL developers 
+are required to document it before it's included in the source.
+
 @item
-MySQL has supports more of the standard ODBC functions than
-@code{PostgreSQL}.
+MySQL supports more of the standard ODBC functions than @code{PostgreSQL}.
+
 @item
 MySQL has a much more sophisticated @code{ALTER TABLE}.
+
 @item
-MySQL has support for tables without transactions for
-applications that need all speed they can get. The tables may be memory
-based,@code{HEAP} tables or disk based @code{MyISAM}. @xref{Table types}.
+MySQL has support for tables without transactions for applications that 
+need all speed they can get. The tables may be memory based, @code{HEAP}
+tables or disk based @code{MyISAM}.  @xref{Table types}.
+
 @item
-MySQL has support for 3 different table handles that support
-transactions (@code{BDB} and @code{InnoDB}).  Because
-every transaction engine performs differently under different
-conditions, this gives the application writer more options to find an
-optimal solution for his/her setup. @xref{Table types}.
+MySQL has support for two different table handlers that support
+transactions, @code{BerkeleyDB} and @code{InnoDB}.  Because every 
+transaction engine performs differently under different conditions, this 
+gives the application writer more options to find an optimal solution for
+his or her setup.  @xref{Table types}.
+
 @item
 @code{MERGE} tables gives you a unique way to instantly make a view over
-a set of identical tables and use these as one. This is perfectly for
+a set of identical tables and use these as one.  This is perfect for
 systems where you have log files that you order for example by month.
 @xref{MERGE}.
+
 @item
 The option to compress read-only tables, but still have direct access to
 the rows in the table, gives you better performance by minimizing disk
-reads.  This is very useful when you are archiving
-things.@xref{myisampack}.
+reads.  This is very useful when you are archiving things.
+@xref{myisampack}.
+
 @item
-MySQL has internal support for text search. @xref{Fulltext Search}.
+MySQL has internal support for fulltext search. @xref{Fulltext Search}.
+
 @item
 You can access many databases from the same connection (depending of course
 on your privileges).
+
 @item
-MySQL is coded from the start with multi-threading while
-PostgreSQL uses processes. Because context switching and access to
-common storage areas is much faster between threads, than are separate
-processes, this gives MySQL a big speed advantage in multi-user
-applications and also makes it easier for MySQL to take full
-advantage of symmetric multiprocessor systems (SMP).
+MySQL is coded from the start to be multi-threaded while PostgreSQL uses
+processes.  Context switching and access to common storage areas is much 
+faster between threads than between separate processes, this gives MySQL
+a big speed advantage in multi-user applications and also makes it easier
+for MySQL to take full advantage of symmetric multiprocessor (SMP) systems.
+
 @item
-MySQL has a much more sophisticated privilege system than
-PostgreSQL.  While PostgreSQL only supports @code{INSERT},
-@code{SELECT}, @code{update/delete} grants per user on a database or a
-table MySQL allows you to define a full set of different
-privileges on database, table and columns level. MySQL also allows
-you to specify the privilege on host+user combinations. @xref{GRANT}.
+MySQL has a much more sophisticated privilege system than PostgreSQL.  
+While PostgreSQL only supports @code{INSERT}, @code{SELECT}, and
+@code{UPDATE/DELETE} grants per user on a database or a table, MySQL allows
+you to define a full set of different privileges on database, table and 
+column level.  MySQL also allows you to specify the privilege on host and 
+user combinations.  @xref{GRANT}.
+
 @item
-MySQL supports a compressed server/client protocol which
-improves performance over slow links.
+MySQL supports a compressed client/server protocol which improves 
+performance over slow links.
+
 @item
-MySQL employs the table handler concept and is the only
-relational database we know of built around this concept. This allows
-different low level table types to be swapped into the SQL engine, each
-table type optimized for a different performance characteristics.
+MySQL employs a ``table handler'' concept, and is the only relational 
+database we know of built around this concept.  This allows different 
+low-level table types to be swapped into the SQL engine, and each table 
+type can be optimized for different performance characteristics.
+
 @item
-All @code{MySQL} table types (except @strong{InnoDB}) are implemented as
-files (ie: one table per file), which makes it really easy to backup,
-move, delete and even symlink databases and tables when the server is
-down.
+All MySQL table types (except @strong{InnoDB}) are implemented as files
+(one table per file), which makes it really easy to backup, move, delete
+and even symlink databases and tables, even when the server is down.
+
 @item
 Tools to repair and optimize @strong{MyISAM} tables (the most common
-MySQL table type).  A repair tool is only needed when a
-physical corruption of a data file happens, usually from a hardware
-failure. It allows a majority of the data to be recovered.
+MySQL table type).  A repair tool is only needed when a physical corruption
+of a data file happens, usually from a hardware failure.  It allows a 
+majority of the data to be recovered.
+
 @item
-Upgrading MySQL is painless. When you are upgrading MySQL,
-you don't need to dump/restore your data, as you have to do with most
-PostgreSQL upgrades.
+Upgrading MySQL is painless.  When you are upgrading MySQL, you don't need
+to dump/restore your data, as you have to do with most PostgreSQL upgrades.
 @end itemize
 
 Drawbacks with MySQL compared to PostgreSQL:
 
 @itemize @bullet
 @item
-The transaction support in MySQL is not yet as well tested as
-PostgreSQL's system.
+The transaction support in MySQL is not yet as well tested as PostgreSQL's
+system.
+
 @item
-Because MySQL uses threads, which are still a moving target on
-many OS, one must either use binaries from
-@uref{http://www.mysql.com/downloads} or carefully follow our
-instructions on
+Because MySQL uses threads, which are not yet flawless on many OSes, one
+must either use binaries from @uref{http://www.mysql.com/downloads}, or
+carefully follow our instructions on
 @uref{http://www.mysql.com/doc/I/n/Installing_source.html} to get an
 optimal binary that works in all cases.
+
 @item
 Table locking, as used by the non-transactional @code{MyISAM} tables, is
 in many cases faster than page locks, row locks or versioning.  The
 drawback however is that if one doesn't take into account how table
-locks works, a single long-running query can block a table for updates
+locks work, a single long-running query can block a table for updates
 for a long time. This can usable be avoided when designing the
 application.  If not, one can always switch the trouble table to use one
 of the transactional table types. @xref{Table locking}.
+
 @item
-With UDF (user defined functions) one can extend MySQL with
-both normal SQL functions and aggregates, but this is not as easy or as
-flexible as in PostgreSQL. @xref{Adding functions}.
+With UDF (user defined functions) one can extend MySQL with both normal 
+SQL functions and aggregates, but this is not yet as easy or as flexible
+as in PostgreSQL.  @xref{Adding functions}.
+
 @item
-Updates and deletes that goes over multiple tables is harder to do in
-MySQL. (Will be fixed in MySQL 4.0 with multi-table
+Updates and deletes that run over multiple tables is harder to do in
+MySQL. This will, hoever, be fixed in MySQL 4.0 with multi-table
 @code{DELETE} and multi-table @code{UPDATE} and in MySQL 4.1
-with @code{SUB-SELECT})
+with subselects.
 @end itemize
 
-PostgreSQL offers currently the following advantages over MySQL:
+PostgreSQL currently offers the following advantages over MySQL:
 
-Note that because we know the MySQL road map, we have included
-in the following table the version when MySQL should support
-this feature.  Unfortunately we couldn't do this for previous comparison,
-because we don't know the PostgreSQL roadmap.
+Note that because we know the MySQL road map, we have included in the
+following table the version when MySQL should support this feature.
+Unfortunately we couldn't do this for previous comparison, because we 
+don't know the PostgreSQL roadmap.
 
 @multitable @columnfractions .70 .30
-@item @strong{Feature} @tab @strong{MySQL version}
-@item Subselects @tab 4.1
-@item Foreign keys @tab 4.0 and 4.1
-@item Views. @tab 4.2
-@item Stored procedures in multiple languages @tab 4.1
-@item Extensible type system. @tab Not planed
-@item Unions @tab 4.0.
-@item Full join. @tab 4.0 or 4.1.
-@item Triggers. @tab 4.1
-@item Constrainst @tab 4.1
-@item Cursors @tab 4.1 or 4.2
-@item Extensible index types like R-trees @tab R-trees are planned to 4.2
-@item Inherited tables @tab Not planned
+@item @strong{Feature}                     @tab @strong{MySQL version}
+@item Subselects                           @tab 4.1
+@item Foreign keys                         @tab 4.0 and 4.1
+@item Views                                @tab 4.2
+@item Stored procedures                    @tab 4.1
+@item Extensible type system               @tab Not planned
+@item Unions                               @tab 4.0
+@item Full join                            @tab 4.0 or 4.1
+@item Triggers                             @tab 4.1
+@item Constrainst                          @tab 4.1
+@item Cursors                              @tab 4.1 or 4.2
+@item Extensible index types like R-trees  @tab R-trees are planned for 4.2
+@item Inherited tables                     @tab Not planned
 @end multitable
 
 Other reasons to use PostgreSQL:
 
 @itemize @bullet
 @item
-Standard usage is in PostgreSQL closer to ANSI SQL in some cases.
+Standard usage in PostgreSQL is closer to ANSI SQL in some cases.
+
 @item
-One can get speed up PostgreSQL by coding things as stored procedures.
+One can speed up PostgreSQL by coding things as stored procedures.
+
 @item
-Bigger team of developers that contributes to the server.
+PostgreSQL has a bigger team of developers that contribute to the server.
 @end itemize
 
 Drawbacks with PostgreSQL compared to MySQL:
 
 @itemize @bullet
 @item
-@code{Vaccum()} makes PostgreSQL hard to use in a 24/7 environment.
+@code{VACUUM()} makes PostgreSQL hard to use in a 24/7 environment.
+
 @item
 Only transactional tables.
+
 @item
-Much slower insert/delete/update.
+Much slower @code{INSERT}, @code{DELETE}, and @code{UPDATE}.
 @end itemize
 
 For a complete list of drawbacks, you should also examine the first table
@@ -5304,88 +5329,83 @@ in this section.
 
 @cindex PostgreSQL vs. MySQL, benchmarks
 
-The only open source benchmark, that we know of, that can be used to
-benchmark MySQL and PostgreSQL (and other databases) is our
-own. It can be found at:
-@uref{http://www.mysql.com/information/benchmarks.html}.
+The only open source benchmark that we know of that can be used to
+benchmark MySQL and PostgreSQL (and other databases) is our own. It can
+be found at @uref{http://www.mysql.com/information/benchmarks.html}.
 
 We have many times asked the PostgreSQL developers and some PostgreSQL
-users to help us extend this benchmark to make the definitive benchmark
-for databases, but unfortunately we haven't got any feedback for this.
+users to help us extend this benchmark to make it the definitive benchmark
+for databases, but unfortunately we haven't gotten any feedback for this.
 
-We, the MySQL developers, have because of this spent a lot of
-hours to get maximum performance from PostgreSQL for the benchmarks, but
-because we don't know PostgreSQL intimately we are sure that there are
-things that we have missed.  We have on the benchmark page documented
-exactly how we did run the benchmark so that it should be easy for
-anyone to repeat and verify our results.
+We the MySQL developers have, because of this, spent a lot of hours to get
+maximum performance from PostgreSQL for the benchmarks, but because we 
+don't know PostgreSQL intimately, we are sure that there are things that 
+we have missed.  We have on the benchmark page documented exactly how we 
+did run the benchmark so that it should be easy for anyone to repeat and
+verify our results.
 
-The benchmarks are usually run with and without the @code{--fast}
-option.  When run with @code{--fast} we are trying to use every trick
-the server can do to get the code to execute as fast as possible.
-The idea is that the normal run should show how the server would work in
-a default setup and the @code{--fast} run shows how the server would do
-if the application developer would use extensions in the server to make
-his application run faster.
+The benchmarks are usually run with and without the @code{--fast} option.
+When run with @code{--fast} we are trying to use every trick the server can
+do to get the code to execute as fast as possible.  The idea is that the
+normal run should show how the server would work in a default setup and 
+the @code{--fast} run shows how the server would do if the application 
+developer would use extensions in the server to make his application run
+faster.
 
-When running with PostgreSQL and @code{--fast} we do a @code{vacuum()}
-between after every major table update and drop table to make the database
-in perfect shape for the following selects. The time for vacuum() is
-measured separately.
+When running with PostgreSQL and @code{--fast} we do a @code{VACUUM()}
+after every major table @code{UPDATE} and @code{DROP TABLE} to make the
+database in perfect shape for the following @code{SELECT}s.  The time for
+@code{VACUUM()} is measured separately.
 
-When running with PostgreSQL 7.1.1 we could however not run with
-@code{--fast} because during the insert test, the postmaster (the
+When running with PostgreSQL 7.1.1 we could, however, not run with
+@code{--fast} because during the @code{INSERT} test, the postmaster (the
 PostgreSQL deamon) died and the database was so corrupted that it was
-impossible to restart postmaster. (The details about the machine we run
-the benchmark can be found on the benchmark page). After this happened
-twice, we decided to postpone the @code{--fast} test until next
-PostgreSQL release.
+impossible to restart postmaster.   After this happened twice, we decided
+to postpone the @code{--fast} test until next PostgreSQL release.  The 
+details about the machine we run the benchmark can be found on the 
+benchmark page.
 
-Before going to the other benchmarks we know of, We would like to give
-some background to benchmarks:
+Before going to the other benchmarks we know of, we would like to give
+some background on benchmarks:
 
 It's very easy to write a test that shows ANY database to be best
 database in the world, by just restricting the test to something the
 database is very good at and not test anything that the database is not
-good at; If one after this publish the result with a single figure
-things is even easier.
+good at.  If one after this publishes the result with a single figure,
+things are even easier.
 
-This would be like we would measure the speed of MySQL compared
-to PostgreSQL by looking at the summary time of the MySQL benchmarks on
-our web page. Based on this MySQL would be more than 40 times
-faster than PostgreSQL, something that is of course not true. We could
-make things even worse by just taking the test where PostgreSQL performs
-worst and claim that MySQL is more than 2000 times faster than
-PostgreSQL.
+This would be like us measuring the speed of MySQL compared to PostgreSQL
+by looking at the summary time of the MySQL benchmarks on our web page.
+Based on this MySQL would be more than 40 times faster than PostgreSQL, 
+something that is of course not true.  We could make things even worse 
+by just taking the test where PostgreSQL performs worst and claim that 
+MySQL is more than 2000 times faster than PostgreSQL.
 
-The case is that MySQL does a lot of optimizations that
-PostgreSQL doesn't do and the other way around.  An SQL optimizer is a
-very complex thing and a company could spend years on just making the
-optimizer faster and faster.
+The case is that MySQL does a lot of optimizations that PostgreSQL doesn't 
+do and the other way around.  An SQL optimizer is a very complex thing, and
+a company could spend years on just making the optimizer faster and faster.
 
 When looking at the benchmark results you should look for things that
 you do in your application and just use these results to decide which
-database would be best suited for your application. The benchmark
+database would be best suited for your application.  The benchmark
 results also shows things a particular database is not good at and should
 give you a notion about things to avoid and what you may have to do in
 other ways.
 
-We know of two benchmark tests that claims that PostgreSQL performers
-better than MySQL. These both where multi-user tests, a test
-that we here at MySQL AB haven't had time to write and include in
-the benchmark suite, mainly because it's a big task to do this in a
-manner that is fair against all databases.
+We know of two benchmark tests that claims that PostgreSQL performs better 
+than MySQL.  These both where multi-user tests, a test that we here at 
+MySQL AB haven't had time to write and include in the benchmark suite, 
+mainly because it's a big task to do this in a manner that is fair against
+all databases.
 
-One is the benchmark paid for by
-@uref{http://www.greatbridge.com/about/press.php?content_id=4,Great
-Bridge}.
+One is the benchmark paid for by Great Bridge, which you can read about at:
+@uref{http://www.greatbridge.com/about/press.php?content_id=4}.
 
-This is the worst benchmark we have ever seen anyone ever conduct.  This
-was not only tuned to only test what PostgreSQL is absolutely best at,
-it was also totally unfair against every other database involved in the
-test.
+This is the probably worst benchmark we have ever seen anyone conduct.  This
+was not only tuned to only test what PostgreSQL is absolutely best at, it 
+was also totally unfair against every other database involved in the test.
 
-@strong{NOTE}: We know that not even some of the main PostgreSQL
+@strong{NOTE}:  We know that not even some of the main PostgreSQL
 developers did like the way Great Bridge conducted the benchmark, so we
 don't blame them for the way the benchmark was made.
 
@@ -5394,98 +5414,115 @@ we will here just shortly repeat some things that where wrong with it.
 
 @itemize @bullet
 @item
-The tests where run with an expensive commercial tool, that makes it
+The tests were run with an expensive commercial tool, that makes it
 impossible for an open source company like us to verify the benchmarks,
-or even check how the benchmark where really done. The tool is not even
-a true benchmark tool, but a application/setup testing tool.  To refer
-this as STANDARD benchmark tool is to stretch the truth a long way.
+or even check how the benchmarks were really done.  The tool is not even
+a true benchmark tool, but an application/setup testing tool.  To refer
+this as a ``standard'' benchmark tool is to stretch the truth a long way.
+
 @item
 Great Bridge admitted that they had optimized the PostgreSQL database
-(with vacuum() before the test) and tuned the startup for the tests,
+(with @code{VACUUM()} before the test) and tuned the startup for the tests,
 something they hadn't done for any of the other databases involved.  To
-say "This process optimizes indexes and frees up disk space a bit.  The
-optimized indexes boost performance by some margin".  Our benchmarks
-clearly indicates that the difference in running a lot of selects on a
-database with and without vacuum() can easily differ by a factor of 10.
-@item
-The test results where also strange; The AS3AP test documentation
-mentions that the test does:
+say ``This process optimizes indexes and frees up disk space a bit.  The
+optimized indexes boost performance by some margin.''  Our benchmarks
+clearly indicate that the difference in running a lot of selects on a
+database with and without @code{VACUUM()} can easily differ by a factor
+of ten.
 
-"selections, simple joins, projections, aggregates, one-tuple updates,
-and bulk updates"
-
-PostgreSQL is good at doing selects and joins (especially after a
-vacuum()), but doesn't perform as well on inserts/updates; The
-benchmarks seem to indicate that only SELECTs where done (or very few
-updates) . This could easily explain they good results for PostgreSQL in
-this test.  The bad results for MySQL will be obvious a bit down in this
-document.
 @item
-They did run the so called benchmark from a Windows machine against a
+The test results were also strange.  The AS3AP test documentation
+mentions that the test does ``selections, simple joins, projections, 
+aggregates, one-tuple updates, and bulk updates''.
+
+PostgreSQL is good at doing @code{SELECT}s and @code{JOIN}s (especially 
+after a @code{VACUUM()}), but doesn't perform as well on @code{INSERT}s or
+@code{UPDATE}s.  The benchmarks seem to indicate that only @code{SELECT}s 
+were done (or very few updates).  This could easily explain they good results
+for PostgreSQL in this test.  The bad results for MySQL will be obvious a 
+bit down in this document.
+
+@item
+They did run the so-called benchmark from a Windows machine against a
 Linux machine over ODBC, a setup that no normal database user would ever
-do when running a heavy multi-user application. This tested more the
+do when running a heavy multi-user application.  This tested more the
 ODBC driver and the Windows protocol used between the clients than the
 database itself.
+
 @item
 When running the database against Oracle and MS-SQL (Great Bridge has
-indirectly indicated that the databases they used in the test),
-they didn't use the native protocol but instead ODBC. Anyone that has
-ever used Oracle, knows that all real application uses the native
-interface instead of ODBC. Doing a test through ODBC and claiming that
-the results had anything to do with using the database for real can't
-be regarded as fair play. They should have done two tests with and
-without ODBC to provide the right facts (after having got experts to tune
-all involved databases of course).
+indirectly indicated that the databases they used in the test), they 
+didn't use the native protocol but instead ODBC.  Anyone that has ever 
+used Oracle knows that all real application uses the native interface 
+instead of ODBC.  Doing a test through ODBC and claiming that the results
+had anything to do with using the database in a real-world situation can't
+be regarded as fair.  They should have done two tests with and without ODBC
+to provide the right facts (after having got experts to tune all involved
+databases of course).
+
 @item
-They refer to the TPC-C tests, but doesn't anywhere mention that the
-tests they did where not a true TPC-C test and they where not even
-allowed to call it a TPC-C test.  A TPC-C test can only be conducted by
-the rules approved by the @uref{http://www.tpc.org,TPC-council}. Great
-Bridge didn't do that. By doing this they have both violated the TPC
-trademark and miscredited their own benchmarks.  The rules set by the
-TPC-council are very strict to ensure that no one can produce false
-results or make unprovable statements. Apparently Great Bridge wasn't
-interested in doing this.
+They refer to the TPC-C tests, but they don't mention anywhere that the
+test they did was not a true TPC-C test and they were not even allowed to
+call it a TPC-C test.  A TPC-C test can only be conducted by the rules
+approved by the TPC Council (@uref{http://www.tpc.org}). Great Bridge 
+didn't do that.  By doing this they have both violated the TPC trademark
+and miscredited their own benchmarks.  The rules set by the TPC Council 
+are very strict to ensure that no one can produce false results or make
+unprovable statements.  Apparently Great Bridge wasn't interested in 
+doing this.
+
 @item
 After the first test, we contacted Great Bridge and mentioned to them
-some of the obvious mistakes they had done with MySQL; Running
-with a debug version of our ODBC driver, running on a Linux system that
-wasn't optimized for threads, using an old MySQL version when there was
-a recommended newer one available, not starting MySQL with the
-right options for heavy multi-user use (the default installation of
-MySQL is tuned for minimal resource use). Great Bridge did run a new
-test, with our optimized ODBC driver and with better startup options for
-MySQL, but refused to either use our updated glibc library or our
-standard binary (used by 80% of our users), which was statically linked
-with a fixed glibc library.
+some of the obvious mistakes they had done with MySQL: 
+
+@itemize @minus
+@item
+Running with a debug version of our ODBC driver
+
+@item
+Running on a Linux system that wasn't optimized for threads
+
+@item
+Using an old MySQL version when there was a recommended newer one available
+
+@item
+Not starting MySQL with the right options for heavy multi-user use (the 
+default installation of MySQL is tuned for minimal resource use). 
+@end itemize
+
+Great Bridge did run a new test, with our optimized ODBC driver and with 
+better startup options for MySQL, but refused to either use our updated 
+glibc library or our standard binary (used by 80% of our users), which was
+statically linked with a fixed glibc library.
 
 According to what we know, Great Bridge did nothing to ensure that the
-other databases where setup correctly to run good in their test
-environment. We are sure however that they didn't contact Oracle or
+other databases were set up correctly to run well in their test
+environment.  We are sure however that they didn't contact Oracle or
 Microsoft to ask for their advice in this matter ;)
+
 @item
 The benchmark was paid for by Great Bridge, and they decided to publish
-only partial chosen results (instead of publishing it all).
+only partial, chosen results (instead of publishing it all).
 @end itemize
 
 Tim Perdue, a long time PostgreSQL fan and a reluctant MySQL user
 published a comparison on
 @uref{http://www.phpbuilder.com/columns/tim20001112.php3,phpbuider}.
 
-When we got aware of the comparison, we phoned Tim Perdue about this
-because there was a lot of strange things in his results. For example,
+When we became aware of the comparison, we phoned Tim Perdue about this
+because there were a lot of strange things in his results.  For example,
 he claimed that MySQL had a problem with five users in his tests, when we
 know that there are users with similar machines as his that are using
-MySQL with 2000 simultaneous connections doing 400 queries per second (In
-this case the limit was the web bandwidth, not the database).
+MySQL with 2000 simultaneous connections doing 400 queries per second.
+(In this case the limit was the web bandwidth, not the database.)
 
 It sounded like he was using a Linux kernel that either had some
-problems with many threads (Linux kernels before 2.4 had a problem with
-this but we have documented how to fix this and Tim should be aware of
-this problem). The other possible problem could have been an old glibc
+problems with many threads, such as kernels before 2.4, which had a problem 
+with this but we have documented how to fix this and Tim should be aware of
+this problem.  The other possible problem could have been an old glibc
 library and that Tim didn't use a MySQL binary from our site, which is
 linked with a corrected glibc library, but had compiled a version of his
-own with. In any of the above cases, the symptom would have been exactly
+own with.  In any of the above cases, the symptom would have been exactly
 what Tim had measured.
 
 We asked Tim if we could get access to his data so that we could repeat
@@ -5498,26 +5535,25 @@ Because of this we can't put any trust in this benchmark either :(
 Conclusion:
 
 The only benchmarks that exist today that anyone can download and run
-against MySQLand PostgreSQL is the MySQL benchmarks.  We here
-at MySQL believe that open source databases should be tested
-with open source tools!  This is the only way to ensure that no one
-does tests that nobody can reproduce and use this to claim that a
-database is better than another. Without knowing all the facts it's
-impossible to answer the claims of the tester.
+against MySQL and PostgreSQL is the MySQL benchmarks.  We here at MySQL 
+believe that open source databases should be tested with open source tools!
+This is the only way to ensure that no one does tests that nobody can 
+reproduce and use this to claim that a database is better than another.
+Without knowing all the facts it's impossible to answer the claims of the
+tester.
 
 The thing we find strange is that every test we have seen about
 PostgreSQL, that is impossible to reproduce, claims that PostgreSQL is
 better in most cases while our tests, which anyone can reproduce,
-clearly shows otherwise. With this we don't want to say that PostgreSQL
-isn't good at many things (It is!) We would just like to see a fair test
+clearly shows otherwise.  With this we don't want to say that PostgreSQL
+isn't good at many things (it is!).  We would just like to see a fair test
 where they are very good so that we could get some friendly competition
 going!
 
-For more information about our benchmarks suite see @xref{MySQL
-Benchmarks}. 
+For more information about our benchmarks suite @xref{MySQL Benchmarks}. 
 
 We are working on an even better benchmark suite, including much better
-documentation of what the individual tests really do and how to add more
+documentation of what the individual tests really do, and how to add more
 tests to the suite.
 
 
@@ -9617,7 +9653,7 @@ thread stacks to stay away from the global heap.  With @code{mysqld}, you
 should enforce this "gentleman" behavior by setting a reasonable value for 
 the @code{max_connections} variable.
 
-If you build MySQL yourself and do not what to mess with patching
+If you build MySQL yourself and do not want to mess with patching
 LinuxThreads, you should set @code{max_connections} to a value no higher 
 than 500.  It should be even less if you have a large key buffer,  large 
 heap tables, or some other things that make @code{mysqld} allocate a lot 
@@ -25075,21 +25111,27 @@ when the first row in t2 is found.
 @item
 The table @code{B} is set to be dependent on table @code{A} and all tables
 that @code{A} is dependent on.
+
 @item
 The table @code{A} is set to be dependent on all tables (except @code{B})
 that are used in the @code{LEFT JOIN} condition.
+
 @item
 All @code{LEFT JOIN} conditions are moved to the @code{WHERE} clause.
+
 @item
 All standard join optimizations are done, with the exception that a table is
 always read after all tables it is dependent on.  If there is a circular
 dependence then MySQL will issue an error.
+
 @item
 All standard @code{WHERE} optimizations are done.
+
 @item
 If there is a row in @code{A} that matches the @code{WHERE} clause, but there
 wasn't any row in @code{B} that matched the @code{LEFT JOIN} condition,
 then an extra @code{B} row is generated with all columns set to @code{NULL}.
+
 @item
 If you use @code{LEFT JOIN} to find rows that don't exist in some
 table and you have the following test: @code{column_name IS NULL} in the
@@ -25112,8 +25154,8 @@ Note that the above means that if you do a query of type:
 SELECT * FROM a,b LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
 @end example
 
-MySQL will do a full scan on @code{b} as the @code{LEFT
-JOIN} will force it to be read before @code{d}.
+MySQL will do a full scan on @code{b} as the @code{LEFT JOIN} will force 
+it to be read before @code{d}.
 
 The fix in this case is to change the query to:
 
@@ -32174,8 +32216,13 @@ ON conditional_expr |
 USING (column_list)
 @end example
 
-Note that in versions before Version 3.23.16, the @code{INNER JOIN} didn't take
-a join condition!
+You should never have any conditions in the @code{ON} part that are used to
+restrict which rows you have in the result set.  If you want to restrict
+which rows should be in the result, you have to do this in the @code{WHERE}
+clause.
+
+Note that in versions before Version 3.23.16, the @code{INNER JOIN} didn't
+take a @code{join_condition}!
 
 @cindex ODBC compatibility
 @cindex compatibility, with ODBC
@@ -32733,7 +32780,7 @@ files have become corrupted.
 @example
     REPLACE [LOW_PRIORITY | DELAYED]
         [INTO] tbl_name [(col_name,...)]
-        VALUES (expression,...)
+        VALUES (expression,...),(...),...
 or  REPLACE [LOW_PRIORITY | DELAYED]
         [INTO] tbl_name [(col_name,...)]
         SELECT ...

From 2e6a193c0f1987094471361f72094fe659852d92 Mon Sep 17 00:00:00 2001
From: unknown <monty@bitch.mysql.fi>
Date: Wed, 22 Aug 2001 12:22:46 +0300
Subject: [PATCH 18/51] Fix to get core files on Solaris

BUILD/compile-solaris-sparc-purify:
  Added -g
---
 BUILD/compile-solaris-sparc-purify |  2 +-
 sql/mysqld.cc                      |  8 +++++---
 sql/stacktrace.c                   | 10 ++++++++--
 sql/stacktrace.h                   |  7 +------
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/BUILD/compile-solaris-sparc-purify b/BUILD/compile-solaris-sparc-purify
index 91fbbf1ae8d..8bb53bba876 100755
--- a/BUILD/compile-solaris-sparc-purify
+++ b/BUILD/compile-solaris-sparc-purify
@@ -6,7 +6,7 @@ aclocal && autoheader && aclocal && automake && autoconf
 (cd bdb/dist && sh s_all)
 (cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
 
-CFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-berkeley-db --with-innodb
+CFLAGS="-g -Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-g -Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti  -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-berkeley-db --with-innodb
 
 gmake -j 4
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 35aeaecc6e1..b484eee3480 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1247,12 +1247,14 @@ static void init_signals(void)
 
   sigset(THR_KILL_SIGNAL,end_thread_signal);
   sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
-  struct sigaction sa; sa.sa_flags = 0;
-  sigemptyset(&sa.sa_mask);
-  sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
 
   if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
   {
+    struct sigaction sa;
+    sa.sa_flags = SA_RESETHAND | SA_NODEFER;
+    sigemptyset(&sa.sa_mask);
+    sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
+
     init_stacktrace();
     sa.sa_handler=handle_segfault;
     sigaction(SIGSEGV, &sa, NULL);
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index ab1113f74cf..408006dac93 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -205,11 +205,17 @@ resolve it\n");
 
 /* Produce a core for the thread */
 
-#ifdef HAVE_WRITE_CORE
+#ifdef HAVE_LINUXTHREADS
 void write_core(int sig)
 {
   signal(sig, SIG_DFL);
   if (fork() != 0) exit(1);			// Abort main program
   // Core will be written at exit
 }
-#endif /* HAVE_WRITE_CORE */
+#else
+void write_core(int sig)
+{
+  signal(sig, SIG_DFL);
+  pthread_kill(pthread_self(), sig);
+}
+#endif
diff --git a/sql/stacktrace.h b/sql/stacktrace.h
index b6c0ec43a0f..980e1ea07eb 100644
--- a/sql/stacktrace.h
+++ b/sql/stacktrace.h
@@ -30,9 +30,6 @@ extern char* heap_start;
 void print_stacktrace(gptr stack_bottom, ulong thread_stack);
 void safe_print_str(const char* name, const char* val, int max_len);
 #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */
-
-#define HAVE_WRITE_CORE
-void write_core(int sig);
 #endif /* HAVE_LINUXTHREADS */
 
 /* Define empty prototypes for functions that are not implemented */
@@ -42,9 +39,7 @@ void write_core(int sig);
 #define safe_print_str(A,B,C) {}
 #endif /* HAVE_STACKTRACE */
 
-#ifndef HAVE_WRITE_CORE
-#define write_core(A) {}
-#endif
+void write_core(int sig);
 
 #ifdef	__cplusplus
 }

From 7374310f96778ad122f6e7006eaa81d759227d5b Mon Sep 17 00:00:00 2001
From: unknown <serg@serg.mysql.com>
Date: Wed, 22 Aug 2001 14:15:01 +0200
Subject: [PATCH 19/51] #include <my_pthread.h> extern "C" {

client/mysqlbinlog.cc:
  #include <my_pthread.h>
include/my_pthread.h:
  #ifdef _cplusplus
  extern "C" {
  #endif
---
 client/mysqlbinlog.cc | 1 +
 include/my_pthread.h  | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index f55a5a3f7c4..db28184f3e7 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -21,6 +21,7 @@
 #include <m_string.h>
 #include <my_sys.h>
 #include <getopt.h>
+#include <my_pthread.h>
 #include <thr_alarm.h>
 #include <mysql.h>
 #include "log_event.h"
diff --git a/include/my_pthread.h b/include/my_pthread.h
index d31d09896dc..79baa7a53e3 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -25,6 +25,10 @@
 #define ETIME ETIMEDOUT				/* For FreeBSD */
 #endif
 
+#ifdef  __cplusplus
+extern "C" {
+#endif /* __cplusplus */ 
+
 #if defined(__WIN__) || defined(OS2)
 
 #ifdef OS2
@@ -612,4 +616,9 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
 #endif /* SAFE_STATISTICS */
 #endif /* HAVE_ATOMIC_ADD */
 #endif /* thread_safe_increment */
+
+#ifdef  __cplusplus
+}
+#endif
+
 #endif /* _my_ptread_h */

From 2707d6f271ded62b6056ebbc985c0d80c26afb38 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Wed, 22 Aug 2001 13:55:28 -0500
Subject: [PATCH 20/51] Texinfo menus fixed.

---
 Docs/manual.texi | 713 +++++++++++++++++++++++------------------------
 1 file changed, 356 insertions(+), 357 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 246a3747576..c2acf5f336a 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -111,15 +111,15 @@ distribution for that version.
 * Introduction::                General Information about MySQL
 * Installing::                  Installing MySQL
 * Tutorial::                    MySQL Tutorial
-* MySQL Database Administration::  
-* MySQL Optimization::          
+* MySQL Database Administration::  MySQL Database Administration
+* MySQL Optimization::          MySQL Optimization
 * Reference::                   MySQL language reference
 * Table types::                 MySQL table types
 * Clients::                     MySQL client tools and APIs
-* Extending MySQL::             
+* Extending MySQL::             Extending MySQL
 * Problems::                    Problems
 * Users::                       Some MySQL users
-* MySQL customer usage::        
+* MySQL customer usage::        MySQL customer usage
 * Contrib::                     Contributed programs
 * Credits::                     Contributors to MySQL
 * News::                        MySQL change history
@@ -129,10 +129,9 @@ distribution for that version.
 * Unireg::                      What is Unireg?
 * GPL license::                 GNU General Public License
 * LGPL license::                GNU Library General Public License
-* Placeholder::                 
+* Placeholder::                 Pieces of the manual in transit
 * Function Index::              SQL command, type and function index
 * Concept Index::               Concept Index
-
 @end menu
 
 
@@ -234,12 +233,12 @@ MySQL, see @ref{MySQL-Books}.
 
 
 @menu
-* MySQL and MySQL AB::          
-* MySQL Information Sources::   
-* Licensing and Support::       
-* Compatibility::               
-* Comparisons::                 
-* TODO::                        
+* MySQL and MySQL AB::          MySQL, MySQL AB, and Open Source
+* MySQL Information Sources::   MySQL Information Sources
+* Licensing and Support::       MySQL Licensing and Support
+* Compatibility::               How Standards-compatible Is MySQL?
+* Comparisons::                 How MySQL Compares to Other Databases
+* TODO::                        MySQL and the future (The TODO)
 @end menu
 
 
@@ -254,7 +253,7 @@ MySQL, see @ref{MySQL-Books}.
 * History::                     History of MySQL
 * Features::                    The main features of MySQL
 * Stability::                   How stable is MySQL?
-* Table size::                  
+* Table size::                  How Big Can MySQL Tables Be?
 * Year 2000 compliance::        Year 2000 compliance
 @end menu
 
@@ -1119,10 +1118,10 @@ values).
 @cindex books, about MySQL
 
 @menu
-* MySQL-Books::                 
-* General-SQL::                 
-* Useful Links::                
-* Questions::                   
+* MySQL-Books::                 Books About MySQL
+* General-SQL::                 General SQL Information and Tutorials
+* Useful Links::                Useful MySQL-related Links
+* Questions::                   MySQL Mailing Lists
 @end menu
 
 
@@ -3378,7 +3377,7 @@ to help you get the problem solved.
 * Missing functions::           Functionality missing from MySQL
 * Standards::                   What standards does MySQL follow?
 * Commit-rollback::             How to cope without @code{COMMIT}-@code{ROLLBACK}
-* Bugs::                        
+* Bugs::                        Known errors and design deficiencies in MySQL
 @end menu
 
 This section describes how MySQL relates to the ANSI SQL standards.
@@ -3709,7 +3708,7 @@ list in this manual. @xref{TODO}.
 * Missing Transactions::        Transactions
 * Missing Triggers::            Triggers
 * Missing Foreign Keys::        Foreign Keys
-* Broken Foreign KEY::          
+* Broken Foreign KEY::          Reasons NOT to Use Foreign Keys constraints
 * Missing Views::               Views
 * Missing comments::            @samp{--} as the start of a comment
 @end menu
@@ -4718,8 +4717,8 @@ MySQL usually takes a couple of minutes.
 
 @menu
 * Using mSQL tools::            How to convert @code{mSQL} tools for MySQL
-* Protocol differences::        
-* Syntax differences::          
+* Protocol differences::        How @code{mSQL} and MySQL Client/Server Communications Protocols Differ
+* Syntax differences::          How @code{mSQL} 2.0 SQL Syntax Differs from MySQL
 @end menu
 
 
@@ -4804,7 +4803,7 @@ If a connection is idle for 8 hours, the server closes the connection.
 @end itemize
 
 @menu
-* Syntax differences::          
+* Syntax differences::          How @code{mSQL} 2.0 SQL Syntax Differs from MySQL
 @end menu
 
 
@@ -5025,8 +5024,8 @@ can offer, you should use @code{PostgreSQL}.
 @cindex PostgreSQL/MySQL, strategies
 @menu
 * MySQL-PostgreSQL goals::      MySQL and PostgreSQL development strategies
-* MySQL-PostgreSQL features::   
-* MySQL-PostgreSQL benchmarks::  
+* MySQL-PostgreSQL features::   Featurewise Comparison of MySQL and PostgreSQL
+* MySQL-PostgreSQL benchmarks::  Benchmarking MySQL and PostgreSQL
 @end menu
 
 
@@ -5320,7 +5319,7 @@ For a complete list of drawbacks, you should also examine the first table
 in this section.
 
 @menu
-* MySQL-PostgreSQL benchmarks::  
+* MySQL-PostgreSQL benchmarks::  Benchmarking MySQL and PostgreSQL
 @end menu
 
 
@@ -6061,12 +6060,12 @@ Nothing;  In the long run we plan to be fully ANSI 92 / ANSI 99 compliant.
 @cindex installing, overview
 
 @menu
-* Quick Standard Installation::  
-* General Installation Issues::  
-* Installing source::           Installing a MySQL source distribution
-* Post-installation::           Post-installation setup and testing
-* Upgrade::                     Upgrading/Downgrading MySQL
-* Operating System Specific Notes::  
+* Quick Standard Installation::  Quick Standard Installation of MySQL
+* General Installation Issues::  General Installation Issues
+* Installing source::            Installing a MySQL source distribution
+* Post-installation::            Post-installation setup and testing
+* Upgrade::                      Upgrading/Downgrading MySQL
+* Operating System Specific Notes::  Operating System Specific Notes
 @end menu
 
 This chapter describes how to obtain and install MySQL:
@@ -6108,8 +6107,8 @@ source distribution.
 
 @c This node name is special
 @menu
-* Linux-RPM::                   
-* Windows installation::        
+* Linux-RPM::                   Installing MySQL on Linux
+* Windows installation::        Installing MySQL on Windows
 @end menu
 
 
@@ -6270,12 +6269,12 @@ options that must be specified in your @file{my.ini} file! @xref{InnoDB start}.
 @c FIX: this needs to be written? 
 
 @menu
-* Getting MySQL::               
-* Which OS::                    
-* Which version::               
-* Installation layouts::        
-* Many versions::               
-* MySQL binaries::              
+* Getting MySQL::               How to Get MySQL
+* Which OS::                    Operating Systems Supported by MySQL
+* Which version::               Which MySQL Version to Use
+* Installation layouts::        Installation Layouts
+* Many versions::               How and When Updates Are Released
+* MySQL binaries::              MySQL Binaries Compiled by MySQL AB
 @end menu
 
 
@@ -7674,9 +7673,9 @@ of getting a solution to your problem!  You will find @code{mysqlbug} in the
 * Quick install::               Quick installation overview
 * Applying patches::            Applying patches
 * configure options::           Typical @code{configure} options
-* Installing source tree::      
-* Compilation problems::        
-* MIT-pthreads::                
+* Installing source tree::      Installing from the Development Source Tree
+* Compilation problems::        Problems Compiling?
+* MIT-pthreads::                MIT-pthreads Notes
 @end menu
 
 
@@ -9541,15 +9540,15 @@ information.
 @section Operating System Specific Notes
 
 @menu
-* Linux::                       
-* Windows::                     
-* Solaris::                     
-* BSD Notes::                   
-* Mac OS X::                    
-* Other Unix Notes::            
-* OS/2::                        
-* BeOS::                        
-* Novell Netware::              
+* Linux::                       Linux Notes (All Linux Versions)
+* Windows::                     Windows Notes
+* Solaris::                     Solaris Notes
+* BSD Notes::                   BSD Notes
+* Mac OS X::                    Mac OS X Notes
+* Other Unix Notes::            Other Unix Notes
+* OS/2::                        OS/2 Notes
+* BeOS::                        BeOS Notes
+* Novell Netware::              Novell Netware Notes
 @end menu
 
 
@@ -9557,13 +9556,13 @@ information.
 @subsection Linux Notes (All Linux Versions)
 
 @menu
-* Binary notes-Linux::          
-* Linux-x86::                   Linux-x86 notes
-* Linux-SPARC::                 Linux-SPARC notes
-* Linux-Alpha::                 Linux-Alpha notes
-* Linux-PowerPC::               
-* Linux-MIPS::                  
-* Linux-IA64::                  Linux-Ia64 notes
+* Binary notes-Linux::          Linux Notes for Binary Distributions
+* Linux-x86::                   Linux x86 Notes
+* Linux-SPARC::                 Linux SPARC Notes
+* Linux-Alpha::                 Linux Alpha Notes
+* Linux-PowerPC::               Linux PowerPC Notes
+* Linux-MIPS::                  Linux MIPS Notes
+* Linux-IA64::                  Linux IA64 Notes
 @end menu
 
 The notes below regarding @strong{glibc} apply only to the situation
@@ -10819,8 +10818,8 @@ symbolic link to it named @file{/etc/rc3.d/S99mysql.server}.
 
 
 @menu
-* Solaris 2.7::                 
-* Solaris x86::                 
+* Solaris 2.7::                 Solaris 2.7/2.8 Notes
+* Solaris x86::                 Solaris x86 Notes
 @end menu
 
 
@@ -10932,15 +10931,15 @@ it with a trace file or under @code{gdb}.  @xref{Using gdb on mysqld}.
 @subsection BSD Notes
 
 @menu
-* FreeBSD::                     
-* NetBSD::                      
-* OpenBSD::                     
-* OpenBSD 2.5::                 
-* OpenBSD 2.8::                 
-* BSDI::                        
-* BSDI2::                       
-* BSDI3::                       
-* BSDI4::                       
+* FreeBSD::                     FreeBSD Notes
+* NetBSD::                      NetBSD notes
+* OpenBSD::                     OpenBSD Notes
+* OpenBSD 2.5::                 OpenBSD 2.5 Notes
+* OpenBSD 2.8::                 OpenBSD 2.8 Notes
+* BSDI::                        BSD/OS Notes
+* BSDI2::                       BSD/OS Version 2.x Notes
+* BSDI3::                       BSD/OS Version 3.x Notes
+* BSDI4::                       BSD/OS Version 4.x Notes
 @end menu
 
 
@@ -11159,8 +11158,8 @@ on BSDI!  (Making a symbolic link to another disk is ok).
 @subsection Mac OS X Notes
 
 @menu
-* Mac OS X Public Beta::        
-* Mac OS X Server::             
+* Mac OS X Public Beta::        Mac OS X Public Beta
+* Mac OS X Server::             Mac OS X Server
 @end menu
 
 
@@ -11198,16 +11197,16 @@ alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
 @subsection Other Unix Notes
 
 @menu
-* Binary notes-HP-UX::          
-* HP-UX 10.20::                 
-* HP-UX 11.x::                  
-* IBM-AIX::                     
-* SunOS::                       
-* Alpha-DEC-UNIX::              
-* Alpha-DEC-OSF1::              
-* SGI-Irix::                    
-* SCO::                         
-* SCO Unixware::                
+* Binary notes-HP-UX::          HP-UX Notes for Binary Distributions
+* HP-UX 10.20::                 HP-UX Version 10.20 Notes
+* HP-UX 11.x::                  HP-UX Version 11.x Notes
+* IBM-AIX::                     IBM-AIX notes
+* SunOS::                       SunOS 4 Notes
+* Alpha-DEC-UNIX::              Alpha-DEC-UNIX Notes (Tru64)
+* Alpha-DEC-OSF1::              Alpha-DEC-OSF1 Notes
+* SGI-Irix::                    SGI Irix Notes
+* SCO::                         SCO Notes
+* SCO Unixware::                SCO Unixware Version 7.0 Notes
 @end menu
 
 
@@ -11982,7 +11981,7 @@ If you want to use @code{gcc}, you must use @code{gcc} 2.95.2 or newer.
 
 
 @menu
-* OS/2::                        
+* OS/2::                        OS/2 Notes
 @end menu
 
 
@@ -12088,7 +12087,7 @@ with any technical questions they may have while doing the port.
 * Examples::                    Examples
 * Batch mode::                  Using @code{mysql} in batch mode
 * Twin::                        Queries from twin project
-* Apache::                      
+* Apache::                      Using MySQL with Apache
 @end menu
 
 This chapter provides a tutorial introduction to MySQL by showing
@@ -12753,7 +12752,7 @@ than a single @code{LOAD DATA} statement.
 * Working with NULL::           Working with @code{NULL} values
 * Pattern matching::            Pattern matching
 * Counting rows::               Counting rows
-* Multiple tables::             
+* Multiple tables::             Using More Than one Table
 @end menu
 
 The @code{SELECT} statement is used to pull information from a table.
@@ -13875,8 +13874,8 @@ mysql> SELECT * FROM shop;
 * example-Maximum-column-group-row::  The rows holding the group-wise maximum of a certain field
 * example-user-variables::      Using user variables
 * example-Foreign keys::        Using foreign keys
-* Searching on two keys::       
-* Calculating days::            
+* Searching on two keys::       Searching on Two Keys
+* Calculating days::            Calculating visits per day
 @end menu
 
 
@@ -14536,16 +14535,16 @@ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
 @chapter MySQL Database Administration
 
 @menu
-* Configuring MySQL::           
-* Privilege system::            
-* User Account Management::     
-* Disaster Prevention::         
-* Database Administration::     
-* Localization::                
-* Server-Side Scripts::         
-* Client-Side Scripts::         
-* Log Files::                   
-* Replication::                 
+* Configuring MySQL::           Configuring MySQL
+* Privilege system::            General Security Issues and the MySQL Access Privilege System
+* User Account Management::     MySQL User Account Management
+* Disaster Prevention::         Disaster Prevention and Recovery
+* Database Administration::     Database Administration Language Reference
+* Localization::                MySQL Localization and International Usage
+* Server-Side Scripts::         MySQL Server-Side Scripts and Utilities
+* Client-Side Scripts::         MySQL Client-Side Scripts and Utilities
+* Log Files::                   The MySQL Log Files
+* Replication::                 Replication in MySQL
 @end menu
 
 
@@ -14554,10 +14553,10 @@ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
 
 
 @menu
-* Command-line options::        
-* Option files::                
-* Installing many servers::     
-* Multiple servers::            
+* Command-line options::        mysqld Command-line Options
+* Option files::                my.cnf Option Files
+* Installing many servers::     Installing Many Servers on the Same Machine
+* Multiple servers::            Running Multiple MySQL Servers on the Same Machine
 @end menu
 
 
@@ -15079,7 +15078,7 @@ argument to @code{safe_mysqld}.
 
 
 @menu
-* Multiple servers::            
+* Multiple servers::            Running Multiple MySQL Servers on the Same Machine
 @end menu
 
 
@@ -15226,7 +15225,7 @@ system.  This section describes how it works.
 @menu
 * General security::            General security
 * Security::                    How to make MySQL secure against crackers
-* Privileges options::          
+* Privileges options::          Startup Options for @code{mysqld} Concerning Security
 * What Privileges::             What the privilege system does
 * Privileges::                  How the privilege system works
 * Privileges provided::         Privileges provided by MySQL
@@ -16779,13 +16778,13 @@ to restart @code{mysqld} with @code{--skip-grant-tables} to run
 @section MySQL User Account Management
 
 @menu
-* GRANT::                       
-* User names::                  
-* Privilege changes::           
-* Default privileges::          
-* Adding users::                
-* Passwords::                   
-* Password security::           
+* GRANT::                       @code{GRANT} and @code{REVOKE} Syntax
+* User names::                  MySQL User Names and Passwords
+* Privilege changes::           When Privilege Changes Take Effect
+* Default privileges::          Setting Up the Initial MySQL Privileges
+* Adding users::                Adding New Users to MySQL
+* Passwords::                   Setting Up Passwords
+* Password security::           Keeping Your Password Secure
 @end menu
 
 
@@ -17602,14 +17601,14 @@ file.
 @section Disaster Prevention and Recovery
 
 @menu
-* Backup::                      
-* BACKUP TABLE::                
-* RESTORE TABLE::               
-* CHECK TABLE::                 
-* REPAIR TABLE::                
-* Table maintenance::           
-* Maintenance regimen::         
-* Table-info::                  
+* Backup::                      Database Backups
+* BACKUP TABLE::                @code{BACKUP TABLE} Syntax
+* RESTORE TABLE::               @code{RESTORE TABLE} Syntax
+* CHECK TABLE::                 @code{CHECK TABLE} Syntax
+* REPAIR TABLE::                @code{REPAIR TABLE} Syntax
+* Table maintenance::           Using @code{myisamchk} for Table Maintenance and Crash Recovery
+* Maintenance regimen::         Setting Up a Table Maintenance Regimen
+* Table-info::                  Getting Information About a Table
 @end menu
 
 
@@ -17968,16 +17967,16 @@ good idea to make a backup BEFORE doing a repair (or anything that could
 make a lot of changes to a table)
 
 @menu
-* myisamchk syntax::            
-* myisamchk general options::   
-* myisamchk check options::     
-* myisamchk repair options::    
-* myisamchk other options::     
-* myisamchk memory::            
-* Crash recovery::              
-* Check::                       
-* Repair::                      
-* Optimization::                
+* myisamchk syntax::            @code{myisamchk} Invocation Syntax
+* myisamchk general options::   General Options for @code{myisamchk}
+* myisamchk check options::     Check Options for @code{myisamchk}
+* myisamchk repair options::    Repair Options for myisamchk
+* myisamchk other options::     Other Options for @code{myisamchk}
+* myisamchk memory::            @code{myisamchk} Memory Usage
+* Crash recovery::              Using @code{myisamchk} for Crash Recovery
+* Check::                       How to Check Tables for Errors
+* Repair::                      How to Repair Tables
+* Optimization::                Table Optimization
 @end menu
 
 
@@ -18063,10 +18062,10 @@ the easiest way to avoid this problem is to use @code{CHECK TABLE}
 instead of @code{myisamchk} to check tables.
 
 @menu
-* myisamchk general options::   
-* myisamchk check options::     
-* myisamchk repair options::    
-* myisamchk other options::     
+* myisamchk general options::   General Options for @code{myisamchk}
+* myisamchk check options::     Check Options for @code{myisamchk}
+* myisamchk repair options::    Repair Options for myisamchk
+* myisamchk other options::     Other Options for @code{myisamchk}
 @end menu
 
 
@@ -19071,11 +19070,11 @@ information and a description of what it means.
 
 
 @menu
-* OPTIMIZE TABLE::              
-* ANALYZE TABLE::               
-* FLUSH::                       
-* KILL::                        
-* SHOW::                        
+* OPTIMIZE TABLE::              @code{OPTIMIZE TABLE} Syntax
+* ANALYZE TABLE::               @code{ANALYZE TABLE} Syntax
+* FLUSH::                       @code{FLUSH} Syntax
+* KILL::                        @code{KILL} Syntax
+* SHOW::                        @code{SHOW} Syntax
 @end menu
 
 
@@ -19276,7 +19275,7 @@ write is aborted with an disk full error message.
 
 
 @menu
-* SHOW::                        
+* SHOW::                        @code{SHOW} Syntax
 @end menu
 
 
@@ -19325,14 +19324,14 @@ used, the @code{wild} string can be a string that uses the SQL @samp{%}
 and @samp{_} wild-card characters.
 
 @menu
-* SHOW DATABASE INFO::          
-* SHOW TABLE STATUS::           
-* SHOW STATUS::                 
-* SHOW VARIABLES::              
-* SHOW LOGS::                   
-* SHOW PROCESSLIST::            
-* SHOW GRANTS::                 
-* SHOW CREATE TABLE::           
+* SHOW DATABASE INFO::          Retrieving information about Database, Tables, Columns, and Indexes
+* SHOW TABLE STATUS::           @code{SHOW TABLE STATUS}
+* SHOW STATUS::                 @code{SHOW STATUS}
+* SHOW VARIABLES::              @code{SHOW VARIABLES}
+* SHOW LOGS::                   @code{SHOW LOGS}
+* SHOW PROCESSLIST::            @code{SHOW PROCESSLIST}
+* SHOW GRANTS::                 @code{SHOW GRANTS}
+* SHOW CREATE TABLE::           @code{SHOW CREATE TABLE}
 @end menu
 
 
@@ -20240,12 +20239,12 @@ Create Table: CREATE TABLE t (
 @section MySQL Localization and International Usage
 
 @menu
-* Character sets::              
-* Languages::                   
-* Adding character set::        
-* Character arrays::            
-* String collating::            
-* Multi-byte characters::       
+* Character sets::              The Character Set Used for Data and Sorting
+* Languages::                   Non-English Error Messages
+* Adding character set::        Adding a New Character Set
+* Character arrays::            The character definition arrays
+* String collating::            String Collating Support
+* Multi-byte characters::       Multi-byte Character Support
 @end menu
 
 
@@ -20574,11 +20573,11 @@ size in bytes of the largest character in the set.
 @section MySQL Server-Side Scripts and Utilities
 
 @menu
-* Server-Side Overview::        
-* safe_mysqld::                 
-* mysqld_multi::                
-* myisampack::                  
-* mysqld-max::                  
+* Server-Side Overview::        Overview of the Server-Side Scripts and Utilities
+* safe_mysqld::                 safe_mysqld, the wrapper around mysqld
+* mysqld_multi::                mysqld_multi, program for managing multiple MySQL servers
+* myisampack::                  myisampack, The MySQL Compressed Read-only Table Generator
+* mysqld-max::                  mysqld-max, An extended mysqld server
 @end menu
 
 
@@ -21498,16 +21497,16 @@ binaries includes:
 @section MySQL Client-Side Scripts and Utilities
 
 @menu
-* Client-Side Overview::        
-* mysql::                       
-* mysqladmin::                  
-* Using mysqlcheck::            
-* mysqldump::                   
-* mysqlhotcopy::                
-* mysqlimport::                 
-* mysqlshow::                   
-* perror::                      
-* Batch Commands::              
+* Client-Side Overview::        Overview of the Client-Side Scripts and Utilities
+* mysql::                       The Command-line Tool
+* mysqladmin::                  mysqladmin, Administrating a MySQL Server
+* Using mysqlcheck::            Using @code{mysqlcheck} for Table Maintenance and Crash Recovery
+* mysqldump::                   mysqldump, Dumping Table Structure and Data
+* mysqlhotcopy::                mysqlhotcopy, Copying MySQL Databases and Tables
+* mysqlimport::                 mysqlimport, Importing Data from Text Files
+* mysqlshow::                   Showing Databases, Tables, and Columns
+* perror::                      perror, Explaining Error Codes
+* Batch Commands::              How to Run SQL Commands from a Text File
 @end menu
 
 
@@ -22812,12 +22811,12 @@ force @code{mysqld} to reopen the log files (or in some cases
 switch to a new log) by executing @code{FLUSH LOGS}. @xref{FLUSH}.
 
 @menu
-* Error log::                   
-* Query log::                   
-* Update log::                  
-* Binary log::                  
-* Slow query log::              
-* Log file maintenance::        
+* Error log::                   The Error Log
+* Query log::                   The General Query Log
+* Update log::                  The Update Log
+* Binary log::                  The Binary Update Log
+* Slow query log::              The Slow Query Log
+* Log file maintenance::        Log File Maintenance
 @end menu
 
 
@@ -23108,14 +23107,14 @@ and then take a backup and remove @file{mysql.old}.
 @cindex databases, replicating
 
 @menu
-* Replication Intro::           
-* Replication Implementation::  
-* Replication HOWTO::           
-* Replication Features::        
-* Replication Options::         
-* Replication SQL::             
-* Replication FAQ::             
-* Replication Problems::        
+* Replication Intro::           Introduction
+* Replication Implementation::  Replication Implementation Overview
+* Replication HOWTO::           How To Set Up Replication
+* Replication Features::        Replication Features and Known Problems
+* Replication Options::         Replication Options in my.cnf
+* Replication SQL::             SQL Commands Related to Replication
+* Replication FAQ::             Replication FAQ
+* Replication Problems::        Troubleshooting Replication
 @end menu
 
 This chapter describes the various replication features in MySQL.
@@ -23319,11 +23318,11 @@ it is preferred that you use @code{CHANGE MASTER TO} command.
 
 
 @menu
-* Replication Features::        
-* Replication Options::         
-* Replication SQL::             
-* Replication FAQ::             
-* Replication Problems::        
+* Replication Features::        Replication Features and Known Problems
+* Replication Options::         Replication Options in my.cnf
+* Replication SQL::             SQL Commands Related to Replication
+* Replication FAQ::             Replication FAQ
+* Replication Problems::        Troubleshooting Replication
 @end menu
 
 
@@ -24118,12 +24117,12 @@ isolate it into a separate test case first. Then report the problem to
 @chapter MySQL Optimization
 
 @menu
-* Optimize Overview::           
-* Query Speed::                 
-* Locking Issues::              
-* Optimizing Database Structure::  
-* Optimizing the Server::       
-* Disk issues::                 
+* Optimize Overview::           Optimization Overview
+* Query Speed::                 Optimizing @code{SELECT}s and Other Queries
+* Locking Issues::              Locking Issues
+* Optimizing Database Structure::  Optimizing Database Structure
+* Optimizing the Server::       Optimizing the MySQL Server
+* Disk issues::                 Disk Issues
 @end menu
 
 
@@ -24175,11 +24174,11 @@ for most systems, but one should be aware of it.
 
 
 @menu
-* Design Limitations::          
-* Portability::                 
-* Internal use::                
-* MySQL Benchmarks::            
-* Custom Benchmarks::           
+* Design Limitations::          MySQL Design Limitations/Tradeoffs
+* Portability::                 Portability
+* Internal use::                What Have We Used MySQL For?
+* MySQL Benchmarks::            The MySQL Benchmark Suite
+* Custom Benchmarks::           Using Your Own Benchmarks
 @end menu
 
 
@@ -24503,7 +24502,7 @@ some exceptions, and the @code{benchmark(loop_count,expression)} is a
 great tool to find out if this is a problem with your query.
 
 @menu
-* EXPLAIN::                     
+* EXPLAIN::                     @code{EXPLAIN} Syntax (Get Information About a @code{SELECT})
 * Estimating performance::      Estimating query performance
 * SELECT speed::                Speed of @code{SELECT} queries
 * Where optimizations::         How MySQL optimizes @code{WHERE} clauses
@@ -24513,7 +24512,7 @@ great tool to find out if this is a problem with your query.
 * Insert speed::                Speed of @code{INSERT} queries
 * Update speed::                Speed of @code{UPDATE} queries
 * Delete speed::                Speed of @code{DELETE} queries
-* Tips::                        
+* Tips::                        Other Optimization Tips
 @end menu
 
 
@@ -25550,8 +25549,8 @@ from the data, you should not lose anything by using @code{DELAY_KEY_WRITE}.
 
 
 @menu
-* Internal locking::            
-* Table locking::               
+* Internal locking::            How MySQL Locks Tables
+* Table locking::               Table Locking Issues
 @end menu
 
 
@@ -25734,14 +25733,14 @@ option to @code{DELETE} may help. @xref{DELETE, , @code{DELETE}}.
 
 
 @menu
-* Design::                      
-* Data size::                   
-* MySQL indexes::               
-* Indexes::                     
-* Multiple-column indexes::     
-* Table cache::                 
-* Creating many tables::        
-* Open tables::                 
+* Design::                      Design Choices
+* Data size::                   Get Your Data as Small as Possible
+* MySQL indexes::               How MySQL Uses Indexes
+* Indexes::                     Column Indexes
+* Multiple-column indexes::     Multiple-Column Indexes
+* Table cache::                 How MySQL Opens and Closes Tables
+* Creating many tables::        Drawbacks to Creating Large Numbers of Tables in the Same Database
+* Open tables::                 Why So Many Open tables?
 @end menu
 
 
@@ -26035,11 +26034,11 @@ much more quickly find the few rows to return in the result.
 
 
 @menu
-* Indexes::                     
-* Multiple-column indexes::     
-* Table cache::                 
-* Creating many tables::        
-* Open tables::                 
+* Indexes::                     Column Indexes
+* Multiple-column indexes::     Multiple-Column Indexes
+* Table cache::                 How MySQL Opens and Closes Tables
+* Creating many tables::        Drawbacks to Creating Large Numbers of Tables in the Same Database
+* Open tables::                 Why So Many Open tables?
 @end menu
 
 
@@ -26249,12 +26248,12 @@ between all threads.
 
 
 @menu
-* System::                      
-* Server parameters::           
-* Compile and link options::    
-* Memory use::                  
-* DNS::                         
-* SET OPTION::                  
+* System::                      System/Compile Time and Startup Parameter Tuning
+* Server parameters::           Tuning Server Parameters
+* Compile and link options::    How Compiling and Linking Affects the Speed of MySQL
+* Memory use::                  How MySQL Uses Memory
+* DNS::                         How MySQL uses DNS
+* SET OPTION::                  @code{SET} Syntax
 @end menu
 
 
@@ -26847,7 +26846,7 @@ with the update log.
 
 
 @menu
-* SET TRANSACTION::             
+* SET TRANSACTION::             @code{SET TRANSACTION} Syntax
 @end menu
 
 
@@ -26944,7 +26943,7 @@ with the noatime flag.
 @end itemize
 
 @menu
-* Symbolic links::              
+* Symbolic links::              Using Symbolic Links
 @end menu
 
 
@@ -26965,8 +26964,8 @@ disk and only symlink tables as a last resort.
 
 @cindex databases, symbolic links
 @menu
-* Symbolic links to databases::  
-* Symbolic links to tables::    
+* Symbolic links to databases::  Using Symbolic Links for Databases
+* Symbolic links to tables::    Using Symbolic Links for Tables
 @end menu
 
 
@@ -27101,14 +27100,14 @@ Things that are not yet supported:
 @chapter MySQL Language Reference
 
 @menu
-* Language Structure::          
+* Language Structure::          Language Structure
 * Column types::                Column types
 * Functions::                   Functions
-* Data Manipulation::           
-* Data Definition::             
-* Basic User Commands::         
-* Transactional Commands::      
-* Fulltext Search::             
+* Data Manipulation::           Data Manipulation: @code{SELECT}, @code{INSERT}, @code{UPDATE}, @code{DELETE}
+* Data Definition::             Data Definition: @code{CREATE}, @code{DROP}, @code{ALTER}
+* Basic User Commands::         Basic MySQL User Utility Commands
+* Transactional Commands::      MySQL Transactional and Locking Commands
+* Fulltext Search::             MySQL Full-text Search
 @end menu
 
 MySQL has a very complex, but intuitive and easy to learn SQL
@@ -27123,12 +27122,12 @@ may find it useful to refer to the various indexes.
 @section Language Structure
 
 @menu
-* Literals::                    
-* Legal names::                 
-* Name case sensitivity::       
-* Variables::                   
-* Comments::                    
-* Reserved words::              
+* Literals::                    Literals: How to Write Strings and Numbers
+* Legal names::                 Database, Table, Index, Column, and Alias Names
+* Name case sensitivity::       Case Sensitivity in Names
+* Variables::                   User Variables
+* Comments::                    Comment Syntax
+* Reserved words::              Is MySQL Picky About Reserved Words?
 @end menu
 
 
@@ -27594,8 +27593,8 @@ row, but the value of @code{id} for the previous accepted row.
 
 
 @menu
-* Comments::                    
-* Reserved words::              
+* Comments::                    Comment Syntax
+* Reserved words::              Is MySQL Picky About Reserved Words?
 @end menu
 
 @node Comments, Reserved words, Variables, Language Structure
@@ -29281,11 +29280,11 @@ mysql> select MOD(29,9);
 @end example
 
 @menu
-* Non-typed Operators::         
+* Non-typed Operators::         Non-Type-Specific Operators and Functions
 * String functions::            String functions
-* Numeric Functions::           
+* Numeric Functions::           Numeric Functions
 * Date and time functions::     Date and time functions
-* Other Functions::             
+* Other Functions::             Other Functions
 @end menu
 
 
@@ -29293,10 +29292,10 @@ mysql> select MOD(29,9);
 @subsection Non-Type-Specific Operators and Functions
 
 @menu
-* Parenthesis::                 
-* Comparison Operators::        
-* Logical Operators::           
-* Control flow functions::      
+* Parenthesis::                 Parenthesis
+* Comparison Operators::        Comparison Operators
+* Logical Operators::           Logical Operators
+* Control flow functions::      Control Flow Functions
 @end menu
 
 
@@ -30321,8 +30320,8 @@ a binary string.  This only affects comparisons.
 
 
 @menu
-* String comparison functions::  
-* Case Sensitivity Operators::  
+* String comparison functions::  String Comparison Functions
+* Case Sensitivity Operators::  Case Sensitivity
 @end menu
 
 @node String comparison functions, Case Sensitivity Operators, String functions, String functions
@@ -30518,8 +30517,8 @@ make string comparison even more flexible.
 @subsection Numeric Functions
 
 @menu
-* Arithmetic functions::        
-* Mathematical functions::      
+* Arithmetic functions::        Arithmetic Operations
+* Mathematical functions::      Mathematical Functions
 @end menu
 
 
@@ -31527,8 +31526,8 @@ mysql> select TIME_TO_SEC('00:39:38');
 @subsection Other Functions
 
 @menu
-* Bit functions::               
-* Miscellaneous functions::     
+* Bit functions::               Bit Functions
+* Miscellaneous functions::     Miscellaneous Functions
 @end menu
 
 
@@ -31885,14 +31884,14 @@ facilitate replication testing.
 
 
 @menu
-* SELECT::                      
-* INSERT::                      
-* INSERT DELAYED::              
-* UPDATE::                      
-* DELETE::                      
-* TRUNCATE::                    
-* REPLACE::                     
-* LOAD DATA::                   
+* SELECT::                      @code{SELECT} Syntax
+* INSERT::                      @code{INSERT} Syntax
+* INSERT DELAYED::              @code{INSERT DELAYED} syntax
+* UPDATE::                      @code{UPDATE} Syntax
+* DELETE::                      @code{DELETE} Syntax
+* TRUNCATE::                    @code{TRUNCATE} Syntax
+* REPLACE::                     @code{REPLACE} Syntax
+* LOAD DATA::                   @code{LOAD DATA INFILE} Syntax
 @end menu
 
 @node SELECT, INSERT, Data Manipulation, Data Manipulation
@@ -32172,7 +32171,7 @@ the examined rows will be write locked.
 
 
 @menu
-* JOIN::                        
+* JOIN::                        @code{JOIN} Syntax
 @end menu
 
 @node JOIN,  , SELECT, SELECT
@@ -32459,7 +32458,7 @@ type.  The column is set to the appropriate zero value for the type.
 @findex INSERT ... SELECT
 
 @menu
-* INSERT SELECT::               
+* INSERT SELECT::               @code{INSERT ... SELECT} Syntax
 @end menu
 
 
@@ -33310,14 +33309,14 @@ For more information about the efficiency of @code{INSERT} versus
 @section Data Definition: @code{CREATE}, @code{DROP}, @code{ALTER}
 
 @menu
-* CREATE DATABASE::             
-* DROP DATABASE::               
-* CREATE TABLE::                
-* ALTER TABLE::                 
-* RENAME TABLE::                
-* DROP TABLE::                  
-* CREATE INDEX::                
-* DROP INDEX::                  
+* CREATE DATABASE::             @code{CREATE DATABASE} Syntax
+* DROP DATABASE::               @code{DROP DATABASE} Syntax
+* CREATE TABLE::                @code{CREATE TABLE} Syntax
+* ALTER TABLE::                 @code{ALTER TABLE} Syntax
+* RENAME TABLE::                @code{RENAME TABLE} Syntax
+* DROP TABLE::                  @code{DROP TABLE} Syntax
+* CREATE INDEX::                @code{CREATE INDEX} Syntax
+* DROP INDEX::                  @code{DROP INDEX} Syntax
 @end menu
 
 
@@ -33384,12 +33383,12 @@ You can also drop databases with @code{mysqladmin}. @xref{Client-Side Scripts}.
 
 
 @menu
-* CREATE TABLE::                
-* ALTER TABLE::                 
-* RENAME TABLE::                
-* DROP TABLE::                  
-* CREATE INDEX::                
-* DROP INDEX::                  
+* CREATE TABLE::                @code{CREATE TABLE} Syntax
+* ALTER TABLE::                 @code{ALTER TABLE} Syntax
+* RENAME TABLE::                @code{RENAME TABLE} Syntax
+* DROP TABLE::                  @code{DROP TABLE} Syntax
+* CREATE INDEX::                @code{CREATE INDEX} Syntax
+* DROP INDEX::                  @code{DROP INDEX} Syntax
 @end menu
 
 @node CREATE TABLE, ALTER TABLE, DROP DATABASE, Data Definition
@@ -34312,8 +34311,8 @@ prior to Version 3.22.  In Version 3.22 or later, @code{DROP INDEX} is mapped to
 @section Basic MySQL User Utility Commands
 
 @menu
-* USE::                         
-* DESCRIBE::                    
+* USE::                         @code{USE} Syntax
+* DESCRIBE::                    @code{DESCRIBE} Syntax (Get Information About Columns)
 @end menu
 
 
@@ -34387,9 +34386,9 @@ The @code{SHOW} statement provides similar information.
 @section MySQL Transactional and Locking Commands
 
 @menu
-* COMMIT::                      
-* LOCK TABLES::                 
-* SET TRANSACTION::             
+* COMMIT::                      @code{BEGIN/COMMIT/ROLLBACK} Syntax
+* LOCK TABLES::                 @code{LOCK TABLES/UNLOCK TABLES} Syntax
+* SET TRANSACTION::             @code{SET TRANSACTION} Syntax
 @end menu
 
 
@@ -34753,10 +34752,10 @@ the Internet with a search engine.  It is with this reasoning that such rows
 have been assigned a low semantical value in @strong{this particular dataset}.
 
 @menu
-* Fulltext restrictions::       
-* Fulltext Fine-tuning::        
-* Fulltext Features to Appear in MySQL 4.0::  
-* Fulltext TODO::               
+* Fulltext restrictions::       Fulltext restrictions
+* Fulltext Fine-tuning::        Fine-tuning MySQL Full-text Search
+* Fulltext Features to Appear in MySQL 4.0::  New Features of Full-text Search to Appear in MySQL 4.0
+* Fulltext TODO::               Full-text Search TODO
 @end menu
 
 
@@ -35141,7 +35140,7 @@ backup media.
 @menu
 * Key space::                   Space needed for keys
 * MyISAM table formats::        MyISAM table formats
-* MyISAM table problems::       
+* MyISAM table problems::       MyISAM table problems.
 @end menu
 
 
@@ -35346,8 +35345,8 @@ tested, but there are always circumstances that may cause database tables
 to become corrupted.
 
 @menu
-* Corrupted MyISAM tables::     
-* MyISAM table close::          
+* Corrupted MyISAM tables::     Corrupted MyISAM tables.
+* MyISAM table close::          Clients is using or hasn't closed the table properly
 @end menu
 
 
@@ -36315,7 +36314,7 @@ mysqld: ready for connections
 @end example
 
 @menu
-* Error creating InnoDB::       
+* Error creating InnoDB::       If something goes wrong in database creation
 @end menu
 
 
@@ -36520,7 +36519,7 @@ from the general log files of MySQL according to instructions in the
 MySQL manual.
 
 @menu
-* InnoDB checkpoints::          
+* InnoDB checkpoints::          Checkpoints
 @end menu
 
 
@@ -36604,12 +36603,12 @@ on the other hand cancels all modifications made by the current
 transaction.
 
 @menu
-* InnoDB consistent read::      
-* InnoDB locking reads::        
-* InnoDB Next-key locking::     
-* InnoDB Locks set::            
-* InnoDB Deadlock detection::   
-* InnoDB Consistent read example::  
+* InnoDB consistent read::      Consistent read
+* InnoDB locking reads::        Locking reads
+* InnoDB Next-key locking::     Next-key locking: avoiding the phantom problem
+* InnoDB Locks set::            Locks set by different SQL statements in InnoDB
+* InnoDB Deadlock detection::   Deadlock detection and rollback
+* InnoDB Consistent read example::  An example of how the consistent read works in InnoDB
 @end menu
 
 
@@ -37189,10 +37188,10 @@ index. Note that if the primary key is long, the secondary indexes
 will use more space.
 
 @menu
-* InnoDB physical structure::   
-* InnoDB Insert buffering::     
-* InnoDB Adaptive hash::        
-* InnoDB Physical record::      
+* InnoDB physical structure::   Physical structure of an index
+* InnoDB Insert buffering::     Insert buffering
+* InnoDB Adaptive hash::        Adaptive hash indexes
+* InnoDB Physical record::      Physical record structure
 @end menu
 
 
@@ -37326,9 +37325,9 @@ integer that can be stored in the specified integer type.
 @subsection File space management and disk i/o
 
 @menu
-* InnoDB Disk i/o::             
-* InnoDB File space::           
-* InnoDB File Defragmenting::   
+* InnoDB Disk i/o::             Disk i/o
+* InnoDB File space::           File space management
+* InnoDB File Defragmenting::   Defragmenting a table
 @end menu
 
 
@@ -37595,7 +37594,7 @@ Finland
 @menu
 * PHP::                         MySQL PHP API
 * Perl::                        MySQL Perl API
-* ODBC::                        
+* ODBC::                        MySQL ODBC Support
 * C::                           MySQL C API
 * Cplusplus::                   MySQL C++ APIs
 * Java::                        MySQL Java connectivity (JDBC)
@@ -38206,7 +38205,7 @@ the @code{DBI} Web page:
 @menu
 * Installing MyODBC::           How to install MyODBC
 * ODBC administrator::          How to fill in the various fields in the ODBC administrator program
-* MyODBC connect parameters::   
+* MyODBC connect parameters::   Connect parameters for MyODBC
 * ODBC Problems::               How to report problems with MySQL ODBC
 * MyODBC clients::              Programs known to work with @strong{MyODBC}
 * ODBC and last_insert_id::     How to get the value of an @code{AUTO_INCREMENT} column in ODBC
@@ -38851,9 +38850,9 @@ likely it is that we can fix the problem!
 * C API datatypes::             C API Datatypes
 * C API function overview::     C API Function Overview
 * C API functions::             C API Function Descriptions
-* C API problems::              
-* Building clients::            
-* Thread-safe clients::         
+* C API problems::              Common questions and problems when using the C API
+* Building clients::            Building Client Programs
+* Thread-safe clients::         How to Make a Thread-safe Client
 @end menu
 
 The C API code is distributed with MySQL. It is included in the
@@ -41545,10 +41544,10 @@ An unknown error occurred.
 @tindex @code{mysql_store_result()}
 
 @menu
-* NULL mysql_store_result::     
-* Query results::               
-* Getting unique ID::           
-* C API linking problems::      
+* NULL mysql_store_result::     Why Is It that After @code{mysql_query()} Returns Success, @code{mysql_store_result()} Sometimes Returns @code{NULL?}
+* Query results::               What Results Can I Get From a Query?
+* Getting unique ID::           How Can I Get the Unique ID for the Last Inserted Row?
+* C API linking problems::      Problems Linking with the C API
 @end menu
 
 
@@ -41586,9 +41585,9 @@ You can test for an error by calling @code{mysql_error()} or
 
 @cindex queries, C API results
 @menu
-* Query results::               
-* Getting unique ID::           
-* C API linking problems::      
+* Query results::               What Results Can I Get From a Query?
+* Getting unique ID::           How Can I Get the Unique ID for the Last Inserted Row?
+* C API linking problems::      Problems Linking with the C API
 @end menu
 
 
@@ -41802,7 +41801,7 @@ included the thread libraries on the link/compile line.
 @section MySQL C++ APIs
 
 @menu
-* Borland C++::                 
+* Borland C++::                 Borland C++
 @end menu
 
 
@@ -41895,9 +41894,9 @@ You can also find this at:
 @chapter Extending MySQL
 
 @menu
-* Adding functions::            
-* Adding procedures::           
-* MySQL internals::             
+* Adding functions::            Adding New Functions to MySQL
+* Adding procedures::           Adding New Procedures to MySQL
+* MySQL internals::             MySQL Internals
 @end menu
 
 
@@ -41943,7 +41942,7 @@ Whichever method you use to add new functions, they may be used just like
 native functions such as @code{ABS()} or @code{SOUNDEX()}.
 
 @menu
-* CREATE FUNCTION::             
+* CREATE FUNCTION::             @code{CREATE FUNCTION/DROP FUNCTION} Syntax
 * Adding UDF::                  Adding a new user-definable function
 * Adding native function::      Adding a new native function
 @end menu
@@ -42689,9 +42688,9 @@ that all future MySQL releases will work well with your
 applications.
 
 @menu
-* running mysqltest::           
-* extending mysqltest::         
-* Reporting mysqltest bugs::    
+* running mysqltest::           Running the MySQL Test Suite
+* extending mysqltest::         Extending the MySQL Test Suite
+* Reporting mysqltest bugs::    Reporting Bugs in the MySQL Test Suite
 @end menu
 
 
@@ -42888,10 +42887,10 @@ do that.  Just specify the @code{--with-debug} options to @code{configure}!
 @menu
 * What is crashing::            How to determine what is causing problems
 * Common errors::               Some common errors when using MySQL
-* Installation Issues::         
-* Administration Issues::       
-* Query Issues::                
-* Table Definition Issues::     
+* Installation Issues::         Installation Related Issues
+* Administration Issues::       Administration Related Issues
+* Query Issues::                Query Related Issues
+* Table Definition Issues::     Table Definition Related Issues
 @end menu
 
 This chapter lists some common problems and error messages that users have
@@ -43018,8 +43017,8 @@ described in this manual. @xref{Asking questions}.
 * Commands out of sync::        @code{Commands out of sync} error in client
 * Ignoring user::               @code{Ignoring user} error
 * Cannot find table::           @code{Table 'xxx' doesn't exist} error
-* Cannot initialize character set::  
-* Not enough file handles::     
+* Cannot initialize character set::  @code{Can@'t initialize character set xxx} error.
+* Not enough file handles::     File Not Found
 @end menu
 
 
@@ -43642,9 +43641,9 @@ limits!  In this case you should start @code{safe_mysqld} with @code{sh}!
 
 
 @menu
-* Link errors::                 
-* Changing MySQL user::         
-* File permissions ::           
+* Link errors::                 Problems When Linking with the MySQL Client Library
+* Changing MySQL user::         How to Run MySQL As a Normal User
+* File permissions ::           Problems with File Permissions
 @end menu
 
 @node Link errors, Changing MySQL user, Installation Issues, Installation Issues
@@ -43842,12 +43841,12 @@ with a zero.
 
 
 @menu
-* Crashing::                    
-* Resetting permissions::       
-* Full disk::                   
-* Temporary files::             
-* Problems with mysql.sock::    
-* Timezone problems::           
+* Crashing::                    What To Do If MySQL Keeps Crashing
+* Resetting permissions::       How to Reset a Forgotten Password
+* Full disk::                   How MySQL Handles a Full Disk
+* Temporary files::             Where MySQL Stores Temporary Files
+* Problems with mysql.sock::    How to Protect @file{/tmp/mysql.sock} from Being Deleted
+* Timezone problems::           Time Zone Problems
 @end menu
 
 @node Crashing, Resetting permissions, Administration Issues, Administration Issues
@@ -44228,12 +44227,12 @@ the server runs, for example, in @code{safe_mysqld} or @code{mysql.server}.
 
 
 @menu
-* Case sensitivity::            
-* Using DATE::                  
-* Problems with NULL::          
-* Problems with alias::         
-* Deleting from related tables::  
-* No matching rows::            
+* Case sensitivity::            Case Sensitivity in Searches
+* Using DATE::                  Problems Using @code{DATE} Columns
+* Problems with NULL::          Problems with @code{NULL} Values
+* Problems with alias::         Problems with @code{alias}
+* Deleting from related tables::  Deleting Rows from Related Tables
+* No matching rows::            Solving Problems with No Matching Rows
 @end menu
 
 @node Case sensitivity, Using DATE, Query Issues, Query Issues
@@ -44537,9 +44536,9 @@ Post the test file using @code{mysqlbug} to @email{mysql@@lists.mysql.com}.
 
 
 @menu
-* ALTER TABLE problems::        
-* Change column order::         
-* Temporary table problems::    
+* ALTER TABLE problems::        Problems with @code{ALTER TABLE}.
+* Change column order::         How To Change the Order of Columns in a Table
+* Temporary table problems::    TEMPORARY TABLE problems
 @end menu
 
 @node ALTER TABLE problems, Change column order, Table Definition Issues, Table Definition Issues
@@ -45946,9 +45945,9 @@ This appendix lists the developers, contributors, and supporters that have
 helped to make MySQL what it is today.
 
 @menu
-* Developers::                  
-* Contributors::                
-* Supporters::                  
+* Developers::                  Developers at MySQL AB
+* Contributors::                Contributors to MySQL
+* Supporters::                  Supporters to MySQL
 @end menu
 
 
@@ -52044,12 +52043,12 @@ problems that may be unique to your environment.
 @xref{Operating System Specific Notes}.
 
 @menu
-* Compiling for debugging::     
-* Making trace files::          
-* Using gdb on mysqld::         
-* Using stack trace::           
-* Using log files::             
-* Reproduceable test case::     
+* Compiling for debugging::     Compiling MYSQL for debugging.
+* Making trace files::          Creating trace files
+* Using gdb on mysqld::         Debugging mysqld under gdb
+* Using stack trace::           Using a stack trace
+* Using log files::             Using log files to find cause of errors in mysqld
+* Reproduceable test case::     Making a test case when you experience table corruption
 @end menu
 
 
@@ -54098,9 +54097,9 @@ That's all there is to it!
 @appendix Pieces of the manual in transit
 
 @menu
-* Installing binary::           
-* Perl support::                
-* Group by functions::          
+* Installing binary::           Installing a MySQL Binary Distribution
+* Perl support::                Perl Installation Comments
+* Group by functions::          Functions for Use with @code{GROUP BY} Clauses
 @end menu
 
 

From 8396f4d8d7a5641e8e9198821eb8f88ff2c9ee17 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Wed, 22 Aug 2001 14:28:35 -0500
Subject: [PATCH 21/51] Added target for mysql.xml to Docs/Makefile.am.

Docs/Makefile.am:
  Added target for mysql.xml.
---
 Docs/Makefile.am | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Docs/Makefile.am b/Docs/Makefile.am
index c4da4e9d0d3..17def904875 100644
--- a/Docs/Makefile.am
+++ b/Docs/Makefile.am
@@ -7,7 +7,7 @@
 # and BSD makes
 
 # If you know how to fix any of this more elegantly please mail
-# david@mysql.com
+# docs@mysql.com
 
 TEXI2HTML_FLAGS =	-iso -number
 DVIPS =			dvips
@@ -93,6 +93,10 @@ nusphere.pdf: manual.texi
 	rm -f manual-tmp.*
 	touch $@
 
+# Target to produce DocBook XML
+mysql.xml: manual.texi include.texi
+	$(MAKEINFO) --force --no-ifinfo --docbook manual.texi
+
 # The texi2dvi gives a lot of harmless errors. Just ignore them unless
 # you want to help with the typesetting part.
 # This is the European papersize version

From 29ebdeb11ccbf43c5b0a3179bed602828eb36149 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 23 Aug 2001 00:55:48 +0300
Subject: [PATCH 22/51] Portability fixes

Docs/manual.texi:
  Small changes because of user request.
heap/heapdef.h:
  Portability fix
include/global.h:
  Portability fix
myisam/myisamlog.c:
  Portability fix
sql/mini_client.cc:
  Fix for windows
sql/sql_repl.cc:
  Fix for windows
sql/violite.c:
  Fix for windows
---
 Docs/manual.texi   | 15 ++++++++++++++-
 heap/heapdef.h     |  4 ++--
 include/global.h   | 13 +++++++++----
 myisam/myisamlog.c |  3 +--
 sql/mini_client.cc | 19 +++++++++++++++----
 sql/sql_repl.cc    |  3 +++
 sql/violite.c      | 14 +++-----------
 7 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 246a3747576..322cf80104e 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -1129,6 +1129,9 @@ values).
 @node MySQL-Books, General-SQL, MySQL Information Sources, MySQL Information Sources
 @subsection Books About MySQL
 
+For the latest book information, with user comments, please visit
+@uref{http://www.mysql.com/portal/books/html/index.html}.
+
 While this manual is still the right place for up to date technical
 information, its primary goal is to contain everything there is to know
 about MySQL.  It is sometimes nice to have a bound book to read
@@ -36066,7 +36069,7 @@ installing a binary version of MySQL. @xref{Installing binary}.
 @xref{mysqld-max, , @code{mysqld-max}}.
 
 To compile MySQL with InnoDB support, download MySQL-3.23.37 or newer
-and configure @code{MySQL} with the @code{--with-innodb} option.
+and configure MySQL with the @code{--with-innodb} option.
 @xref{Installing source}.
 
 @example
@@ -36074,6 +36077,16 @@ cd /path/to/source/of/mysql-3.23.37
 ./configure --with-innodb
 @end example
 
+To get InnoDB to work you have to specify where the data for InnoDB
+tables should be stored by specifying the @code{innodb_data_file_path}
+option on the command line or in an MySQL option file. @xref{InnoDB
+start}.  If you have configured MySQL for InnoDB but you have not
+specified the above option, @code{mysqld} will print at start:
+
+@example
+Can't initialize InnoDB as 'innodb_data_file_path' is not set
+@end example
+
 InnoDB provides MySQL with a transaction-safe table handler with
 commit, rollback, and crash recovery capabilities. InnoDB does
 locking on row level, and also provides an Oracle-style consistent
diff --git a/heap/heapdef.h b/heap/heapdef.h
index 19c3b7d7792..938cb55c0eb 100644
--- a/heap/heapdef.h
+++ b/heap/heapdef.h
@@ -34,9 +34,9 @@ if (!(info->update & HA_STATE_AKTIV))\
 	/* Find pos for record and update it in info->current_ptr */
 #define _hp_find_record(info,pos) (info)->current_ptr= _hp_find_block(&(info)->s->block,pos)
 
-typedef struct st_hash_info
+typedef struct st_hp_hash_info
 {
-  struct st_hash_info *next_key;
+  struct st_hp_hash_info *next_key;
   byte *ptr_to_rec;
 } HASH_INFO;
 
diff --git a/include/global.h b/include/global.h
index d6a46e1b187..f10411af0aa 100644
--- a/include/global.h
+++ b/include/global.h
@@ -644,13 +644,18 @@ typedef off_t os_off_t;
 #endif
 
 #if defined(__WIN__)
-#define socket_errno WSAGetLastError()
+#define socket_errno	WSAGetLastError()
+#define SOCKET_EINTR	WSAEINTR 
+#define SOCKET_EAGAIN	WSAEINPROGRESS
 #elif defined(OS2)
-#define socket_errno sock_errno()
+#define socket_errno	sock_errno()
 #define closesocket(A)	soclose(A)
-#else
+#else /* Unix */
 #define socket_errno errno
-#define closesocket(A) close(A)
+#define closesocket(A)	close(A)
+#define SOCKET_EINTR	EINTR
+#define SOCKET_EAGAIN	EAGAIN
+#define SOCKET_EWOULDBLOCK EWOULDBLOCK
 #endif
 
 typedef uint8		int7;	/* Most effective integer 0 <= x <= 127 */
diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c
index a6094cfd489..ddfafb91430 100644
--- a/myisam/myisamlog.c
+++ b/myisam/myisamlog.c
@@ -488,8 +488,7 @@ static int examine_log(my_string file_name, char **table_names)
 		   command_name[command], (int) extra_command,result);
       if (update && curr_file_info && !curr_file_info->closed)
       {
-	if (mi_extra(curr_file_info->isam,
-		     (int) extra_command) != (int) result)
+	if (mi_extra(curr_file_info->isam, extra_command) != (int) result)
 	{
 	  fflush(stdout);
 	  VOID(fprintf(stderr,
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 88a02e227a3..3a2305aa69c 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -23,10 +23,23 @@
  */
 
 #define DONT_USE_RAID
-#if defined(__WIN__) || defined(WIN32)
+#if defined(__WIN__)
 #include <winsock.h>
 #include <odbcinst.h>
+/* Disable alarms */
+typedef my_bool ALARM;
+#define thr_alarm_init(A) (*(A))=0
+#define thr_alarm_in_use(A) (*(A))
+#define thr_end_alarm(A)
+#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
+inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
+{
+  *A=1;
+  return 0;
+}
+#define thr_got_alarm(A) 0
 #endif
+
 #include <global.h>
 #include <my_sys.h>
 #include <mysys_err.h>
@@ -62,7 +75,7 @@ extern "C" {					// Because of SCO 3.2V4.2
 #ifdef HAVE_SYS_UN_H
 #  include <sys/un.h>
 #endif
-#if defined(THREAD) && !defined(__WIN__)
+#if defined(THREAD)
 #include <my_pthread.h>				/* because of signal()	*/
 #include <thr_alarm.h>
 #endif
@@ -486,9 +499,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
   uint		pkt_length;
   NET		*net= &mysql->net;
   thr_alarm_t   alarmed;
-#if !defined(__WIN__)
   ALARM alarm_buff;
-#endif
 
 #ifdef __WIN__
   HANDLE	hPipe=INVALID_HANDLE_VALUE;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 32c4c5c6509..b9ba284ab27 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -620,6 +620,9 @@ int stop_slave(THD* thd, bool net_report )
 #ifdef HAVE_TIMESPEC_TS_SEC
       abstime.ts_sec=time(NULL)+2;		
       abstime.ts_nsec=0;
+#elif defined(__WIN__)
+      abstime.tv_sec=time((time_t*) 0)+2;
+      abstime.tv_nsec=0;
 #else
       struct timeval tv;
       gettimeofday(&tv,0);
diff --git a/sql/violite.c b/sql/violite.c
index aff4224e5a3..0d96c71969c 100644
--- a/sql/violite.c
+++ b/sql/violite.c
@@ -44,18 +44,10 @@
 #endif	/* defined(__EMX__) */
 
 #if defined(MSDOS) || defined(__WIN__)
-#ifdef __WIN__
-#undef errno
-#undef EINTR
-#undef EAGAIN
-#define errno WSAGetLastError()
-#define EINTR  WSAEINTR
-#define EAGAIN WSAEINPROGRESS
-#endif /* __WIN__ */
 #define O_NONBLOCK 1    /* For emulation of fcntl() */
 #endif
 #ifndef EWOULDBLOCK
-#define EWOULDBLOCK EAGAIN
+#define SOCKET_EWOULDBLOCK SOCKET_EAGAIN
 #endif
 
 #ifndef __WIN__
@@ -327,8 +319,8 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
 my_bool
 vio_should_retry(Vio * vio __attribute__((unused)))
 {
-  int en = errno;
-  return en == EAGAIN || en == EINTR || en == EWOULDBLOCK;
+  int en = socket_errno;
+  return en == SOCKET_EAGAIN || en == SOCKET_EINTR || en == SOCKET_EWOULDBLOCK;
 }
 
 

From b5dfa5b7a77b9ae694d1330fdc03ae6f9f2cb810 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Thu, 23 Aug 2001 14:47:05 -0500
Subject: [PATCH 23/51] Lots of cleanups.

---
 Docs/manual.texi | 98 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 82 insertions(+), 16 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index c2acf5f336a..b6d05119e36 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -3644,16 +3644,20 @@ differently:
 @item
 @code{--} is only a comment if followed by a white space. @xref{Missing
 comments}.
+
 @item
 For @code{VARCHAR} columns, trailing spaces are removed when the value is
 stored. @xref{Bugs}.
+
 @item
 In some cases, @code{CHAR} columns are silently changed to @code{VARCHAR}
 columns. @xref{Silent column changes}.
+
 @item
 Privileges for a table are not automatically revoked when you delete a
 table. You must explicitly issue a @code{REVOKE} to revoke privileges for
 a table. @xref{GRANT, , @code{GRANT}}.
+
 @item
 @code{NULL AND FALSE} will evaluate to @code{NULL} and not to @code{FALSE}.
 This is because we don't think it's good to have to evaluate a lot of
@@ -3673,15 +3677,19 @@ behavior of MySQL changes:
 @itemize @bullet
 @item
 @code{||} is string concatenation instead of @code{OR}.
+
 @item
 You can have any number of spaces between a function name and the @samp{(}.
 This forces all function names to be treated as reserved words.
+
 @item
 @samp{"} will be an identifier quote character (like the MySQL
 @samp{`} quote character) and not a string quote character.
+
 @item
 @code{REAL} will be a synonym for @code{FLOAT} instead of a synonym of
 @code{DOUBLE}.
+
 @item
 The default transaction isolation level is @code{SERIALIZABLE}.
 @xref{SET TRANSACTION}.
@@ -4315,17 +4323,21 @@ The following problems are known and will be fixed in due time:
 @itemize @bullet
 @item
 For the moment @code{MATCH} only works with @code{SELECT} statements.
+
 @item
 When using @code{SET CHARACTER SET}, one can't use translated
 characters in database, table and column names.
+
 @item
 @code{DELETE FROM merge_table} used without a @code{WHERE}
 will only clear the mapping for the table, not delete everything in the
 mapped tables
+
 @item
 You cannot build in another directory when using
 MIT-pthreads. Because this requires changes to MIT-pthreads, we are not
 likely to fix this.
+
 @item
 @code{BLOB} values can't ``reliably'' be used in @code{GROUP BY} or
 @code{ORDER BY} or @code{DISTINCT}. Only the first @code{max_sort_length}
@@ -4333,6 +4345,7 @@ bytes (default 1024) are used when comparing @code{BLOB}bs in these cases.
 This can be changed with the @code{-O max_sort_length} option to
 @code{mysqld}. A workaround for most cases is to use a substring:
 @code{SELECT DISTINCT LEFT(blob,2048) FROM tbl_name}.
+
 @item
 Calculation is done with @code{BIGINT} or @code{DOUBLE} (both are
 normally 64 bits long). It depends on the function which precision one
@@ -4341,13 +4354,16 @@ precision, @code{IF}, and @code{ELT()} with @code{BIGINT} or @code{DOUBLE}
 precision and the rest with @code{DOUBLE} precision.  One should try to
 avoid using bigger unsigned long long values than 63 bits
 (9223372036854775807) for anything else than bit fields!
+
 @item
 All string columns, except @code{BLOB} and @code{TEXT} columns, automatically
 have all trailing spaces removed when retrieved. For @code{CHAR} types this
 is okay, and may be regarded as a feature according to ANSI SQL92. The bug is
 that in MySQL, @code{VARCHAR} columns are treated the same way.
+
 @item
 You can only have up to 255 @code{ENUM} and @code{SET} columns in one table.
+
 @item
 @code{safe_mysqld} re-directs all messages from @code{mysqld} to the
 @code{mysqld} log.  One problem with this is that if you execute
@@ -4357,14 +4373,18 @@ If you use @code{--log} extensively, you should edit @code{safe_mysqld} to
 log to @file{'hostname'.err} instead of @file{'hostname'.log} so you can
 easily reclaim the space for the old log by deleting the old one and
 executing @code{mysqladmin refresh}.
+
 @item
-In the @code{UPDATE} statement, columns are updated from left to right.
-If you refer to an updated column, you will get the updated value instead of the
+In the @code{UPDATE} statement, columns are updated from left to right.  If 
+you refer to an updated column, you will get the updated value instead of the
 original value. For example:
+
 @example
 mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1;
 @end example
-will update @code{KEY} with @code{2} instead of with @code{1}.
+
+This will update @code{KEY} with @code{2} instead of with @code{1}.
+
 @item
 You can't use temporary tables more than once in the same query.
 For example, the following doesn't work.
@@ -4389,9 +4409,11 @@ An example of this is:
 @example
 SELECT DISTINCT mp3id FROM band_downloads WHERE userid = 9 ORDER BY id
 DESC;
+@end example
 
 and
 
+@example
 SELECT DISTINCT band_downloads.mp3id, FROM band_downloads,band_mp3
 WHERE band_downloads.userid = 9 AND band_mp3.id = band_downloads.mp3id
 ORDER BY band_downloads.id DESC;
@@ -4422,24 +4444,28 @@ optimizations that otherwise would be very hard to do.
 If you set a column to an incorrect value, MySQL will, instead of
 doing a rollback, store the @code{best possible value} in the column:
 
-@itemize @bullet
+@itemize @minus
 @item
 If you try to store a value outside the range in a numerical column,
 MySQL will instead store the smallest or biggest possible value in
 the column.
+
 @item
 If you try to store a string that doesn't start with a number into a
 numerical column, MySQL will store 0 into it.
+
 @item
 If you try to store @code{NULL} into a column that doesn't take
 @code{NULL} values, MySQL will store 0 or @code{''} (empty
 string) in it instead. (This behavior can, however, be changed with the
 -DDONT_USE_DEFAULT_FIELDS compile option).
+
 @item
 MySQL allows you to store some wrong date values into
 @code{DATE} and @code{DATETIME} columns. (Like 2000-02-31 or 2000-02-00).
 If the date is totally wrong, MySQL will store the special
 0000-00-00 date value in the column.
+
 @item
 If you set an @code{enum} to an unsupported value, it will be set to
 the error value 'empty string', with numeric value 0.
@@ -4448,15 +4474,18 @@ the error value 'empty string', with numeric value 0.
 @item
 If you execute a @code{PROCEDURE} on a query that returns an empty set,
 in some cases the @code{PROCEDURE} will not transform the columns.
+
 @item
 Creation of a table of type @code{MERGE} doesn't check if the underlying
 tables are of compatible types.
+
 @item
 MySQL can't yet handle @code{NaN}, @code{-Inf} and @code{Inf}
 values in double. Using these will cause problems when trying to export
 and import data. We should as an intermediate solution change @code{NaN} to
 @code{NULL} (if possible) and @code{-Inf} and @code{Inf} to the
 Minimum respective maximum possible @code{double} value.
+
 @item
 @code{LIMIT} on negative numbers are treated as big positive numbers.
 @end itemize
@@ -4470,11 +4499,14 @@ one among many tables that is locked with @code{LOCK TABLES}.
 
 @item
 In the following case you can get a core dump:
-@enumerate
+
+@itemize @minus
 @item
 Delayed insert handler has pending inserts to a table.
+
 @item
 @code{LOCK table} with @code{WRITE}
+
 @item
 @code{FLUSH TABLES}
 @end enumerate
@@ -4496,6 +4528,7 @@ mysql> UPDATE tbl_name SET KEY=KEY+1 WHERE KEY+0 > 100;
 
 This will work because MySQL will not use index on expressions in
 the @code{WHERE} clause.
+
 @item
 Before MySQL Version 3.23, all numeric types where treated as fixed-point
 fields. That means you had to specify how many decimals a floating-point
@@ -4545,10 +4578,13 @@ simple security, @code{mSQL} should be quicker at:
 @item
 Tests that perform repeated connects and disconnects, running a very simple
 query during each connection.
+
 @item
 @code{INSERT} operations into very simple tables with few columns and keys.
+
 @item
 @code{CREATE TABLE} and @code{DROP TABLE}.
+
 @item
 @code{SELECT} on something that isn't an index. (A table scan is very
 easy.)
@@ -4564,20 +4600,27 @@ most other SQL implementations) on the following:
 @itemize @bullet
 @item
 Complex @code{SELECT} operations.
+
 @item
 Retrieving large results (MySQL has a better, faster, and safer
 protocol).
+
 @item
 Tables with variable-length strings, because MySQL has more efficient
 handling and can have indexes on @code{VARCHAR} columns.
+
 @item
 Handling tables with many columns.
+
 @item
 Handling tables with large record lengths.
+
 @item
 @code{SELECT} with many expressions.
+
 @item
 @code{SELECT} on large tables.
+
 @item
 Handling many connections at the same time. MySQL is fully
 multi-threaded. Each connection has its own thread, which means that
@@ -4587,6 +4630,7 @@ is established, all others must wait until the first has finished, regardless
 of whether the connection is running a query that is short or long. When the
 first connection terminates, the next can be served, while all the others wait
 again, etc.
+
 @item
 Joins.
 @code{mSQL} can become pathologically slow if you change the order of tables
@@ -4596,10 +4640,13 @@ join optimizer to order tables in the optimal order. However, if you put the
 tables in exactly the right order in @code{mSQL}2 and the @code{WHERE} is
 simple and uses index columns, the join will be relatively fast!
 @xref{MySQL Benchmarks}.
+
 @item
 @code{ORDER BY} and @code{GROUP BY}.
+
 @item
 @code{DISTINCT}.
+
 @item
 Using @code{TEXT} or @code{BLOB} columns.
 @end itemize
@@ -4619,6 +4666,7 @@ columns are retrieved, and there is no @code{WHERE} clause.  @code{MIN()} and
 @item @code{INSERT} and @code{UPDATE} with calculations.
 MySQL can do calculations in an @code{INSERT} or @code{UPDATE}.
 For example:
+
 @example
 mysql> UPDATE SET x=x*10+y WHERE x<20;
 @end example
@@ -4645,6 +4693,7 @@ saving even one byte per record is very important.
 
 @code{mSQL2} has a more limited set of column types, so it is
 more difficult to get small tables.
+
 @item Stability
 This is harder to judge objectively. For a discussion of MySQL
 stability, see @ref{Stability}.
@@ -4666,18 +4715,23 @@ some added features.
 
 @item JDBC (Java)
 MySQL currently has a lot of different JDBC drivers:
+
 @itemize @bullet
 @item
 The mm driver: A type 4 JDBC driver by Mark Matthews
 @email{mmatthew@@ecn.purdue.edu}.  This is released under the LGPL.
+
 @item
 The Resin driver. This is a commercial JDBC driver released under open
 source.  @uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp}
+
 @item
 The gwe driver: A Java interface by GWE technologies (not supported anymore).
+
 @item
 The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU
 @email{X.Zhu@@brad.ac.uk} (not supported anymore).
+
 @item
 The twz driver: A type 4 JDBC driver by Terrence W. Zellers
 @email{zellert@@voicenet.com}.  This is commercial but is free for private
@@ -4739,29 +4793,35 @@ The conversion procedure is:
 @item
 Run the shell script @code{msql2mysql} on the source. This requires the
 @code{replace} program, which is distributed with MySQL.
+
 @item
 Compile.
+
 @item
 Fix all compiler errors.
 @end enumerate
 
 Differences between the @code{mSQL} C API and the MySQL C API are:
+
 @itemize @bullet
 @item
 MySQL uses a @code{MYSQL} structure as a connection type (@code{mSQL}
 uses an @code{int}).
+
 @item
 @code{mysql_connect()} takes a pointer to a @code{MYSQL} structure as a
 parameter.  It is easy to define one globally or to use @code{malloc()} to get
-one.
-@code{mysql_connect()} also takes two parameters for specifying the user and
-password.  You may set these to @code{NULL, NULL} for default use.
+one.  @code{mysql_connect()} also takes two parameters for specifying the 
+user and password.  You may set these to @code{NULL, NULL} for default use.
+
 @item
 @code{mysql_error()} takes the @code{MYSQL} structure as a parameter. Just add
 the parameter to your old @code{msql_error()} code if you are porting old code.
+
 @item
 MySQL returns an error number and a text error message for all
 errors. @code{mSQL} returns only a text error message.
+
 @item
 Some incompatibilities exist as a result of MySQL supporting
 multiple connections to the server from the same process.
@@ -4783,21 +4843,27 @@ from the @code{mSQL} protocol are listed below:
 @itemize @bullet
 @item
 A message buffer may contain many result rows.
+
 @item
 The message buffers are dynamically enlarged if the query or the
 result is bigger than the current buffer, up to a configurable server and
 client limit.
+
 @item
 All packets are numbered to catch duplicated or missing packets.
+
 @item
 All column values are sent in ASCII. The lengths of columns and rows are sent
 in packed binary coding (1, 2, or 3 bytes).
+
 @item
 MySQL can read in the result unbuffered (without having to store the
 full set in the client).
+
 @item
 If a single read/write takes more than 30 seconds, the server closes
 the connection.
+
 @item
 If a connection is idle for 8 hours, the server closes the connection.
 @end itemize
@@ -5115,20 +5181,20 @@ existing programs than PostgreSQL.  @xref{Contrib}.
 
 @item
 MySQL works on 24/7 heavy duty systems.  In most circumstances
-you never have to run any cleanups on @code{MySQL}.  PostgreSQL doesn't
-yet support 24/7 systems because you have to run @code{vacuum()}
+you never have to run any cleanups on MySQL.  PostgreSQL doesn't
+yet support 24/7 systems because you have to run @code{VACUUM()}
 once in a while to reclaim space from @code{UPDATE} and @code{DELETE}
 commands and to perform statistics analyzes that are critical to get
-good performance with PostgreSQL.  Vacuum is also needed after adding
-a lot of new rows to a table.  On a busy system with lots of changes,
-vacuum must be run very frequently, in the worst cases even many times a
-day.  During the @code{vacuum()} run, which may take hours if the
-database is big, the database is from a production standpoint,
+good performance with PostgreSQL.  @code{VACUUM()} is also needed after
+adding a lot of new rows to a table.  On a busy system with lots of changes,
+@code{VACUUM()} must be run very frequently, in the worst cases even 
+many times a day.  During the @code{VACUUM()} run, which may take hours 
+if the database is big, the database is from a production standpoint,
 practically dead.  The PostgreSQL team has fixing this on their TODO,
 but we assume that this is not an easy thing to fix permanently.
 
 @item
-A working, tested replication feature used by sites like
+A working, tested replication feature used by sites like:
 @itemize @minus
 @item Yahoo Finance (@uref{http://finance.yahoo.com})
 @item Mobile.de (@uref{http://www.mobile.de/})

From 390eb478e90238c621f8be5907536780f74e3ad8 Mon Sep 17 00:00:00 2001
From: unknown <jcole@tetra.spaceapes.com>
Date: Thu, 23 Aug 2001 14:54:41 -0500
Subject: [PATCH 24/51] Fixed oopsie, and fixed a typo.

---
 Docs/manual.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 6ae3314b4c2..ee58f786b29 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -4512,7 +4512,7 @@ Delayed insert handler has pending inserts to a table.
 
 @item
 @code{FLUSH TABLES}
-@end enumerate
+@end itemize
 
 @item
 Before MySQL Version 3.23.2 an @code{UPDATE} that updated a key with
@@ -17859,7 +17859,7 @@ The command returns a table with the following columns:
 @example
 CHECK TABLE tbl_name[,tbl_name...] [option [option...]]
 
-option = QUICK | FAST | MEDIUM | EXTEND | CHANGED
+option = QUICK | FAST | MEDIUM | EXTENDED | CHANGED
 @end example
 
 @code{CHECK TABLE} only works on @code{MyISAM} tables. On

From 0733b85d75c560cc2e9cca84e490a4ccde5a945a Mon Sep 17 00:00:00 2001
From: unknown <sasha@mysql.sashanet.com>
Date: Fri, 24 Aug 2001 20:45:06 -0600
Subject: [PATCH 25/51] test case for InnoDB replace/auto_increment bug when
 insert_id is forced by the user

mysql-test/r/innodb.result:
  updated result
mysql-test/t/innodb.test:
  added test case for bug in Innodb reported by Slashdot
---
 mysql-test/r/innodb.result |  4 ++++
 mysql-test/t/innodb.test   | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index fd7900af13b..913f4226f1c 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -475,3 +475,7 @@ a
 1
 2
 4
+id	name	value	uid
+1	one	one value	101
+3	three	three value	103
+6	two	other value	102
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 97908aeaa57..5530e2b1f54 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -490,3 +490,25 @@ delete from t1 where a=3;
 insert into t1 values (NULL);
 select * from t1;
 drop table t1;
+
+#Slashdot bug
+create table t1
+ (
+  id int auto_increment primary key,
+  name varchar(32) not null,
+  value text not null,
+  uid int not null,
+  unique key(name,uid)
+ ) type=innodb;
+insert into t1 values (1,'one','one value',101),
+ (2,'two','two value',102),(3,'three','three value',103);
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+delete from t1 where uid=102;
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+set insert_id=6;
+replace into t1 (value,name,uid) values ('other value','two',102);
+select * from t1;
+drop table t1;
+

From 30774b35493d3ad14ee40b73d4b9ffff51dd6cd1 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Sun, 26 Aug 2001 23:24:48 +0300
Subject: [PATCH 26/51] Fixed bug in auto-increment handling with InnoDB Some
 small speedups

Docs/manual.texi:
  Changelog
client/mysqldump.c:
  Fixed quoting problem for table names when using --opt
mysys/mf_casecnv.c:
  Speed up some common string functions
sql-bench/test-insert.sh:
  Small changes that shouldn't affect results
sql-bench/test-select.sh:
  Small changes that shouldn't affect results
sql/field.h:
  Added reset() functions to speed up some common things
sql/gen_lex_hash.cc:
  Smaller hash table
sql/ha_innobase.cc:
  Fixed bug in auto-increment handling with InnoDB
---
 Docs/manual.texi         |  2 ++
 client/mysqldump.c       |  8 +++++---
 mysys/mf_casecnv.c       | 32 ++++++++++++++++++++------------
 sql-bench/test-insert.sh |  4 ++--
 sql-bench/test-select.sh |  6 +++---
 sql/field.h              | 14 ++++++++++++++
 sql/gen_lex_hash.cc      |  2 +-
 sql/ha_innobase.cc       |  2 ++
 8 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index ee58f786b29..a3397de70a6 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46672,6 +46672,8 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
+@item
 Applied large patch for OS/2 from Yuri Dario.
 @item
 Fixed problem with InnoDB when one could get the error @code{Can't
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 29629940fb5..9038c88e085 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -37,7 +37,7 @@
 **   T�nu Samuel  <tonu@please.do.not.remove.this.spam.ee>
 **/
 
-#define DUMP_VERSION "8.14"
+#define DUMP_VERSION "8.15"
 
 #include <global.h>
 #include <my_sys.h>
@@ -1224,6 +1224,7 @@ static int dump_all_tables_in_db(char *database)
 {
   char *table;
   uint numrows;
+  char table_buff[NAME_LEN+3];
 
   if (init_dumping(database))
     return 1;
@@ -1233,7 +1234,7 @@ static int dump_all_tables_in_db(char *database)
     init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
     for (numrows=0 ; (table = getTableName(1)) ; numrows++)
     {
-      dynstr_append(&query, table);
+      dynstr_append(&query, quote_name(table,table_buff));
       dynstr_append(&query, " READ /*!32311 LOCAL */,");
     }
     if (numrows && mysql_real_query(sock, query.str, query.length-1))
@@ -1263,6 +1264,7 @@ static int dump_all_tables_in_db(char *database)
 static int dump_selected_tables(char *db, char **table_names, int tables)
 {
   uint numrows;
+  char table_buff[NAME_LEN+3];
 
   if (init_dumping(db))
     return 1;
@@ -1274,7 +1276,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
     init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
     for (i=0 ; i < tables ; i++)
     {
-      dynstr_append(&query, table_names[i]);
+      dynstr_append(&query, quote_name(table_names[i],table_buff));
       dynstr_append(&query, " READ /*!32311 LOCAL */,");
     }
     if (mysql_real_query(sock, query.str, query.length-1))
diff --git a/mysys/mf_casecnv.c b/mysys/mf_casecnv.c
index 1d63527eb7b..4ec3b66d9cb 100644
--- a/mysys/mf_casecnv.c
+++ b/mysys/mf_casecnv.c
@@ -31,14 +31,16 @@
 void caseup_str(my_string str)
 {
 #ifdef USE_MB
-  register uint32 l;
-  register char *end=str+(uint) strlen(str);
   if (use_mb(default_charset_info))
+  {
+    register uint32 l;
+    register char *end=str+(uint) strlen(str);
     while (*str)
     {
       if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
       else *str=toupper(*str),++str;
     }
+  }
   else
 #endif
     while ((*str = toupper(*str)) != 0)
@@ -50,14 +52,16 @@ void caseup_str(my_string str)
 void casedn_str(my_string str)
 {
 #ifdef USE_MB
-  register uint32 l;
-  register char *end=str+(uint) strlen(str);
   if (use_mb(default_charset_info))
+  {
+    register uint32 l;
+    register char *end=str+(uint) strlen(str);
     while (*str)
     {
       if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
       else *str=tolower(*str),++str;
     }
+  }
   else
 #endif
     while ((*str= tolower(*str)) != 0)
@@ -70,14 +74,16 @@ void casedn_str(my_string str)
 void caseup(my_string str, uint length)
 {
 #ifdef USE_MB
-  register uint32 l;
-  register char *end=str+length;
   if (use_mb(default_charset_info))
+  {
+    register uint32 l;
+    register char *end=str+length;
     while (str<end)
     {
       if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
       else *str=toupper(*str),++str;
     }
+  }
   else
 #endif
     for ( ; length>0 ; length--, str++)
@@ -89,14 +95,16 @@ void caseup(my_string str, uint length)
 void casedn(my_string str, uint length)
 {
 #ifdef USE_MB
-  register uint32 l;
-  register char *end=str+length;
   if (use_mb(default_charset_info))
+  {
+    register uint32 l;
+    register char *end=str+length;
     while (str<end)
     {
       if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
       else *str=tolower(*str),++str;
     }
+  }
   else
 #endif
     for ( ; length>0 ; length--, str++)
@@ -143,10 +151,10 @@ skipp:
 int my_strcasecmp(const char *s, const char *t)
 {
 #ifdef USE_MB
-  register uint32 l;
-  register const char *end=s+(uint) strlen(s);
   if (use_mb(default_charset_info))
   {
+    register uint32 l;
+    register const char *end=s+(uint) strlen(s);
     while (s<end)
     {
       if ((l=my_ismbchar(default_charset_info, s,end)))
@@ -172,10 +180,10 @@ int my_strcasecmp(const char *s, const char *t)
 int my_casecmp(const char *s, const char *t, uint len)
 {
 #ifdef USE_MB
-  register uint32 l;
-  register const char *end=s+len;
   if (use_mb(default_charset_info))
   {
+    register uint32 l;
+    register const char *end=s+len;
     while (s<end)
     {
       if ((l=my_ismbchar(default_charset_info, s,end)))
diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh
index b8f20b123a5..9d1adda1fc3 100644
--- a/sql-bench/test-insert.sh
+++ b/sql-bench/test-insert.sh
@@ -562,7 +562,7 @@ if ($limits->{'group_functions'})
     fetch_all_rows($dbh,"select min(id) from bench1");
     fetch_all_rows($dbh,"select max(id) from bench1");
     fetch_all_rows($dbh,"select sum(id+0.0) from bench1");
-    fetch_all_rows($dbh,"select min(id3),max(id3),sum(id3 +0.0) from bench1");
+    fetch_all_rows($dbh,"select min(id3),max(id3),sum(id3-0.0) from bench1");
     if ($limits->{'group_func_sql_min_str'})
     {
       fetch_all_rows($dbh,"select min(dummy1),max(dummy1) from bench1");
@@ -579,7 +579,7 @@ if ($limits->{'group_functions'})
 
 
     $count++;
-    $sth=$dbh->prepare($query="select count(*),sum(id+0.0),min(id),max(id),avg(id+0.0) from bench1") or die $DBI::errstr;
+    $sth=$dbh->prepare($query="select count(*),sum(id+0.0),min(id),max(id),avg(id-0.0) from bench1") or die $DBI::errstr;
     $sth->execute or die $DBI::errstr;
     @row=$sth->fetchrow_array;
     if ($row[0] != $total_rows ||
diff --git a/sql-bench/test-select.sh b/sql-bench/test-select.sh
index 3c7efe3c5c2..1ecad5804c5 100644
--- a/sql-bench/test-select.sh
+++ b/sql-bench/test-select.sh
@@ -136,12 +136,12 @@ if ($limits->{'group_functions'})
   print "Test if the database has a query cache\n";
 
   # First ensure that the table is read into memory
-  fetch_all_rows($dbh,"select sum(idn+$tmp),sum(rev_idn+$tmp) from bench1");
+  fetch_all_rows($dbh,"select sum(idn+$tmp),sum(rev_idn-$tmp) from bench1");
 
   $loop_time=new Benchmark;
   for ($tests=0 ; $tests < $opt_loop_count ; $tests++)
   {
-    fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn+$tests) from bench1");
+    fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn-$tests) from bench1");
   }
   $end_time=new Benchmark;
   print "Time for select_query_cache ($opt_loop_count): " .
@@ -153,7 +153,7 @@ if ($limits->{'group_functions'})
   $loop_time=new Benchmark;
   for ($tests=0 ; $tests < $opt_loop_count ; $tests++)
   {
-    fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn+$tests) from bench1");
+    fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn-$tests) from bench1");
   }
   $end_time=new Benchmark;
   print "Time for select_query_cache2 ($opt_loop_count): " .
diff --git a/sql/field.h b/sql/field.h
index fc0bfdc75d5..b9d8e1957c9 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -300,6 +300,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -328,6 +329,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -356,6 +358,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -389,6 +392,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -423,6 +427,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -449,6 +454,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { bzero(ptr,sizeof(float)); }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -480,6 +486,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { bzero(ptr,sizeof(double)); }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -505,6 +512,7 @@ public:
   void store(const char *to, uint length) { null[0]=1; }
   void store(double nr)   { null[0]=1; }
   void store(longlong nr) { null[0]=1; }
+  void reset(void)	  {}
   double val_real(void)		{ return 0.0;}
   longlong val_int(void)	{ return 0;}
   String *val_str(String *value,String *value2)
@@ -528,6 +536,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -588,6 +597,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -615,6 +625,7 @@ public:
   void store(double nr);
   void store(longlong nr);
   void store_time(TIME *ltime,timestamp_type type);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -643,6 +654,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -673,6 +685,7 @@ public:
   void store(double nr);
   void store(longlong nr);
   void store_time(TIME *ltime,timestamp_type type);
+  void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
@@ -922,6 +935,7 @@ public:
   void store(const char *to,uint length);
   void store(double nr);
   void store(longlong nr);
+  void reset() { bzero(ptr,packlength); }
   double val_real(void);
   longlong val_int(void);
   String *val_str(String*,String *);
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 5eee5c6163a..d55197a8b60 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -472,7 +472,7 @@ int main(int argc,char **argv)
   int error;
 
   MY_INIT(argv[0]);
-  start_value=487844L;  best_t1=4969454L;  best_t2=2266538L;  best_type=2; /* mode=4567  add=5  type: 0 */
+  start_value=4597269L;  best_t1=6001982L;  best_t2=5063828L;  best_type=4; /* mode=4513  add=8  type: 0 */
   if (get_options(argc,(char **) argv))
     exit(1);
 
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index fdbc0b107f5..061371eb5d4 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -1334,6 +1334,8 @@ ha_innobase::write_row(
 	        autoincrement field */
 	        
 	        auto_inc = table->next_number_field->val_int();
+		if (auto_inc == 0)
+		  auto_inc= user_thd->next_insert_id;
 
 		if (auto_inc != 0) {
 			/* This call will calculate the max of the

From bfe2213babce74eac616dd3be0c8ac5bce16f032 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Tue, 28 Aug 2001 06:43:55 +0300
Subject: [PATCH 27/51] Fixed that LOAD DATA INFILE works with transactions.
 Fix for lower case filenames

BitKeeper/deleted/.del-select.tst~2e626fa07144d2c8:
  Delete: mysql-test/misc/select.tst
Docs/manual.texi:
  Better examples for sub selects
bdb/lock/lock_region.c:
  Fixed not critical error
mysql-test/r/gemini.result:
  Testcase for load data infile
mysql-test/t/gemini.test:
  Testcase for load data infile
sql/sql_load.cc:
  Fixed that LOAD DATA INFILE works with transactions
sql/sql_show.cc:
  Fix for lower case filenames
sql/sql_string.cc:
  cleanup
---
 Docs/manual.texi               |   27 +-
 bdb/lock/lock_region.c         |    1 +
 mysql-test/misc/select.tst     | 4015 --------------------------------
 mysql-test/r/gemini.result     |    6 +
 mysql-test/std_data/gemini.dat |    5 +
 mysql-test/t/gemini.test       |   15 +
 sql/sql_load.cc                |   15 +-
 sql/sql_show.cc                |   16 +-
 sql/sql_string.cc              |    6 +-
 9 files changed, 74 insertions(+), 4032 deletions(-)
 delete mode 100644 mysql-test/misc/select.tst
 create mode 100644 mysql-test/std_data/gemini.dat

diff --git a/Docs/manual.texi b/Docs/manual.texi
index a3397de70a6..6e77f0110cd 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -3730,18 +3730,31 @@ list in this manual. @xref{TODO}.
 
 @cindex sub-selects
 
-The following will not yet work in MySQL:
+MySQL currently only supports sub selects of the form @code{INSERT
+... SELECT ...} and @code{REPLACE ... SELECT ...}. You can however use
+the function @code{IN()} in other contexts.
+
+In many cases you can rewrite the query without a sub-select:
 
 @example
 SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
+@end example
+
+This can be re-written as:
+
+@example
+SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
+@end example
+
+The queries:
+@example
 SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
 SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id);
 @end example
 
-However, in many cases you can rewrite the query without a sub-select:
+Can be rewritten as:
 
 @example
-SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
 SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
 @end example
 
@@ -3777,11 +3790,9 @@ second instance of the interpreter:
 prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb
 @end example
 
-MySQL only supports @code{INSERT ... SELECT ...} and
-@code{REPLACE ... SELECT ...} Independent sub-selects will probably
-be available in Version 4.0.  You can now use the function @code{IN()} in
-other contexts, however.
-
+MySQL 4.0 supports multi-table deletes that can be used to efficiently
+delete rows based on information from one table or even from many tables
+at the same time.
 
 @node Missing SELECT INTO TABLE, Missing Transactions, Missing Sub-selects, Missing functions
 @subsubsection @code{SELECT INTO TABLE}
diff --git a/bdb/lock/lock_region.c b/bdb/lock/lock_region.c
index 4bd4ee4b765..5ca91a9951d 100644
--- a/bdb/lock/lock_region.c
+++ b/bdb/lock/lock_region.c
@@ -291,6 +291,7 @@ __lock_init(dbenv, lt)
 		    sizeof(struct __db_lock), MUTEX_ALIGN, &lp)) != 0)
 			goto mem_err;
 		lp->status = DB_LSTAT_FREE;
+		lp->gen=0;
 		if ((ret = __db_shmutex_init(dbenv, &lp->mutex,
 		    R_OFFSET(&lt->reginfo, &lp->mutex) + DB_FCNTL_OFF_LOCK,
 		    MUTEX_SELF_BLOCK, &lt->reginfo,
diff --git a/mysql-test/misc/select.tst b/mysql-test/misc/select.tst
deleted file mode 100644
index ed7f110f91a..00000000000
--- a/mysql-test/misc/select.tst
+++ /dev/null
@@ -1,4015 +0,0 @@
-# enkel s�kning
-#
-use ok;
-#set option sql_big_tables=1;
-
-select period from ok_system;
-select * from ok_system;
-select ok_system.* from ok_system;
-
-# s�kning med ej nyckel
-#
-select station.ok_namn from station where f�reningsnr = 58 and ok_namn like "%LJUGARN%";
-select ok_namn from station where ok_namn like "%leden" ;
-
-# s�kning med ej nyckel samt sortering och limit
-#
-select station.ok_namn from station where f�reningsnr = 57+1 order by ok_namn;
-select stationsnr from station where f�reningsnr = 58 order by ok_namn;
-select ok_namn from station order by ok_namn desc limit 10;
-select ok_namn from station order by ok_namn desc limit 5;
-select ok_namn from station order by ok_namn desc limit 5,5;
-
-# S�kning med nyckel = constant p� icke unik nyckel
-# H�r l�ses databasen direkt med read-next p� ok_namn
-#
-select station.ok_namn from station where ok_namn = 'J�RL�SMACKEN AB';
-select station.ok_namn from station where ok_namn LIKE 'J�RL�SMACKEN A_';
-select station.ok_namn from station where ok_namn LIKE 'J�RL_SMACKEN A_';
-select station.ok_namn from station where ok_namn LIKE 'J�RL�SMACKEN AB%';
-select station.ok_namn from station where ok_namn LIKE 'J%AB';
-select station.ok_namn from station where ok_namn LIKE 'J�RL�SMACKEN AB_';
-select station.ok_namn from station where ok_namn LIKE 'b_s%';
-
-#
-# Test av USE INDEX and IGNORE INDEX
-#
-explain select station.ok_namn from station where ok_namn = 'J�RL�SMACKEN AB';
-explain select ok_namn from station ignore index (ok_namn) where ok_namn = 'J�RL�SMACKEN AB';
-explain select ok_namn from station use index (stationsnr) where ok_namn = 'J�RL�SMACKEN AB';
-explain select ok_namn from station use index (ok_namn) where ok_namn = 'J�RL�SMACKEN AB';
-explain select ok_namn from station use index (stationsnr,ok_namn) where ok_namn = 'J�RL�SMACKEN AB';
-
-# F�ljande skall ge fel
-explain select ok_namn from station ignore index (ok_namn,not_used);
-explain select ok_namn from station use index (not_used);
-
-
-# Test av sortering p� p� anv�nd nyckel (ingen sortering beh�vs)
-#
-select station.ok_namn from station where ok_namn >= 'J�RL�SMACKEN AB' and ok_namn <= 'J�RL�SMACKEN AB' order by ok_namn;
-select stationsnr,ok_namn from station where ok_namn="" or ok_namn = "." order by ok_namn ;
-
-# s�kning med nyckel = constant med flera tr�ffar
-# H�r l�ses databasen direkt med read-next p� ok_namn ifall f� tr�ffar
-#
-select stationsnr,ok_namn from station where f�reningsnr = 37 and ok_namn = '�STERSUND';
-
-
-# s�kning med eller-niv�er p� nyckel
-# Ifall man kan begr�nsa nyckel till ett antal intervall s�kes endast de
-# m�jliga intervallen igenom.
-#
-select stationsnr from station where stationsnr=250501 or stationsnr="250502"; 
-select stationsnr from station where stationsnr=250501 or stationsnr=250502 or stationsnr >= 250505 and stationsnr <= 250601 or stationsnr between 250501 and 250502;
-
-
-# s�kning med nyckel LIKE constant
-# Ifall LIKE begreppet b�rjar p� en bokstav anv�nds nyckeln
-#
-select stationsnr,ok_namn from station where f�reningsnr = 37 and ok_namn like 'f%';
-select ok_namn from station where ok_namn like "L%" and ok_namn = "ok";
-select ok_namn from station where (ok_namn like "L%" and ok_namn = "Lund");
-select stationsnr,ok_namn from station where stationsnr like "25050%";
-select stationsnr,ok_namn from station where stationsnr like "25050_";
-
-# S�kning med distinct
-# ifall distinct endast �r p� en riktig tabell g�rs en automatisk group �ver
-# alla f�lt. I andra fall skapas alltid en tempor�r databas.
-# Ifall endast sorteringsf�lt fr�n huvudregistret, sorteras detta f�rst innan
-# den distinkta tabellen skapas.
-#
-select distinct f�reningsnr from station ;
-select distinct f�reningsnr from station order by f�reningsnr;
-select distinct f�reningsnr from station order by f�reningsnr desc;
-select distinct station.ok_namn,period from station,ok_system where f�reningsnr = 58 and ok_namn like "O%";
-select distinct ok_namn from station where f�reningsnr = 34 order by ok_namn;
-select distinct ok_namn from station limit 10;
-select distinct ok_namn from station having ok_namn like "A%" limit 10;
-select distinct substring(ok_namn,1,3) from station where ok_namn like "A%";
-select distinct substring(ok_namn,1,3) as a from station having a like "A%" order by a limit 10 ;
-select distinct substring(ok_namn,1,3) from station where ok_namn like "A%" limit 10;
-select distinct substring(ok_namn,1,3) as a from station having a like "A%" limit 10;
-SET OPTION SQL_BIG_TABLES=1;
-select distinct concat(ok_namn," ",ok_namn) as namn from station,station_period where station.stationsnr=station_period.stationsnr order by namn limit 10;
-SET OPTION SQL_BIG_TABLES=0;
-select distinct concat(ok_namn," ",ok_namn) from station,station_period where station.stationsnr=station_period.stationsnr order by ok_namn limit 10;
-select distinct co from station limit 10;
-
-#
-# Force use of remove_dupp
-#
-select distinct ok_namn,count(*) from station group by f�reningsnr,ok_namn;
-SET OPTION SQL_BIG_TABLES=1; # Force use of MyISAM
-select distinct ok_namn,count(*) from station group by f�reningsnr,ok_namn;
-SET OPTION SQL_BIG_TABLES=0;
-select distinct ok_namn,repeat("a",length(ok_namn)),count(*) from station group by f�reningsnr,ok_namn;
-
-# En order by som borde anv�nda merge i filesort!
-select distinct f�reningsnr,rtrim(space(512+f�reningsnr)) from station_period order by 1,2;
-
-# S�kning med distinct och order och flera register
-# Ifall result-posten �r liten skapas en unik nyckel i tempor�rbasen som
-# t�cker hela posten. I annat fall g�rs en j�mf�relse alla-mot-alla f�r att
-# eliminera dubletterna :(
-# Detta specifica exempel tar tyv�rr station_period som huvudtabell. Fixas
-# genom att
-# s�tta nyckel p� f�reningsnr.
-
-select distinct ok_namn from station,station_period where station.f�reningsnr = 34 and station.stationsnr=station_period.stationsnr order by ok_namn;
-
-#
-# Here the last ok_namn is optimized away from the order by
-#
-explain select station_period.stationsnr,ok_namn from station,station_period where station.f�reningsnr = 34 and station.stationsnr=station_period.stationsnr order by station_period.stationsnr,ok_namn;
-
-# S�kning med konstantregister (systemregister samt nyckel = konstant)
-# Alla konstantregister l�ses i b�rjan och h�refter l�ses resten normalt.
-#
-select period from ok_system;
-select period from ok_system where period=1900;
-select ok_namn,period from ok_system,station where stationsnr = 011401 order by period;
-
-
-# S�kning med konstantregister och flera nyckeldelar (posterna l�ses 1 g�ng vid
-# start av s�kningen)
-#
-select ok_namn,period from station,station_period where station.stationsnr = 011401 and station.stationsnr=station_period.stationsnr and station_period.period=9501;
-explain select ok_namn,period from station,station_period where station.stationsnr = 011401 and station_period.stationsnr=station.stationsnr and 9501 = station_period.period;
-
-# S�kning med ett konstantregister och flera poster i andra register
-#
-select ok_namn,period from station,ok_system where f�reningsnr*10 = 37*10;
-
-# S�kning med register referens och s�kning p� ej nyckel
-# (H�r �r station_period huvudregister)
-#
-select ok_namn,period,priv_ink�p,ftg_ink�p from station,station_period where station.stationsnr=station_period.stationsnr and period >= 9401 and period <= 9402 and station.f�reningsnr = 34 order by ok_namn,period, priv_ink�p;
-
-
-# S�kning med intervall p� ett register med full nyckel p� referensregister
-# (H�r �r station huvudregister och endast stationerna i stationsnummer
-# intervallet kontrolleras)
-#
-select station.stationsnr,ok_namn,period,priv_ink�p,ftg_ink�p from station,station_period where station.stationsnr>= 250501 and station.stationsnr <= 250505 and station.stationsnr=station_period.stationsnr and period = 9401 and station.f�reningsnr = 34;
-
-#
-# Test of stright join to force a full join
-#
-select STRAIGHT_JOIN station.f�reningsnr,f�reningsnamn from forening,station where station.f�reningsnr=forening.f�reningsnr group by station.f�reningsnr;
-
-select SQL_SMALL_RESULT station.f�reningsnr,f�reningsnamn from forening,station where station.f�reningsnr=forening.f�reningsnr group by station.f�reningsnr;
-
-#Full join (samt alias)
-select * from ok_system,ok_system ok_system2;
-select station.stationsnr,station2.stationsnr from station,station station2 where station.stationsnr >= 250501 and station.stationsnr <= 250505 and station2.stationsnr >= 250501 and station2.stationsnr <= 250505;
-
-#
-# test of left join
-#
-select station.f�reningsnr,f�reningsnamn from station left join forening using (f�reningsnr) where forening.f�reningsnr is null;
-explain select station.f�reningsnr,f�reningsnamn from station left join forening using (f�reningsnr) where forening.f�reningsnr is null;
-explain select station.f�reningsnr,f�reningsnamn from forening left join station using (f�reningsnr) where station.f�reningsnr is null;
-
-#
-# Join med formler
-#
-
-select distinct station.f�reningsnr,forening.f�reningsnr from station,forening where station.f�reningsnr=forening.f�reningsnr+1;
-explain select distinct station.f�reningsnr,forening.f�reningsnr from station,forening where station.f�reningsnr=forening.f�reningsnr+1;
-
-# S�kning med 'eller' med samma referens-begrepp
-# F�rst g�rs en intervall s�kning i det f�rsta registret och sedan refereras
-# det andra med nyckel med en 'test ifall nyckelanv�nding' f�r varje post
-#
-select station.stationsnr,station.f�reningsnr,ok_namn,period from station_period,station where station.stationsnr = 250501 and station.stationsnr=station_period.stationsnr and period = 9401 or station.stationsnr = 250502 and station.stationsnr=station_period.stationsnr and period = 9402;
-select station.stationsnr,station.f�reningsnr,ok_namn,period from station_period,station where (station.stationsnr = 250501 or station.stationsnr = 250502) and station.stationsnr=station_period.stationsnr and period>=9401 and period<=9402;
-select station.stationsnr,station.f�reningsnr,ok_namn,period from station_period,station where (station_period.stationsnr = 250501 or station_period.stationsnr = 250502) and station.stationsnr=station_period.stationsnr and period>=9401 and period<=9402;
-
-# Test of many paren levels
-#
-select period from ok_system where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909) ;
-select period from ok_system where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-
-select a.stationsnr from station as a,station b where ((a.stationsnr = 250501 and a.stationsnr=b.stationsnr) or a.stationsnr=250502 or a.stationsnr=250503 or (a.stationsnr=250505 and a.stationsnr<=b.stationsnr and b.stationsnr>=a.stationsnr)) and a.stationsnr=b.stationsnr;
-
-select stationsnr from station where stationsnr in (250502,98005,98006,250503,250605,250606) and stationsnr >=250502 and stationsnr not in (250605,250606);
-
-select stationsnr from station where stationsnr between 250502 and 250504;
-
-select ok_namn from station where (((ok_namn like "_%L%" ) or (ok_namn like "%ok%")) and ( ok_namn like "L%" or ok_namn like "G%")) and ok_namn like "L%" ;
-
-
-# Group on one table
-# optimizer: sort table by group and send rows.
-#
-select count(*) from ok_system ;
-select f�reningsnr,count(*),sum(stationsnr) from station group by f�reningsnr ;
-select f�reningsnr,count(*) from station group by f�reningsnr order by f�reningsnr desc limit 5;
-select count(*),min(stationsnamn),max(stationsnamn),sum(stationsnr),avg(stationsnr),std(stationsnr) from station where f�reningsnr = 34 and stationsnamn<>"";
-select f�reningsnr,count(*),min(stationsnamn),max(stationsnamn),sum(stationsnr),avg(stationsnr),std(stationsnr) from station group by f�reningsnr limit 3;
-select f�reningsnr,stationsnr,count(priv_ink�p),sum(priv_ink�p),min(priv_ink�p),max(priv_ink�p),avg(priv_ink�p) from station_period where f�reningsnr = 34 group by f�reningsnr,stationsnr ;
-select /*! SQL_SMALL_RESULT */ f�reningsnr,stationsnr,count(priv_ink�p),sum(priv_ink�p),min(priv_ink�p),max(priv_ink�p),avg(priv_ink�p) from station_period where f�reningsnr = 34 group by f�reningsnr,stationsnr ;
-select f�reningsnr,count(priv_ink�p),sum(priv_ink�p),min(priv_ink�p),max(priv_ink�p),avg(priv_ink�p) from station_period group by f�reningsnr ;
-select distinct mod(f�reningsnr,10) from forening group by f�reningsnr;
-select distinct 1 from forening group by f�reningsnr;
-select count(distinct stationsnr) from station;
-select f�reningsnr,count(distinct stationsnr) from station group by f�reningsnr;
-select f�reningsnr,count(*) from station group by f�reningsnr;
-select f�reningsnr,count(distinct concat(stationsnr,repeat(65,1000))) from station group by f�reningsnr;
-select f�reningsnr,count(distinct concat(stationsnr,repeat(65,200))) from station group by f�reningsnr;
-select f�reningsnr,count(distinct floor(stationsnr/100)) from station group by f�reningsnr; 
-select f�reningsnr,count(distinct concat(repeat(65,1000),floor(stationsnr/100))) from station group by f�reningsnr;
-
-#
-# group with where on a key field
-#
-select sum(stationsnr) from station where ok_namn="." group by stationsnr limit 10;
-select stationsnr,count(*) from station_drvm where stationsnr=098001 group by stationsnr;
-select stationsnr,count(*) from station_drvm where stationsnr=098004 and ftg>10 group by stationsnr;
-select count(*) from station_drvm where stationsnr=98001 and ftg=1;
-select stationsnr,count(*) from station_drvm where stationsnr=98001 and ftg=1 group by stationsnr;
-select stationsnr,count(*) from station_drvm where stationsnr>=98004 and stationsnr <=98005 group by stationsnr;
-select station.stationsnr,count(*) from station,station_drvm where station.stationsnr=98004 and station_drvm.stationsnr=station.stationsnr group by station_drvm.stationsnr;
-
-# Group with extra not group fields.
-#
-select f�reningsnr|0,f�reningsnamn from forening group by 1 ;
-select station.f�reningsnr,f�reningsnamn,count(*) from station,forening where station.f�reningsnr=forening.f�reningsnr group by station.f�reningsnr order by f�reningsnamn;
-
-#
-# Calculation with group functions
-#
-
-select sum(Period)/count(*) from ok_system ;
-select f�reningsnr,count(priv_ink�p) as "count",sum(priv_ink�p) as "sum" ,sum(priv_ink�p)/count(priv_ink�p)-avg(priv_ink�p) as "diff",(0+count(priv_ink�p))*f�reningsnr as func from station_period group by f�reningsnr ;
-select f�reningsnr,sum(priv_ink�p)/count(priv_ink�p) as avg from station_period group by f�reningsnr having avg > 70000000 order by avg;
-
-# Group with order on not first table
-# optimizer: sort table by group and write group records to tmp table.
-#            sort tmp_table and send rows.
-#
-select f�reningsnr,count(*) from station group by f�reningsnr order by 2 desc ;
-select f�reningsnr,count(*) from station where f�reningsnr > 40 group by f�reningsnr order by 2 desc ;
-select station.stationsnamn,station.stationsnr,count(priv_ink�p),sum(priv_ink�p),min(priv_ink�p),max(priv_ink�p),avg(priv_ink�p) from station_period,station where station_period.f�reningsnr = 34 and station.stationsnr = station_period.stationsnr group by stationsnr,station.stationsnamn ;
-
-
-# group by with many tables
-# optimizer: create tmp table with group-by uniq index.
-#           write with update to tmp table.
-#           sort tmp table according to order (or group if no order)
-#	    send rows
-#
-select station_period.f�reningsnr,ok_namn,sum(priv_ink�p) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.f�reningsnr = 58 group by f�reningsnr,ok_namn ;
-select station.f�reningsnr,count(*),min(ok_namn),max(ok_namn),sum(priv_ink�p),avg(priv_ink�p) from station,station_period where station_period.f�reningsnr >= 30 and station_period.f�reningsnr <= 58 and station_period.stationsnr = station.stationsnr and 1+1=2 group by station.f�reningsnr;
-
-
-# group with many tables and long group on many tables. group on formula
-#optimizer: create tmp table with neaded fields
-#           sort tmp table by group and calculate sums to new table
-#	    if different order by than group, sort tmp table
-#	    send rows
-
-select station_period.f�reningsnr+0,station_period.stationsnr,ok_namn,sum(priv_ink�p) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.f�reningsnr = 34 group by 1,station_period.stationsnr,ok_namn,ok_namn,ok_namn,ok_namn,ok_namn order by stationsnr;
-
-
-# WHERE const folding
-# optimize: If there is a "field = const" part in the where, change all
-#           instances of field in the and level to const.
-#	    All instances of const = const are checked once and removed.
-
-#Where -> station_period.stationsnr = 98005 and station.stationsnr = 98005
-select sum(priv_ink�p) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.f�reningsnr = 58 and station_period.stationsnr = 98004 and station.stationsnr = 98005 or station.stationsnr = station_period.stationsnr and station_period.stationsnr = 98005 and station.stationsnr = 98005 ;
-
-select station.stationsnr,sum(priv_ink�p) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.f�reningsnr = 58 and station_period.stationsnr = 98004 and station.stationsnr = 98005 or station.stationsnr = station_period.stationsnr and station_period.stationsnr = 98005 and station.stationsnr = 98005 or station_period.stationsnr = station.stationsnr and station.stationsnr = 98004 group by station.stationsnr ;
-
-explain select ok_namn from station where 1>2 or 2>3;
-explain select ok_namn from station where stationsnr=stationsnr;
-
-#
-# HAVING
-#
-select f�reningsnr,stationsnr from station HAVING stationsnr=250501 or stationsnr=250502; 
-select f�reningsnr,stationsnr from station WHERE stationsnr>=250501 HAVING stationsnr<=250502;
-select f�reningsnr,count(*) as count,sum(stationsnr) as sum from station group by f�reningsnr having count > 40 and sum/count >= 120000 ;
-select f�reningsnr from station group by f�reningsnr having count(*) > 40 and sum(stationsnr)/count(*) >= 120000 ;
-select station.f�reningsnr,f�reningsnamn,count(*) from station,forening where station.f�reningsnr=forening.f�reningsnr group by f�reningsnamn having station.f�reningsnr >= 40;
-
-#
-# MIN(), MAX() and COUNT() optimizing
-#
-select count(*) from station;
-select count(*) from station where stationsnr < 098024;
-select min(stationsnr) from station where stationsnr>= 098024;
-select max(stationsnr) from station where stationsnr>= 098024;
-select count(*) from station_drvm where stationsnr=098024;
-select count(*) from station_drvm where kundnr=78987 and stationsnr=098024;
-explain select min(stationsnr),max(stationsnr),count(*) from station;
-select min(stationsnr),max(stationsnr),count(*) from station;
-select min(kortnr),max(kortnr) from station_drvm where kundnr=78987 and stationsnr=098024;
-select count(*),min(kortnr),max(kortnr) from station_drvm where kundnr=78987 and stationsnr=098024;
-select kundnr,count(*) from station_drvm where stationsnr=098024 group by kundnr limit 20;
-select max(kundnr) from station_drvm where stationsnr=98024;
-#
-# Test of alias
-#
-select system.period from ok_system = system ;
-select system.period from ok_system as system ;
-select system.period as "Nuvarande period" from ok_system as system;
-select period as ok_period from ok_system;
-select period as ok_period from ok_system group by ok_period;
-select 1+1 as summa from ok_system group by summa;
-select period as "Nuvarande period" from ok_system group by "Nuvarande period";
-
-#
-# Some simple show commands
-#
-show databases;
-show tables;
-show tables from kf96 like "s%";
-show columns from station ;
-show columns from station from ok like 's%' ;
-show keys from station ;
-show variables;
-show variables like "p%";
-show table status from ok like "station%";
-
-
-#############################################################################
-#############################################################################
-#####################  END `ok' TESTS  ######################################
-#############################################################################
-#############################################################################
-
-
-#
-# numerical functions
-#
-select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2,sign(-5) ;
-select floor(5.5),floor(-5.5),ceiling(5.5),ceiling(-5.5),round(5.5),round(-5.5);
-select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
-select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2);
-select abs(-10),log(exp(10)),exp(log(sqrt(10))*2),pow(10,log10(10)),rand(999999),rand(),power(2,4);
-select pi(),sin(pi()/2),cos(pi()/2),tan(pi()),cot(1),asin(1),acos(0),atan(1);
-select 1 | (1+1),5 & 3,bit_count(7) ;
-select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
-select 10,10.0,10.,.1e+2,100.0e-1;
-select 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
-select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
-select 922337203685477580,92233720368547758000;
-select -922337203685477580,-92233720368547758000;
-select 9223372036854775807,-009223372036854775808;
-select +9999999999999999999,-9999999999999999999;
-select degrees(pi()),radians(360);
-
-#
-# test functions
-#
-select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ;
-select "a"<"b","a"<="b","b">="a","b">"a","a"="A","a"<>"b";
-select "a "="A", "A "="a", "a  " <= "A b"; 
-select "abc" like "a%", "abc" not like "%d%", "a%" like "a\%","abc%" like "a%\%","abcd" like "a%b_%d", "a" like "%%a","abcde" like "a%_e","abc" like "abc%";
-select "a" like "%%b","a" like "%%ab","ab" like "a\%", "ab" like "_", "ab" like "ab_", "abc" like "%_d", "abc" like "abc%d";
-select '?' like '|%', '?' like '|%' ESCAPE '|', '%' like '|%', '%' like '|%' ESCAPE '|', '%' like '%';
-select 'abc' like '%c','abcabc' like '%c',  "ab" like "", "ab" like "a", "ab" like "ab";
-select "Det h�r �r svenska" regexp "h[[:alpha:]]+r", "aba" regexp "^(a|b)*$";
-select "aba" regexp concat("^","a");
-select !0,NOT 0=1,!(0=0),1 AND 1,1 && 0,0 OR 1,1 || NULL, 1=1 or 1=1 and 1=0;
-select IF(0,"ERROR","this"),IF(1,"is","ERROR"),IF(NULL,"ERROR","a"),IF(1,2,3)|0,IF(1,2.0,3.0)+0 ;
-select 2 between 1 and 3, "monty" between "max" and "my",2=2 and "monty" between "max" and "my" and 3=3;
-select 'b' between 'a' and 'c', 'B' between 'a' and 'c';
-select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0);
-select -1.49 or -1.49,0.6 or 0.6;
-select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0");
-select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
-select decode(encode("abcdef","monty"),"monty")="abcdef";
-
-select CASE "b" when "a" then 1 when "b" then 2 END;
-select CASE "c" when "a" then 1 when "b" then 2 END;
-select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
-select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
-select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
-select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
-select CASE when 1=0 then "true" else "false" END;
-select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
-select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
-select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
-select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
-select case 1/0 when "a" then "true" else "false" END;
-select case 1/0 when "a" then "true" END;
-select (case 1/0 when "a" then "true" END) | 0;
-select (case 1/0 when "a" then "true" END) + 0.0;
-select case when 1>0 then "TRUE" else "FALSE" END;
-select case when 1<0 then "TRUE" else "FALSE" END;
-
-#
-# string functions
-#
-select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
-select 'hello' 'monty';
-select length("\n\t\r\b\0\_\%\\");
-select concat("monty"," was here ","again"),length("hello"),char(ascii('h'));
-select locate("he","hello"),locate("he","hello",2),locate("lo","hello",2) ;
-select instr("hello","he");
-select position("ll" in "hello"),position("a" in "hello");
-select left("hello",2),right("hello",2),substring("hello",2,2),mid("hello",1,5) ;
-select concat("",left(right(concat("what ",concat("is ","happening")),9),4),"",substring("monty",5,1)) ;
-select substring_index("www.tcx.se",".",-2),substring_index("www.tcx.se",".",1);
-select substring_index("www.tcx.se","tcx",1),substring_index("www.tcx.se","tcx",-1);
-select substring_index(".tcx.se",".",-2),substring_index(".tcx.se",".tcx",-1);
-
-select concat(":",ltrim("  left  "),":",rtrim("  right  "),":");
-select concat(":",trim(LEADING FROM " left"),":",trim(TRAILING FROM " right "),":");
-select concat(":",trim(" m "),":",trim(BOTH FROM " y "),":",trim("*" FROM "*s*"),":");
-select concat(":",trim(BOTH "ab" FROM "ababmyabab"),":",trim(BOTH "*" FROM "***sql"),":");
-select concat(":",trim(LEADING ".*" FROM ".*my"),":",trim(TRAILING ".*" FROM "sql.*.*"),":");
-
-select insert("txs",2,1,"hi"),insert("is ",4,0,"a"),insert("txxxxt",2,4,"es");
-select replace("aaaa","a","b"),replace("aaaa","aa","b"),replace("aaaa","a","bb"),replace("aaaa","","b"),replace("bbbb","a","c");
-select replace(concat(lcase(concat("THIS"," ","IS"," ","A"," ")),ucase("false")," ","test"),"FALSE","REAL") ;
-select soundex(""),soundex("he"),soundex("hello all folks");
-select password("test"),length(encrypt("test")),encrypt("test","aa");
-select md5("hello");
-select repeat("monty",5),concat("*",space(5),"*");
-select reverse("abc"),reverse("abcd");
-select rpad("a",4,"1"),rpad("a",4,"12"),rpad("abcd",3,"12");
-select lpad("a",4,"1"),lpad("a",4,"12"),lpad("abcd",3,"12");
-select rpad(741653838,17,'0'),lpad(741653838,17,'0');
-select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
-
-#
-# varbinary as string and number
-#
-select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ;
-select 0x31+1,concat(0x31)+1,-0xf;
-
-#
-# misc functions
-#
-select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
-select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
-select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
-select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
-select make_set(NULL,'a','b','c'),make_set(1|4,'a',NULL,'c'),make_set(1+2,'a',NULL,'c');
-select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","");
-
-select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.5555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
-
-select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
-select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
-select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
-
-#
-# system functions
-#
-select database(),user();
-
-#
-# Null tests
-#
-select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
-select 1 | NULL,1 & NULL,1+NULL,1-NULL;
-select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0;
-select strcmp("a",NULL),(1<NULL)+0.0,NULL regexp "a",null like "a%","a%" like null;
-select concat("a",NULL),replace(NULL,"a","b"),replace("string","i",NULL),replace("string",NULL,"i"),insert("abc",1,1,NULL),left(NULL,1);
-select repeat("a",0),repeat("ab",5+5),repeat("ab",-1),reverse(NULL);
-select field(NULL,"a","b","c");
-select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
-SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
-SELECT (NULL OR NULL) IS NULL;
-select NULL AND 0, 0 and NULL;
-select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
-#
-# Wrong or 'funny' use of functions.
-#
-
-select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
-select elt(2,1),field(NULL,"a","b","c"),reverse("");
-select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
-select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
-select locate("a","b",2),locate("","a",1);
-select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
-select concat("1","2")|0,concat("1",".5")+0.0;
-select substring_index("www.tcx.se","",3);
-select length(repeat("a",100000000)),length(repeat("a",1000*64));
-select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
-select position(("1" in (1,2,3)) in "01");
-select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
-select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
-select 1 and 0 or 2, 2 or 1 and 0;
-select length(repeat("a",65500)),length(concat(repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",10000)))),length(insert(repeat("a",40000),1,30000,repeat("b",50000)));
-select length(repeat("a",1000000)),length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",32000)))),length(insert(repeat("a",48000),1,1000,repeat("a",48000)));
-select 1+2/*hello*/+3;
-select 1 /* long
-multi line comment */;
-/* empty query */;
-select 1 /*!32301 +1 */;
-select 1 /*!52301 +1 */;
-
-#
-# time functions
-#
-select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
-select period_add("9602",-12),period_diff(199505,"9404") ;
-select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
-select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
-select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22");
-select now()-curdate()*1000000-curtime();
-select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
-select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
-select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
-select dayofmonth("1997-01-02"),dayofmonth(19970323);
-select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
-select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
-select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
-select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
-select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
-select week(19950101),week(19950101,1);
-select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
-select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
-select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
-select yearweek('1987-01-01',1),yearweek('1987-01-01');
-
-select dayname("1962-03-03"),dayname("1962-03-03")+0;
-select monthname("1972-03-04"),monthname("1972-03-04")+0;
-select time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
-select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
-select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
-
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
-
-select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
-select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
-select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
-select INTERVAL 1 DAY + "1997-12-31";
-select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
-
-select date_sub("1998-01-02",INTERVAL 31 DAY);
-select date_add("1997-12-31",INTERVAL 1 SECOND);
-select date_add("1997-12-31",INTERVAL 1 DAY);
-select date_add(NULL,INTERVAL 100000 SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND);
-select date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND);
-select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
-select date_add('1998-01-30',Interval 1 month);
-select date_add('1998-01-30',Interval '2:1' year_month);
-select date_add('1996-02-29',Interval '1' year);
-select extract(YEAR FROM "1999-01-02 10:11:12");
-select extract(YEAR_MONTH FROM "1999-01-02");
-select extract(DAY FROM "1999-01-02");
-select extract(DAY_HOUR FROM "1999-01-02 10:11:12");
-select extract(DAY_MINUTE FROM "02 10:11:12");
-select extract(DAY_SECOND FROM "225 10:11:12");
-select extract(HOUR FROM "1999-01-02 10:11:12");
-select extract(HOUR_MINUTE FROM "10:11:12");
-select extract(HOUR_SECOND FROM "10:11:12");
-select extract(MINUTE FROM "10:11:12");
-select extract(MINUTE_SECOND FROM "10:11:12");
-select extract(SECOND FROM "1999-01-02 10:11:12");
-
-#
-# test variables
-#
-set @`test`=1,@TEST=3,@select=2;
-select @test,@`select`,@TEST,@not_used;
-set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
-select @test_int,@test_double,@test_string,@test_string2,@select;
-set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
-select @test_int,@test_double,@test_string,@test_string2;
-set @test_int="hellohello",@test_double="hellohello",@test_string="hellohello",@test_string2="hellohello";
-select @test_int,@test_double,@test_string,@test_string2;
-set @test_int=null,@test_double=null,@test_string=null,@test_string2=null;
-select @test_int,@test_double,@test_string,@test_string2;
-select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
-
-#
-# Some functions that has failed sometimes
-#
-select concat(encrypt('haha','R1'),encrypt('haha','R2'));
-
-#
-# Functions and groups
-#
-select concat(station_period.f�reningsnr,station_period.stationsnr) as concat,station_period.stationsnr+1,left(ok_namn,4),sum(priv_ink�p/100),sum(length(concat("1","2"))) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.f�reningsnr = 34 group by concat,2,3 order by 2;
-
-#
-# Some new procedures
-#
-select stationsnr from station_drvm where stationsnr>=98001 and stationsnr <= 98002 group by stationsnr procedure split_sum(5,dm_1_kvant10,1,stationsnr,kundnr,kortnr) ;
-select stationsnr from station_drvm where stationsnr>=98001 and stationsnr <= 98002 group by stationsnr procedure split_count(5,dm_1_kvant10,1,stationsnr,kundnr,kortnr) ;
-
-#
-# explain
-#
-explain select period from ok_system;
-explain select period from ok_system where period=1900;
-explain select ok_namn from station where ok_namn like "L%" and ok_namn = "ok";
-explain select distinct ok_namn from station,station_period where station.stationsnr=station_period.stationsnr order by ok_namn;
-explain select 1;
-explain select count(*) from ok_system;
-
-select forening.f�reningsnr,max(ok_namn) from station,forening where forening.f�reningsnr=station.f�reningsnr group by 1 into outfile "/tmp/select-test.out";
-
-#
-# ODBC compatibility
-# 
-
-select {fn length("hello")}, { date "1997-10-20" };
-
-#
-# AVG() crashed for Perra when sorting.
-#
-
-use kf96;
-#set option sql_big_tables=1;
-
-select �vergrupp as �vergrupp,AVG(100 * omd�me * antal_l�st_mersmak / antal_l�st_med_mersmak / antal_intervjuade) as my_index from mersmak_tidnings_info,mersmak_artikel_info where mersmak_tidnings_info.�r=mersmak_artikel_info.�r and mersmak_tidnings_info.nummer=mersmak_artikel_info.nr and mersmak_tidnings_info.namn=mersmak_artikel_info.artikelnamn and mersmak_tidnings_info.typ='ar' and mersmak_tidnings_info.bildnr=1 group by �vergrupp order by my_index desc ;
-
-select concat("O",substring('000',1,3-length(concat(111))),"K");
-
-#
-# Test in the "test" database
-#
-
-use test;
-#set option sql_big_tables=1;
-
-drop table if exists t1,t2,t3,t4,t5;
-
-CREATE TABLE t1 (
-  auto int(5) unsigned DEFAULT 0 NOT NULL auto_increment,
-  string char(10) default "hello",
-  tiny tinyint(4) DEFAULT '0' NOT NULL ,
-  short smallint(6) DEFAULT '1' NOT NULL ,
-  medium mediumint(8) DEFAULT '0' NOT NULL,
-  long_int int(11) DEFAULT '0' NOT NULL,
-  longlong bigint(13) DEFAULT '0' NOT NULL,
-  real_float float(13,1) DEFAULT 0.0 NOT NULL,
-  real_double double(16,4),
-  utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
-  ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
-  umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
-  ulong int(11) unsigned DEFAULT '0' NOT NULL,
-  ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
-  time_stamp timestamp,
-  date_field date,	
-  time_field time,	
-  date_time datetime,
-  blob_col blob,
-  tinyblob_col tinyblob,
-  mediumblob_col mediumblob  not null,
-  longblob_col longblob  not null,
-  options enum('one','two','tree') not null,
-  flags set('one','two','tree') not null,
-  PRIMARY KEY (auto),
-  KEY (utiny),
-  KEY (tiny),
-  KEY (short),
-  KEY any_name (medium),
-  KEY (longlong),
-  KEY (real_float),
-  KEY (ushort),
-  KEY (umedium),
-  KEY (ulong),
-  KEY (ulonglong,ulong),
-  KEY (options,flags)
-);
-
-show fields from t1;
-show keys from t1;
-
-CREATE UNIQUE INDEX test on t1 ( auto ) ;
-CREATE INDEX test2 on t1 ( ulonglong,ulong) ;
-CREATE INDEX test3 on t1 ( medium ) ;
-DROP INDEX test ON t1;
-
-insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
-insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
-insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3);
-insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
-insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
-insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
-insert into t1 (tiny) values (1);
-
-select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,utiny,ushort,umedium,ulong,ulonglong,mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000),date_field,time_field,date_time,blob_col,tinyblob_col,mediumblob_col,longblob_col from t1;
-
-
-ALTER TABLE t1
-add new_field char(10) default "new" not null,
-change blob_col new_blob_col varchar(20),
-change date_field date_field char(10),
-alter column string set default "new default",
-alter short drop default,
-DROP INDEX utiny,
-DROP INDEX ushort,
-DROP PRIMARY KEY,
-DROP FOREIGN KEY any_name,
-ADD INDEX (auto);
-
-LOCK TABLES t1 WRITE;
-ALTER TABLE t1 
-RENAME as t2,
-DROP longblob_col;
-UNLOCK TABLES;
-
-ALTER TABLE t2 rename as t3;
-LOCK TABLES t3 WRITE ;
-ALTER TABLE t3 rename as t1;
-UNLOCK TABLES;
-
-select auto,new_field,new_blob_col,date_field from t1 ;
-
-#
-# check with old syntax
-#
-CREATE TABLE t2 (
-  auto int(5) unsigned NOT NULL DEFAULT 0 auto_increment,
-  string char(20),
-  mediumblob_col mediumblob not null,
-  new_field char(2),
-  PRIMARY KEY (auto)
-);
-
-INSERT INTO t2 (string,mediumblob_col,new_field) SELECT string,mediumblob_col,new_field from t1 where auto > 10;
-
-select * from t2;
-
-# test enums
-select distinct flags from t1;
-select flags from t1 where find_in_set("two",flags)>0;
-select flags from t1 where find_in_set("unknown",flags)>0;
-select options,flags from t1 where options="ONE" and flags="ONE";
-select options,flags from t1 where options="one" and flags="one";
-
-drop table t2;
-
-#
-# Check CREATE ... SELECT
-#
-
-create table t2 select * from t1;
-update t2 set string="changed" where auto=16;
-show columns from t1;
-show columns from t2;
-select * from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null)));
-select * from t1,t2 where t1.auto=t2.auto and not (t1.string<=>t2.string and t1.tiny<=>t2.tiny and t1.short<=>t2.short and t1.medium<=>t2.medium and t1.long_int<=>t2.long_int and t1.longlong<=>t2.longlong and t1.real_float<=>t2.real_float and t1.real_double<=>t2.real_double and t1.utiny<=>t2.utiny and t1.ushort<=>t2.ushort and t1.umedium<=>t2.umedium and t1.ulong<=>t2.ulong and t1.ulonglong<=>t2.ulonglong and t1.time_stamp<=>t2.time_stamp and t1.date_field<=>t2.date_field and t1.time_field<=>t2.time_field and t1.date_time<=>t2.date_time and t1.new_blob_col<=>t2.new_blob_col and t1.tinyblob_col<=>t2.tinyblob_col and t1.mediumblob_col<=>t2.mediumblob_col and t1.options<=>t2.options and t1.flags<=>t2.flags and t1.new_field<=>t2.new_field);
-
-drop table t2;
-
-create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1;
-show columns from t2;
-select * from t2;
-drop table t1,t2;
-
-create table t1 (c int);
-insert into t1 values(1),(2);
-create table t2 select * from t1;
-create table t3 select * from t1, t2; # Should give an error
-create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
-show columns from t3;
-drop table t1,t2,t3;
-
-create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield));
-drop table t1;
-
-create table t1 ( id integer unsigned not null primary key );
-create table t2 ( id integer unsigned not null primary key );
-insert into t1 values (1), (2);
-insert into t2 values (1);
-select  t1.id as id_A,  t2.id as id_B from t1 left join t2 using ( id ); 
-create table t3 (id_A integer unsigned not null, id_B integer unsigned null  );
-insert into t3 select t1.id as id_A,  t2.id as id_B from t1 left join t2 using ( id );
-select * from t3;
-drop table t3;
-create table t3 select t1.id as id_A,  t2.id as id_B from t1 left join t2 using ( id );
-select * from t3;
-drop table t1,t2,t3;
-
-#
-# Check floating point handling
-
-create table t1 (f1 float(24),f2 float(52));
-show columns from t1;
-insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
-insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
-select * from t1;
-drop table t1;
-
-#
-# FLOAT/DOUBLE/DECIMAL handling
-#
-
-create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
-show columns from t1;
-drop table t1;
-create table t1 (f float(54));	# Should give an error
-drop table if exists t1;
-
-create table t1 (a  decimal(7,3) not null, key (a));
-insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
-select a from t1 order by a;
-select min(a) from t1;
-drop table t1;
-
-#
-# BIGINT handling
-#
-
-create table t1 (a bigint unsigned);
-insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFF);
-select * from t1;
-drop table t1;
-
-#
-# Check on condition on different length keys.
-
-CREATE TABLE t1 (
-  a char(5) NOT NULL,
-  b char(4) NOT NULL,
-  KEY (a),
-  KEY (b)
-);
-
-INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a');
-
-select * from t1,t1 as t2;
-explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
-select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
-select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by t1.a;
-select * from t1 where a='a';
-drop table t1;
-
-#
-# Check null keys
-
-create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
-insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
-explain select * from t1 where a is null;
-explain select * from t1 where a is null and b = 2;
-explain select * from t1 where a is null and b = 7;
-explain select * from t1 where a=2 and b = 2;
-explain select * from t1 where a<=>b limit 2;
-explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-explain select * from t1 where (a is null or a = 7) and b=7;
-explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
-explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-explain select * from t1 where a > 1 and a < 3 limit 1;
-explain select * from t1 where a > 8 and a < 9;
-select * from t1 where a is null;
-select * from t1 where a is null and b = 7;
-select * from t1 where a<=>b limit 2;
-select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
-select * from t1 where (a is null or a = 7) and b=7;
-select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
-explain select * from t1 where a is null and b = 2;
-explain select * from t1 where a is null and b = 2 and c=0;
-explain select * from t1 where a is null and b = 7 and c=0;
-explain select * from t1 where a=2 and b = 2;
-explain select * from t1 where a<=>b limit 2;
-explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
-explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
-explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
-explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-explain select * from t1 where a > 1 and a < 3 limit 1;
-explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
-explain select * from t1 where a > 8 and a < 9;
-explain select * from t1 where b like "6%";
-select * from t1 where a is null;
-select * from t1 where a is null and b = 7 and c=0;
-select * from t1 where a<=>b limit 2;
-select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
-select * from t1 where (a is null or a = 7) and b=7 and c=0;
-select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-select * from t1 where b like "6%";
-drop table t1;
-
-#
-# Check some special create statements.
-#
-
-create table t1 (b char(0));
-insert into t1 values (""),(null);
-select * from t1;
-drop table if exists t1;
-
-create table t1 (b char(0) not null);
-create table if not exists t1 (b char(0) not null);
-insert into t1 values (""),(null);
-select * from t1;
-drop table if exists t1;
-
-#
-# the following should give errors
-#
-
-create table t2 type=heap select * from t1;
-create table t2 select auto+1 from t1;
-drop table if exists t1,t2;
-create table t1 (b char(0) not null, index(b));
-create table t1 (a int not null auto_increment,primary key (a)) type=heap;
-create table t1 (a int not null,b text) type=heap;
-create table t1 (a int ,primary key(a)) type=heap;
-create table t1 (a int,b text, index(a)) type=isam;
-create table t1 (a int,b text, index(b)) type=isam;
-drop table if exists t1;
-
-#
-# Test of some show commands
-#
-create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
-insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
-create table t2 type=isam select * from t1;
-optimize table t1;
-check table t1,t2;
-repair table t1,t2;
-check table t2,t1;
-lock tables t1 read;
-check table t2,t1;
-show keys from t1;
-drop table t1,t2;
-
-create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
-insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
-check table t1 type=fast;
-check table t1 type=fast;
-check table t1 type=changed;
-insert into t1 values (5,5,5);
-check table t1 type=changed;
-check table t1 type=extended;
-show keys from t1;
-insert into t1 values (5,5,5);
-optimize table t1;
-optimize table t1;
-drop table t1;
-
-#
-# simple test of all group functions
-#
-
-create table t1 (grp int, a bigint unsigned, c char(10) not null);
-insert into t1 values (1,1,"a");
-insert into t1 values (2,2,"b");
-insert into t1 values (2,3,"c");
-insert into t1 values (3,4,"E");
-insert into t1 values (3,5,"C");
-insert into t1 values (3,6,"D");
-
-# Test of MySQL field extension with and without matching records.
-select a,c,sum(a) from t1 group by a;
-select a,c,sum(a) from t1 where a > 10 group by a;
-select sum(a) from t1 where a > 10;
-select a from t1 order by rand(10);
-select distinct a from t1 order by rand(10);
-select count(distinct a),count(distinct grp) from t1;
-insert into t1 values (null,null,'');
-select count(distinct a),count(distinct grp) from t1;
-
-select sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1;
-select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
-select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
-
-create table t2 (grp int, a bigint unsigned, c char(10));
-insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
-replace into t2 select grp, a, c from t1 limit 2,1;
-select * from t2;
-
-drop table t2;
-
-#
-# test of left outer join
-#
-
-create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a));
-insert into t2 values (1,1,"a",1);
-insert into t2 values (3,4,"A",4);
-insert into t2 values (3,5,"B",5);
-insert into t2 values (3,6,"C",6);
-insert into t2 values (4,7,"D",7);
-
-select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a;
-select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c;
-select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) };
-select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2;
-select t1.*,t2.* from t1 left join t2 using (a);
-select t1.*,t2.* from t1 left join t2 using (a,c);
-select t1.*,t2.* from t1 left join t2 using (c);
-select t1.*,t2.* from t1 natural left outer join t2;
-
-select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3;
-select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null;
-
-explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1;
-explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
-
-select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
-
-# The next query should rearange the left joins to get this to work
-explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
-select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
-
-# The next query should give an error in MySQL
-select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
-
-# Test of inner join
-select t1.*,t2.* from t1 inner join t2 using (a);
-select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a);
-select t1.*,t2.* from t1 natural join t2;
-
-drop table t1,t2;
-
-#
-# Problem with std()
-#
-CREATE TABLE t1 (id int(11),value1 float(10,2));
-INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00); 
-CREATE TABLE t2 (id int(11),name char(20)); 
-INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two'); 
-select id, avg(value1), std(value1) from t1 group by id;
-select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id;
-drop table t1,t2;
-
-#
-# Test of bug in left join & avg
-
-create table t1 (id int not null);
-create table t2 (id int not null,rating int null);
-insert into t1 values(1),(2),(3);
-insert into t2 values(1, 3),(2, NULL),(2, NULL),(3, 2),(3, NULL);
-select t1.id, avg(rating) from t1 left join t2 on ( t1.id = t2.id ) group by t1.id;
-drop table t1,t2;
-
-# test of count
-
-create table t1 (a smallint(6) primary key, c char(10), b text);
-INSERT INTO t1 VALUES (1,'1','1');
-INSERT INTO t1 VALUES (2,'2','2');
-INSERT INTO t1 VALUES (4,'4','4');
-
-select count(*) from t1;
-select count(*) from t1 where a = 1;
-select count(*) from t1 where a = 100;
-select count(*) from t1 where a >= 10;
-select count(a) from t1 where a = 1;
-select count(a) from t1 where a = 100;
-select count(a) from t1 where a >= 10;
-select count(b) from t1 where b >= 2;
-select count(b) from t1 where b >= 10;
-select count(c) from t1 where c = 10;
-drop table t1;
-
-#
-# Test of left join bug
-#
-
-CREATE TABLE t1 (
- usr_id INT unsigned NOT NULL,
- uniq_id INT unsigned NOT NULL AUTO_INCREMENT,
-        start_num INT unsigned NOT NULL DEFAULT 1,
-        increment INT unsigned NOT NULL DEFAULT 1,
- PRIMARY KEY (uniq_id),
- INDEX usr_uniq_idx (usr_id, uniq_id),
- INDEX uniq_usr_idx (uniq_id, usr_id)
-);
-CREATE TABLE t2 (
- id INT unsigned NOT NULL DEFAULT 0,
- usr2_id INT unsigned NOT NULL DEFAULT 0,
- max INT unsigned NOT NULL DEFAULT 0,
- c_amount INT unsigned NOT NULL DEFAULT 0,
- d_max INT unsigned NOT NULL DEFAULT 0,
- d_num INT unsigned NOT NULL DEFAULT 0,
- orig_time INT unsigned NOT NULL DEFAULT 0,
- c_time INT unsigned NOT NULL DEFAULT 0,
- active ENUM ("no","yes") NOT NULL,
- PRIMARY KEY (id,usr2_id),
- INDEX id_idx (id),
- INDEX usr2_idx (usr2_id)
-);
-INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198);
-
-#1st select shows that one record is returned with null entries for the right
-#table, when selecting on an id that does not exist in the right table t2
-SELECT t1.usr_id,t1.uniq_id,t1.increment,
-t2.usr2_id,t2.c_amount,t2.max
-FROM t1
-LEFT JOIN t2 ON t2.id = t1.uniq_id
-WHERE t1.uniq_id = 4
-ORDER BY t2.c_amount;
-
-# The same with RIGHT JOIN
-SELECT t1.usr_id,t1.uniq_id,t1.increment,
-t2.usr2_id,t2.c_amount,t2.max
-FROM t2
-RIGHT JOIN t1 ON t2.id = t1.uniq_id
-WHERE t1.uniq_id = 4
-ORDER BY t2.c_amount;
-
-INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
-INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
-INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes');
-
-#3rd select should show that one record is returned with null entries for the
-# right table, when selecting on an id that does not exist in the right table
-# t2 but this select returns an empty set!!!!
-SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount;
-SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount;
-# Removing the ORDER BY works:
-SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4;
-
-drop table t1,t2;
-
-#
-# Test syntax of not supported functions
-#
-
-create table t1 (
-	a int not null references t2,
-	b int not null references t2 (c),
-	primary key (a,b),
-	foreign key (a) references t3 match full,
-	foreign key (a) references t3 match partial,
-	foreign key (a,b) references t3 (c,d) on delete no action
-	  on update no action,
-	foreign key (a,b) references t3 (c,d) on update cascade,
-	foreign key (a,b) references t3 (c,d) on delete set default,
-	foreign key (a,b) references t3 (c,d) on update set null);
-
-create index a on t1 (a);
-create unique index b on t1 (a,b);
-
-grant all privileges on t1 to monty,david with grant option;
-show grants for monty;
-show grants for david;
-revoke all privileges on t1 from david;
-show grants for david;
-drop table t1;
-
-#
-# test sort,min and max on binary fields
-#
-
-create table t1 (name char(20) not null, primary key (name));
-create table t2 (name char(20) binary not null, primary key (name));
-insert into t1 values ("�");
-insert into t1 values ("�");
-insert into t1 values ("�");
-insert into t2 select * from t1;
-
-select * from t1 order by name;
-select concat("*",name,"*") from t1 order by 1;
-select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
-select * from t2 order by name;
-select concat("*",name,"*") from t2 order by 1;
-select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
-select name from t1 where name between '�' and '�';
-select name from t2 where name between '�' and '�';
-select name from t2 where name between '�' and '�';
-
-drop table t1,t2;
-
-#
-# test of full join with blob
-#
-
-create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
-insert into t1 values (null,"a","A");
-insert into t1 values (null,"bbb","BBB");
-insert into t1 values (null,"ccc","CCC");
-select last_insert_id();
-select * from t1,t1 as t2;
-
-drop table t1;
-
-#
-# Test of changing TEXT column
-#
-create table t1 (a text);
-insert into t1 values ('where');
-update t1 set a='Where'; 
-select * from t1;
-drop table t1;
-
-#
-# Some special cases with empty tables
-#
-
-create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
-select count(*) from t1;
-select * from t1;
-select * from t1 limit 0;
-drop table t1;
-
-#
-# Test keywords as fields
-#
-create table t1 (time time, date date, timestamp timestamp);
-insert into t1 values ("12:22:22","97:02:03","1997-01-02");
-select * from t1;
-select t1.time+0,t1.date+0,t1.timestamp+0,concat(date," ",time) from t1;
-drop table t1;
-
-#
-# test of blob, text, char and char binary
-#
-create table t1 (t text,c char(10),b blob, d char(10) binary);
-insert into t1 values (NULL,NULL,NULL,NULL);
-insert into t1 values ("","","","");
-insert into t1 values ("hello","hello","hello","hello");
-insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
-insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
-insert into t1 values ("a","a","a","a");
-insert into t1 values (1,1,1,1);
-insert into t1 values (NULL,NULL,NULL,NULL);
-update t1 set c="",b=null where c="1";
-
-lock tables t1 READ;
-show fields from t1;
-lock tables t1 WRITE;
-show fields from t1;
-unlock tables;
-
-select t from t1 where t like "hello";
-select c from t1 where c like "hello";
-select b from t1 where b like "hello";
-select d from t1 where d like "hello";
-select c from t1 having c like "hello";
-select d from t1 having d like "hello";
-select t from t1 where t like "%HELLO%";
-select c from t1 where c like "%HELLO%";
-select b from t1 where b like "%HELLO%";
-select d from t1 where d like "%HELLO%";
-select c from t1 having c like "%HELLO%";
-select d from t1 having d like "%HELLO%";
-select t from t1 order by t;
-select c from t1 order by c;
-select b from t1 order by b;
-select d from t1 order by d;
-select distinct t from t1;
-select distinct b from t1;
-select distinct t from t1 order by t;
-select distinct b from t1 order by b;
-select t from t1 group by t;
-select b from t1 group by b;
-set option sql_big_tables=1;
-select distinct t from t1;
-select distinct b from t1;
-select distinct t from t1 order by t;
-select distinct b from t1 order by b;
-select distinct c from t1;
-select distinct d from t1;
-select distinct c from t1 order by c;
-select distinct d from t1 order by d;
-select c from t1 group by c;
-select d from t1 group by d;
-set option sql_big_tables=0;
-select distinct * from t1;
-select t,count(*) from t1 group by t;
-select b,count(*) from t1 group by b;
-select c,count(*) from t1 group by c;
-select d,count(*) from t1 group by d;
-drop table t1;
-
-#
-# testing different DATETIME ranges
-#
-create table t1 (t datetime);
-insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959);
-select * from t1;
-delete from t1 where t > 0;
-optimize table t1;
-insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959");
-select * from t1;
-drop table t1;
-
-#
-# testing different TIME formats
-#
-create table t1 (t time);
-insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10  1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
-# Test wrong values
-insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
-select * from t1;
-drop table t1;
-
-create table t1 (date date);  
-insert into t1 values ("2000-08-10"),("2000-08-11");
-select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1;
-drop table t1;
-
-create table t1 (t time);
-insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09:00:00'),('09:00:00'),('13:00:00'),('13:00:00'),('13:00:00'),('09:00:00');
-;
-select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1;
-select sec_to_time(time_to_sec(t)) from t1;
-drop table t1;
-
-#
-# test of into outfile|dumpfile
-#
-
-create table t1 (`a` blob);
-insert into t1 values("hello world"),("Hello mars"),(NULL);
-select * into outfile "/tmp/select-test.1" from t1;
-select load_file("/tmp/select-test.1");
-select * into dumpfile "/tmp/select-test.2" from t1 limit 1;
-select load_file("/tmp/select-test.2");
-select * into dumpfile "/tmp/select-test.3" from t1 where a is null;
-select load_file("/tmp/select-test.3");
-
-# the following should give errors
-
-select * into outfile "/tmp/select-test.1" from t1;
-select * into dumpfile "/tmp/select-test.1" from t1;
-select * into dumpfile "/tmp/select-test.99" from t1;
-select load_file("/tmp/select-test.not-exist");
-drop table t1;
-
-#
-# This failed for lia Perminov
-#
-
-create table t1 (id int primary key);
-create table t2 (id int);
-insert into t1 values (75);
-insert into t1 values (79);
-insert into t1 values (78);
-insert into t1 values (77);
-replace into t1 values (76);
-replace into t1 values (76);
-insert into t1 values (104);
-insert into t1 values (103);
-insert into t1 values (102);
-insert into t1 values (101);
-insert into t1 values (105);
-insert into t1 values (106);
-insert into t1 values (107);
-
-insert into t2 values (107);
-insert into t2 values (75);
-
-select t1.id, t2.id from t1, t2 where t2.id = t1.id;
-select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t1.id;
-select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t2.id;
-
-drop table t1,t2;
-
-#
-# Bug with distinct and INSERT INTO
-# Bug with group by and not used fields
-#
-
-CREATE TABLE t1 (id int,facility char(20));
-CREATE TABLE t2 (facility char(20));
-INSERT INTO t1 VALUES (NULL,NULL);
-INSERT INTO t1 VALUES (-1,'');
-INSERT INTO t1 VALUES (0,'');
-INSERT INTO t1 VALUES (1,'/L');
-INSERT INTO t1 VALUES (2,'A01');
-INSERT INTO t1 VALUES (3,'ANC');
-INSERT INTO t1 VALUES (4,'F01');
-INSERT INTO t1 VALUES (5,'FBX');
-INSERT INTO t1 VALUES (6,'MT');
-INSERT INTO t1 VALUES (7,'P');
-INSERT INTO t1 VALUES (8,'RV');
-INSERT INTO t1 VALUES (9,'SRV');
-INSERT INTO t1 VALUES (10,'VMT');
-INSERT INTO t2 SELECT DISTINCT FACILITY FROM t1;
-
-select id from t1 group by id;
-select * from t1 order by id;
-select id-5,facility from t1 order by "id-5";
-select max(id),concat(facility) from t1 group by id ;
-select id+0 as a,max(id),concat(facility) as b from t1 group by a order by b desc;
-select id >= 0 and id <= 5 as grp,count(*) from t1 group by grp;
-
-SELECT DISTINCT FACILITY FROM t1;
-SELECT FACILITY FROM t2;
-SELECT count(*) from t1,t2 where t1.facility=t2.facility;
-select count(facility) from t1;
-select count(*) from t1;
-select count(*) from t1 where facility IS NULL;
-select count(*) from t1 where facility = NULL;
-select count(*) from t1 where facility IS NOT NULL;
-select count(*) from t1 where id IS NULL;
-select count(*) from t1 where id IS NOT NULL;
-
-drop table t1,t2;
-
-#
-# Bug with order by
-#
-
-CREATE TABLE t1 (
-  id int(6) DEFAULT '0' NOT NULL,
-  idservice int(5),
-  clee char(20) NOT NULL,
-  flag char(1),
-  KEY id (id),
-  PRIMARY KEY (clee)
-);
-
-
-INSERT INTO t1 VALUES (2,4,'6067169d','Y');
-INSERT INTO t1 VALUES (2,5,'606716d1','Y');
-INSERT INTO t1 VALUES (2,1,'606717c1','Y');
-INSERT INTO t1 VALUES (3,1,'6067178d','Y');
-INSERT INTO t1 VALUES (2,6,'60671515','Y');
-INSERT INTO t1 VALUES (2,7,'60671569','Y');
-INSERT INTO t1 VALUES (2,3,'dd','Y');
-
-CREATE TABLE t2 (
-  id int(6) DEFAULT '0' NOT NULL auto_increment,
-  description varchar(40) NOT NULL,
-  idform varchar(40),
-  ordre int(6) unsigned DEFAULT '0' NOT NULL,
-  image varchar(60),
-  PRIMARY KEY (id),
-  KEY id (id,ordre)
-);
-
-#
-# Dumping data for table 't2'
-#
-
-INSERT INTO t2 VALUES (1,'Emettre un appel d''offres','en_construction.html',10,'emettre.gif');
-INSERT INTO t2 VALUES (2,'Emettre des soumissions','en_construction.html',20,'emettre.gif');
-INSERT INTO t2 VALUES (7,'Liste des t2','t2_liste_form.phtml',51060,'link.gif');
-INSERT INTO t2 VALUES (8,'Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif');
-INSERT INTO t2 VALUES (9,'Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif');
-INSERT INTO t2 VALUES (10,'Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif');
-INSERT INTO t2 VALUES (3,'Cr�er une fiche de client','clients_ajoute_form.phtml',40000,'link.gif');
-INSERT INTO t2 VALUES (4,'Modifier des clients','en_construction.html',40010,'link.gif');
-INSERT INTO t2 VALUES (5,'Effacer des clients','en_construction.html',40020,'link.gif');
-INSERT INTO t2 VALUES (6,'Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif');
-
-
-select t1.id,t1.idservice,t2.ordre,t2.description  from t1, t2 where t1.id = 2   and t1.idservice = t2.id  order by t2.ordre;
- 
-drop table t1,t2;
-
-create table t1 (first char(10),last char(10));
-insert into t1 values ("Michael","Widenius");
-insert into t1 values ("Allan","Larsson");
-insert into t1 values ("David","Axmark");
-select concat(first," ",last) as name from t1 order by name;
-select concat(last," ",first) as name from t1 order by name;
-drop table t1;
-
-#
-# bug in distinct + order by
-#
-
-create table t1 (i int);
-insert into t1 values(1),(2),(1),(2),(1),(2),(3);
-select distinct i from t1;
-select distinct i from t1 order by rand(5);
-select distinct i from t1 order by i desc;
-select distinct i from t1 order by 1-i;
-select distinct i from t1 order by mod(i,2);
-drop table t1;
-
-#
-# test of dummy table names
-#
-
-create table 1ea10 (1a20 int,1e int);
-insert into 1ea10 values(1,1);
-select 1ea10.1a20,1e+ 1e+10 from 1ea10;
-drop table 1ea10;
-create table t1 (t1.index int);
-drop table t1;
-drop database if exists test$1;
-create database test$1;
-create table test$1.$test1 (a$1 int, $b int, c$ int);
-insert into test$1.$test1 values (1,2,3);
-select a$1, $b, c$ from test$1.$test1;
-create table test$1.test2$ (a int);
-drop table test$1.test2$;
-drop database  test$1;
-
-#
-# This failed for Elizabeth Mattijsen
-#
-
-CREATE TABLE t1 (
-  ID CHAR(32) NOT NULL,
-  name CHAR(32) NOT NULL,
-  value CHAR(255),
-  INDEX indexIDname (ID(8),name(8))
-) ;
-
-INSERT INTO t1 VALUES
-('keyword','indexdir','/export/home/local/www/database/indexes/keyword');
-INSERT INTO t1 VALUES ('keyword','urlprefix','text/ /text');
-INSERT INTO t1 VALUES ('keyword','urlmap','/text/ /');
-INSERT INTO t1 VALUES ('keyword','attr','personal employee company');
-INSERT INTO t1 VALUES
-('emailgids','indexdir','/export/home/local/www/database/indexes/emailgids');
-INSERT INTO t1 VALUES ('emailgids','urlprefix','text/ /text');
-INSERT INTO t1 VALUES ('emailgids','urlmap','/text/ /');
-INSERT INTO t1 VALUES ('emailgids','attr','personal employee company');
-
-SELECT value FROM t1 WHERE ID='emailgids' AND name='attr';
-
-drop table t1;
-
-#
-# problem with date conversions
-#
-
-CREATE TABLE t1 (name char(6),cdate date);
-INSERT INTO t1 VALUES ('name1','1998-01-01');
-INSERT INTO t1 VALUES ('name2','1998-01-01');
-INSERT INTO t1 VALUES ('name1','1998-01-02');
-INSERT INTO t1 VALUES ('name2','1998-01-02');
-CREATE TABLE t2 (cdate date, note char(6));
-INSERT INTO t2 VALUES ('1998-01-01','note01');
-INSERT INTO t2 VALUES ('1998-01-02','note02');
-select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01';
-drop table t1,t2;
-
-#
-# Date and BETWEEN
-#
-
-CREATE TABLE t1 ( datum DATE );
-INSERT INTO t1 VALUES ( "2000-1-1" );
-INSERT INTO t1 VALUES ( "2000-1-2" );
-INSERT INTO t1 VALUES ( "2000-1-3" );
-INSERT INTO t1 VALUES ( "2000-1-4" );
-INSERT INTO t1 VALUES ( "2000-1-5" );
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
-DROP TABLE t1;
-
-#
-# test of primary key conversions
-#
-
-create table t1 (t1 char(3) primary key);
-insert into t1 values("ABC");
-insert into t1 values("ABA");
-insert into t1 values("AB%");
-select * from t1 where t1="ABC";
-select * from t1 where t1="ABCD";
-select * from t1 where t1 like "a_\%";
-describe select * from t1 where t1="ABC";
-describe select * from t1 where t1="ABCD";
-drop table t1;
-
-#
-# Test of like
-#
-
-create table t1 (a varchar(10), key(a));
-insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
-select * from t1 where a like "abc%"; 
-select * from t1 where a like "test%"; 
-select * from t1 where a like "te_t"; 
-drop table t1;
-
-#
-# test of max(date) and having
-#
-
-CREATE TABLE t1 (
-  user_id char(10),
-  summa int(11),
-  rdate date
-);
-INSERT INTO t1 VALUES ('aaa',100,'1998-01-01');
-INSERT INTO t1 VALUES ('aaa',200,'1998-01-03');
-INSERT INTO t1 VALUES ('bbb',50,'1998-01-02');
-INSERT INTO t1 VALUES ('bbb',200,'1998-01-04');
-select max(rdate) as s from t1 where rdate < '1998-01-03' having s> "1998-01-01";
-select max(rdate) as s from t1 having s="1998-01-04";
-select max(rdate+0) as s from t1 having s="19980104";
-drop table t1;
-
-#
-# Test of group (Failed for Lars Hoss <lh@pbm.de>)
-#
-
-CREATE TABLE t1 (
-  spID int(10) unsigned,
-  userID int(10) unsigned,
-  score smallint(5) unsigned,
-  lsg char(40),
-  date date
-);
-
-INSERT INTO t1 VALUES (1,1,1,'','0000-00-00');
-INSERT INTO t1 VALUES (2,2,2,'','0000-00-00');
-INSERT INTO t1 VALUES (2,1,1,'','0000-00-00');
-INSERT INTO t1 VALUES (3,3,3,'','0000-00-00');
-
-CREATE TABLE t2 (
-  userID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
-  niName char(15),
-  passwd char(8),
-  mail char(50),
-  isAukt enum('N','Y') DEFAULT 'N',
-  vName char(30),
-  nName char(40),
-  adr char(60),
-  plz char(5),
-  ort char(35),
-  land char(20),
-  PRIMARY KEY (userID)
-);
-
-INSERT INTO t2 VALUES (1,'name','pass','mail','Y','v','n','adr','1','1','1');
-INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1');
-INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1');
-
-SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid;
-SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2  GROUP BY t2.userid;
-SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2  GROUP BY t2.userid;
-
-drop table test.t1,test.t2;
-
-#
-# Test of LEFT JOIN with const tables (failed for frankie@etsetb.upc.es)
-#
-
-CREATE TABLE t1 (
-  cod_asig int(11) DEFAULT '0' NOT NULL,
-  desc_larga_cat varchar(80) DEFAULT '' NOT NULL,
-  desc_larga_cas varchar(80) DEFAULT '' NOT NULL,
-  desc_corta_cat varchar(40) DEFAULT '' NOT NULL,
-  desc_corta_cas varchar(40) DEFAULT '' NOT NULL,
-  cred_total double(3,1) DEFAULT '0.0' NOT NULL,
-  pre_requisit int(11),
-  co_requisit int(11),
-  preco_requisit int(11),
-  PRIMARY KEY (cod_asig)
-);
-
-INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los  Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','C�lculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL);
-
-CREATE TABLE t2 (
-  idAssignatura int(11) DEFAULT '0' NOT NULL,
-  Grup int(11) DEFAULT '0' NOT NULL,
-  Places smallint(6) DEFAULT '0' NOT NULL,
-  PlacesOcupades int(11) DEFAULT '0',
-  PRIMARY KEY (idAssignatura,Grup)
-);
-
-
-INSERT INTO t2 VALUES (10360,12,333,0);
-INSERT INTO t2 VALUES (10361,30,2,0);
-INSERT INTO t2 VALUES (10361,40,3,0);
-INSERT INTO t2 VALUES (10360,45,10,0);
-INSERT INTO t2 VALUES (10362,10,12,0);
-INSERT INTO t2 VALUES (10360,55,2,0);
-INSERT INTO t2 VALUES (10360,70,0,0);
-INSERT INTO t2 VALUES (10360,565656,0,0);
-INSERT INTO t2 VALUES (10360,32767,7,0);
-INSERT INTO t2 VALUES (10360,33,8,0);
-INSERT INTO t2 VALUES (10360,7887,85,0);
-INSERT INTO t2 VALUES (11405,88,8,0);
-INSERT INTO t2 VALUES (10360,0,55,0);
-INSERT INTO t2 VALUES (10360,99,0,0);
-INSERT INTO t2 VALUES (11411,30,10,0);
-INSERT INTO t2 VALUES (11404,0,0,0);
-INSERT INTO t2 VALUES (10362,11,111,0);
-INSERT INTO t2 VALUES (10363,33,333,0);
-INSERT INTO t2 VALUES (11412,55,0,0);
-INSERT INTO t2 VALUES (50003,66,6,0);
-INSERT INTO t2 VALUES (11403,5,0,0);
-INSERT INTO t2 VALUES (11406,11,11,0);
-INSERT INTO t2 VALUES (11410,11410,131,0);
-INSERT INTO t2 VALUES (11416,11416,32767,0);
-INSERT INTO t2 VALUES (11409,0,0,0);
-
-CREATE TABLE t3 (
-  id int(11) DEFAULT '0' NOT NULL auto_increment,
-  dni_pasaporte char(16) DEFAULT '' NOT NULL,
-  idPla int(11) DEFAULT '0' NOT NULL,
-  cod_asig int(11) DEFAULT '0' NOT NULL,
-  any smallint(6) DEFAULT '0' NOT NULL,
-  quatrimestre smallint(6) DEFAULT '0' NOT NULL,
-  estat char(1) DEFAULT 'M' NOT NULL,
-  PRIMARY KEY (id),
-  UNIQUE dni_pasaporte (dni_pasaporte,idPla),
-  UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre)
-);
-
-INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M');
-
-CREATE TABLE t4 (
-  id int(11) DEFAULT '0' NOT NULL auto_increment,
-  papa int(11) DEFAULT '0' NOT NULL,
-  fill int(11) DEFAULT '0' NOT NULL,
-  idPla int(11) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (id),
-  KEY papa (idPla,papa),
-  UNIQUE papa_2 (idPla,papa,fill)
-);
-
-INSERT INTO t4 VALUES (1,-1,10360,1);
-INSERT INTO t4 VALUES (2,-1,10361,1);
-INSERT INTO t4 VALUES (3,-1,10362,1);
-
-SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S'   AND dni_pasaporte='11111111'   AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig   AND Places>PlacesOcupades   AND fill=idAssignatura   AND t4.idPla=1   AND papa=-1;
-
-SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ;
-
-INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S');
-SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ;
-
-drop table t1,t2,t3,test.t4;
-
-#
-# Bug in GROUP BY, by Nikki Chumakov <nikki@saddam.cityline.ru>
-
-CREATE TABLE t1 (
-  PID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
-  payDate date DEFAULT '0000-00-00' NOT NULL,
-  recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
-  URID int(10) unsigned DEFAULT '0' NOT NULL,
-  CRID int(10) unsigned DEFAULT '0' NOT NULL,
-  amount int(10) unsigned DEFAULT '0' NOT NULL,
-  operator int(10) unsigned,
-  method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL,
-  DIID int(10) unsigned,
-  reason char(1) binary DEFAULT '' NOT NULL,
-  code_id int(10) unsigned,
-  qty mediumint(8) unsigned DEFAULT '0' NOT NULL,
-  PRIMARY KEY (PID),
-  KEY URID (URID),
-  KEY reason (reason),
-  KEY method (method),
-  KEY payDate (payDate)
-);
-
-INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
-
-SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000   AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
-
-drop table t1;
-
-# Another SUM() problem with 3.23.2
-
-create table t1 (
-        num float(5,2),
-        user char(20)
-);
-insert into t1 values (10.3,'nem'),(20.53,'monty'),(30.23,'sinisa');
-insert into t1 values (30.13,'nem'),(20.98,'monty'),(10.45,'sinisa');
-insert into t1 values (5.2,'nem'),(8.64,'monty'),(11.12,'sinisa');
-select sum(num) from t1;
-select sum(num) from t1 group by user;
-drop table t1;
-
-#
-# Problem with GROUP BY + ORDER BY when no match
-# Tested with locking
-#
-
-CREATE TABLE t1 (
-  cid mediumint(9) DEFAULT '0' NOT NULL auto_increment,
-  firstname varchar(32) DEFAULT '' NOT NULL,
-  surname varchar(32) DEFAULT '' NOT NULL,
-  PRIMARY KEY (cid)
-);
-INSERT INTO t1 VALUES (1,'That','Guy');
-INSERT INTO t1 VALUES (2,'Another','Gent');
-
-CREATE TABLE t2 (
-  call_id mediumint(8) DEFAULT '0' NOT NULL auto_increment,
-  contact_id mediumint(8) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (call_id),
-  KEY contact_id (contact_id)
-);
-
-lock tables t1 read,t2 write;
-
-INSERT INTO t2 VALUES (10,2);
-INSERT INTO t2 VALUES (18,2);
-INSERT INTO t2 VALUES (62,2);
-INSERT INTO t2 VALUES (91,2);
-INSERT INTO t2 VALUES (92,2);
-
-SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid;
-SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
-
-drop table t1,t2;
-unlock tables;
-
-#
-# Test of locking and delete of files
-#
-
-CREATE TABLE t1 (a int);
-CREATE TABLE t2 (a int);
-lock tables t1 write,t1 as b write, t2 write, t2 as c read;
-drop table t1;
-drop table t2;
-
-CREATE TABLE t1 (a int);
-CREATE TABLE t2 (a int);
-lock tables t1 write,t1 as b write, t2 write, t2 as c read;
-drop table t2;
-drop table t1;
-unlock tables;
-
-#
-# Order by on first index part
-#
-
-create table t1 (id int not null,col1 int not null,col2 int not null,index(col1));
-insert into t1 values(1,2,2),(2,2,1),(3,1,2),(4,1,1),(5,1,4),(6,2,3),(7,3,1),(8,2,4);
-select * from t1 order by col1,col2;
-select col1 from t1 order by id;
-select col1 as id from t1 order by t1.id;
-select concat(col1) as id from t1 order by t1.id;
-drop table t1;
-
-#
-# Problem with many key parts and many or
-#
-
-CREATE TABLE t1 (
-  price int(5) DEFAULT '0' NOT NULL,
-  area varchar(40) DEFAULT '' NOT NULL,
-  type varchar(40) DEFAULT '' NOT NULL,
-  transityes enum('Y','N') DEFAULT 'Y' NOT NULL,
-  shopsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
-  schoolsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
-  petsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
-  KEY price (price,area,type,transityes,shopsyes,schoolsyes,petsyes)
-);
-
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','','');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-
- SELECT * FROM t1 WHERE area='Vancouver' and transityes='y' and schoolsyes='y' and ( ((type='1 Bedroom' or type='Studio/Bach') and (price<=500)) or ((type='2 Bedroom') and (price<=550)) or ((type='Shared/Roomate') and (price<=300)) or ((type='Room and Board') and (price<=500)) ) and price <= 400;
-
-drop table t1;
-
-#
-# Problem with distinct without results
-#
-CREATE TABLE t1 (UserId int(11) DEFAULT '0' NOT NULL);
-INSERT INTO t1 VALUES (20);
-INSERT INTO t1 VALUES (27);
-
-SELECT UserId FROM t1 WHERE Userid=22;
-SELECT UserId FROM t1 WHERE UserId=22 group by Userid;
-SELECT DISTINCT UserId FROM t1 WHERE UserId=22 group by Userid;
-SELECT DISTINCT UserId FROM t1 WHERE UserId=22;
-drop table t1;
-
-#
-# Check for problems with delete
-#
-
-CREATE TABLE t1 (a tinyint(3), b tinyint(5));
-INSERT INTO t1 VALUES (1,1);
-INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
-INSERT INTO t1 VALUES (1,3);
-DELETE from t1 where a=1 limit 1;
-DELETE LOW_PRIORITY from t1 where a=1;
-
-INSERT INTO t1 VALUES (1,1);
-DELETE from t1;
-LOCK TABLE t1 write;
-INSERT INTO t1 VALUES (1,2);
-DELETE from t1;
-UNLOCK TABLES;
-INSERT INTO t1 VALUES (1,2);
-SET AUTOCOMMIT=0;
-DELETE from t1;
-SET AUTOCOMMIT=1;
-drop table t1;
-
-create table t1 (s1 char(64),s2 char(64));
-
-insert into t1 values('aaa','aaa');
-insert into t1 values('aaa|qqq','qqq');
-insert into t1 values('gheis','^[^a-dXYZ]+$');
-insert into t1 values('aab','^aa?b');
-insert into t1 values('Baaan','^Ba*n');
-insert into t1 values('aaa','qqq|aaa');
-insert into t1 values('qqq','qqq|aaa');
-
-insert into t1 values('bbb','qqq|aaa');
-insert into t1 values('bbb','qqq');
-insert into t1 values('aaa','aba');
-
-insert into t1 values(null,'abc');
-insert into t1 values('def',null);
-insert into t1 values(null,null);
-insert into t1 values('ghi','ghi[');
-
-select HIGH_PRIORITY s1 regexp s2 from t1;
-
-drop table t1;
-
-#
-# Test retreiving row with last insert_id value.
-#
-
-create table t1 (a int not null auto_increment,b int not null,primary key (a,b));
-insert into t1 SET A=NULL,B=1;
-insert into t1 SET a=null,b=2;
-select * from t1 where a is null and b=2;
-select * from t1 where a is null;
-explain select * from t1 where b is null;
-drop table t1;
-
-#
-# Test of IS NULL on AUTO_INCREMENT with LEFT JOIN
-#
-
-CREATE TABLE t1 (
-  id smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment,
-  name char(60) DEFAULT '' NOT NULL,
-  PRIMARY KEY (id)
-);
-INSERT INTO t1 VALUES (1,'Antonio Paz');
-INSERT INTO t1 VALUES (2,'Lilliana Angelovska');
-INSERT INTO t1 VALUES (3,'Thimble Smith');
-
-CREATE TABLE t2 (
-  id smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment,
-  owner smallint(5) unsigned DEFAULT '0' NOT NULL,
-  name char(60),
-  PRIMARY KEY (id)
-);
-INSERT INTO t2 VALUES (1,1,'El Gato');
-INSERT INTO t2 VALUES (2,1,'Perrito');
-INSERT INTO t2 VALUES (3,3,'Happy');
-
-select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner);
-select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
-select count(*) from t1 left join t2 on (t1.id = t2.owner);
-
-select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner);
-select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
-select count(*) from t2 right join t1 on (t1.id = t2.owner);
-
-select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner;
-select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
-select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
-
-drop table t1,t2;
-
-create table t1 (id int not null, str char(10), index(str));
-insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar");
-select * from t1 where str is not null;
-select * from t1 where str is null;
-drop table t1;
-
-#
-# Test wrong LEFT JOIN query
-#
-
-CREATE TABLE t1 (
-  t1_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  PRIMARY KEY (t1_id)
-);
-CREATE TABLE t2 (
-  t2_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  PRIMARY KEY (t2_id)
-);
-CREATE TABLE t3 (
-  t3_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  PRIMARY KEY (t3_id)
-);
-CREATE TABLE t4 (
-  seq_0_id bigint(21) DEFAULT '0' NOT NULL,
-  seq_1_id bigint(21) DEFAULT '0' NOT NULL,
-  KEY seq_0_id (seq_0_id),
-  KEY seq_1_id (seq_1_id)
-);
-CREATE TABLE t5 (
-  seq_0_id bigint(21) DEFAULT '0' NOT NULL,
-  seq_1_id bigint(21) DEFAULT '0' NOT NULL,
-  KEY seq_1_id (seq_1_id),
-  KEY seq_0_id (seq_0_id)
-);
-
-insert into t1 values (1);
-insert into t2 values (1);
-insert into t3 values (1);
-insert into t4 values (1,1);
-insert into t5 values (1,1);
-
-explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
-
-drop table t1,t2,t3,t4,t5;
-
-# Test bug with NATURAL join:
-
-CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT);   
-INSERT INTO t1 VALUES (1,'a',1);
-INSERT INTO t1 VALUES (2,'b',1);
-INSERT INTO t1 VALUES (3,'c',2);
-
-CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1));   
-INSERT INTO t2 VALUES (1,'x');
-INSERT INTO t2 VALUES (2,'y');
-INSERT INTO t2 VALUES (3,'z');
-
-SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL;
-SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
-
-drop table t1,t2;
-
-#
-# Test of order by on field()
-#
-
-CREATE TABLE t1 (id int auto_increment primary key,aika varchar(40),aikakentta  timestamp);
-insert into t1 (aika) values ('Keskiviikko');
-insert into t1 (aika) values ('Tiistai');
-insert into t1 (aika) values ('Maanantai');
-insert into t1 (aika) values ('Sunnuntai');
-
-SELECT FIELD(SUBSTRING(t1.aika,1,2),'Ma','Ti','Ke','To','Pe','La','Su') AS test FROM t1 ORDER by test;
-drop table t1;
-
-#
-# Test of ORDER BY on IF
-#
-
-CREATE TABLE t1
-(
-  a          int unsigned       NOT NULL,
-  b          int unsigned       NOT NULL,
-  c          int unsigned       NOT NULL,
-  UNIQUE(a),
-  INDEX(b),
-  INDEX(c)
-);
-
-CREATE TABLE t2
-(
-  c          int unsigned       NOT NULL,
-  i          int unsigned       NOT NULL,
-  INDEX(c)
-);
-
-CREATE TABLE t3
-(
-  c          int unsigned       NOT NULL,
-  v          varchar(64),
-  INDEX(c)
-);
-
-INSERT INTO t1 VALUES (1,1,1);
-INSERT INTO t1 VALUES (2,1,2);
-INSERT INTO t1 VALUES (3,2,1);
-INSERT INTO t1 VALUES (4,2,2);
-INSERT INTO t2 VALUES (1,50);
-INSERT INTO t2 VALUES (2,25);
-INSERT INTO t3 VALUES (1,'123 Park Place');
-INSERT INTO t3 VALUES (2,'453 Boardwalk');
-
-SELECT    a,b,if(b = 1,i,if(b = 2,v,''))
-FROM      t1
-LEFT JOIN t2 USING(c)
-LEFT JOIN t3 ON t3.c = t1.c;
-
-SELECT    a,b,if(b = 1,i,if(b = 2,v,''))
-FROM      t1
-LEFT JOIN t2 USING(c)
-LEFT JOIN t3 ON t3.c = t1.c
-ORDER BY a;
-
-drop table t1,t2,t3;
-
-#
-# test of IN (NULL)
-#
-
-CREATE TABLE t1 (field char(1));
-INSERT INTO t1 VALUES ('A'),(NULL);
-SELECT * from t1 WHERE field IN (NULL);
-SELECT * from t1 WHERE field NOT IN (NULL);
-SELECT * from t1 where field = field;
-SELECT * from t1 where field <=> field;
-DELETE FROM t1 WHERE field NOT IN (NULL);
-SELECT * FROM t1;
-drop table t1;
-
-#
-# Test insert of now() and curtime()
-#
-
-CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
-insert into t1 (b,c,d) values(now(),curtime(),now());
-select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1;
-drop table t1;
-
-#
-# Test of binary and normal strings
-#
-
-create table t1 (a char(10) not null, b char(10) binary not null,index (a));
-insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
-select * from t1 where a="hello ";
-select * from t1 where b="hello ";
-select * from t1 where b="hello";
-drop table t1;
-
-#
-# Test some warnings
-#
-
-create table t1 (a int);
-insert into t1 values (1);
-insert into t1 values ("hej");
-insert into t1 values ("hej"),("d�");
-set SQL_WARNINGS=1;
-insert into t1 values ("hej");
-insert into t1 values ("hej"),("d�");
-drop table t1;
-set SQL_WARNINGS=0;
-
-#
-# Test of join with blobs and min
-#
-
-CREATE TABLE t1 (
-  t1_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  _field_72 varchar(128) DEFAULT '' NOT NULL,
-  _field_95 varchar(32),
-  _field_115 tinyint(4) DEFAULT '0' NOT NULL,
-  _field_122 tinyint(4) DEFAULT '0' NOT NULL,
-  _field_126 tinyint(4),
-  _field_134 tinyint(4),
-  PRIMARY KEY (t1_id),
-  UNIQUE _field_72 (_field_72),
-  KEY _field_115 (_field_115),
-  KEY _field_122 (_field_122)
-);
-
-
-INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
-INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
-INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
-
-
-CREATE TABLE t2 (
-  seq_0_id bigint(21) DEFAULT '0' NOT NULL,
-  seq_1_id bigint(21) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (seq_0_id,seq_1_id)
-);
-
-
-INSERT INTO t2 VALUES (1,1);
-INSERT INTO t2 VALUES (2,1);
-INSERT INTO t2 VALUES (2,2);
-
-CREATE TABLE t3 (
-  t3_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  _field_131 varchar(128),
-  _field_133 tinyint(4) DEFAULT '0' NOT NULL,
-  _field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
-  _field_137 tinyint(4),
-  _field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
-  _field_140 blob,
-  _field_142 tinyint(4) DEFAULT '0' NOT NULL,
-  _field_145 tinyint(4) DEFAULT '0' NOT NULL,
-  _field_148 tinyint(4) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (t3_id),
-  KEY _field_133 (_field_133),
-  KEY _field_135 (_field_135),
-  KEY _field_139 (_field_139),
-  KEY _field_142 (_field_142),
-  KEY _field_145 (_field_145),
-  KEY _field_148 (_field_148)
-);
-
-
-INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
-INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
-
-
-CREATE TABLE t4 (
-  seq_0_id bigint(21) DEFAULT '0' NOT NULL,
-  seq_1_id bigint(21) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (seq_0_id,seq_1_id)
-);
-
-
-INSERT INTO t4 VALUES (1,1);
-INSERT INTO t4 VALUES (2,1);
-
-CREATE TABLE t5 (
-  t5_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  _field_149 tinyint(4),
-  _field_156 varchar(128) DEFAULT '' NOT NULL,
-  _field_157 varchar(128) DEFAULT '' NOT NULL,
-  _field_158 varchar(128) DEFAULT '' NOT NULL,
-  _field_159 varchar(128) DEFAULT '' NOT NULL,
-  _field_160 varchar(128) DEFAULT '' NOT NULL,
-  _field_161 varchar(128) DEFAULT '' NOT NULL,
-  PRIMARY KEY (t5_id),
-  KEY _field_156 (_field_156),
-  KEY _field_157 (_field_157),
-  KEY _field_158 (_field_158),
-  KEY _field_159 (_field_159),
-  KEY _field_160 (_field_160),
-  KEY _field_161 (_field_161)
-);
-
-
-INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
-INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
-
-CREATE TABLE t6 (
-  seq_0_id bigint(21) DEFAULT '0' NOT NULL,
-  seq_1_id bigint(21) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (seq_0_id,seq_1_id)
-);
-
-INSERT INTO t6 VALUES (1,1);
-INSERT INTO t6 VALUES (1,2);
-INSERT INTO t6 VALUES (2,2);
-
-CREATE TABLE t7 (
-  t7_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
-  _field_143 tinyint(4),
-  _field_165 varchar(32),
-  _field_166 smallint(6) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (t7_id),
-  KEY _field_166 (_field_166)
-);
-
-
-INSERT INTO t7 VALUES (1,0,'High',1);
-INSERT INTO t7 VALUES (2,0,'Medium',2);
-INSERT INTO t7 VALUES (3,0,'Low',3);
-
-select t3._field_140,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), min(t3._field_140), t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
-
-drop table t1,t2,t3,t4,t5,t6,t7;
-
-#
-# Test of timestamp and blobs
-
-CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp, PRIMARY KEY (id));
-INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00");
-SELECT stamp FROM t1 WHERE id="myKey";
-UPDATE t1 SET value="my value" WHERE id="myKey";
-SELECT stamp FROM t1 WHERE id="myKey";
-drop table t1;
-
-create table t1 (a timestamp);
-insert into t1 values (now());
-select date_format(a,"%Y %y"),year(a),year(now()) from t1;
-drop table t1;
-
-create table t1 (ix timestamp);
-insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
-select * from t1; 
-drop table t1;
-
-CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
-INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959);
-INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000);
-INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959);
-INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000);
-INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000);
-INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000);
-INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000);
-INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959);
-INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000);
-INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959);
-INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000);
-INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
-INSERT INTO t1 VALUES ("2050-01-01","2050-01-01 00:00:00",20500101000000);
-SELECT * FROM t1;
-drop table t1;
-
-#
-# test of DELAYED insert and timestamps
-# (Can't be tested with purify :( )
-#
-
-#create table t1 (a char(10), tmsp timestamp);
-#insert into t1 set a = 1;
-#insert delayed into t1 set a = 2;
-#insert into t1 set a = 3, tmsp=NULL;
-#insert delayed into t1 set a = 4;
-#insert delayed into t1 set a = 5, tmsp = 19711006010203;
-#insert delayed into t1 (a, tmsp) values (6, 19711006010203);
-#insert delayed into t1 (a, tmsp) values (7, NULL);
-#insert into t1 set a = 8,tmsp=19711006010203;
-#select * from t1 where tmsp=0;
-#select * from t1 where tmsp=19711006010203;
-#drop table t1;
-
-#
-# Test of date and not null
-#
-
-CREATE TABLE t1 (a datetime not null);
-insert into t1 values (0);
-select * from t1 where a is null;
-drop table t1;
-
-create table t1 (id int not null, str char(10), unique(str));
-insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
-select * from t1 where str is null;
-select * from t1 where str="foo";
-explain select * from t1 where str is null;
-explain select * from t1 where str="foo";
-explain select * from t1 ignore key (str) where str="foo";
-explain select * from t1 use key (str,str) where str="foo";
-
-#The following should give errors
-explain select * from t1 use key (str,str,foo) where str="foo";
-explain select * from t1 ignore key (str,str,foo) where str="foo";
-drop table t1;
-
-#
-# Test of bug in COUNT(i)*(i+0)
-#
-
-CREATE TABLE t1 (d DATETIME, i INT);
-INSERT INTO t1 VALUES (NOW(), 1);
-SELECT COUNT(i), i, COUNT(i)*i FROM t1 GROUP BY i;
-SELECT COUNT(i), (i+0), COUNT(i)*(i+0) FROM t1 GROUP BY i; 
-DROP TABLE t1;
-
-#
-# Test if time type
-#
-create table t1 (t time);
-insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
-select * from t1;
-drop table t1;
-
-#
-# Problem med concat
-#
-
-create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null, Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
-insert into t1 values ("09:26:00",16,9,1998);
-insert into t1 values ("09:26:00",16,9,1998);
-SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
-   UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
-FROM t1;
-drop table t1;
-
-create table t1 ( domain char(50) );
-insert into t1 VALUES ("hello.de" ), ("test.de" );
-select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de';
-select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
-drop table t1;
-
-#
-# Problem med range optimizer
-#
-
-CREATE TABLE t1 (
-  event_date date DEFAULT '0000-00-00' NOT NULL,
-  type int(11) DEFAULT '0' NOT NULL,
-  event_id int(11) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (event_date,type,event_id)
-);
-
-INSERT INTO t1 VALUES ('1999-07-10',100100,24),('1999-07-11',100100,25),('1999-07-13',100600,0),('1999-07-13',100600,4),('1999-07-13',100600,26),('1999-07-14',100600,10),('1999-07-15',100600,16),('1999-07-15',100800,45),('1999-07-15',101000,47),('1999-07-16',100800,46),('1999-07-20',100600,5),('1999-07-20',100600,27),('1999-07-21',100600,11),('1999-07-22',100600,17),('1999-07-23',100100,39),('1999-07-24',100100,39),('1999-07-24',100500,40),('1999-07-25',100100,39),('1999-07-27',100600,1),('1999-07-27',100600,6),('1999-07-27',100600,28),('1999-07-28',100600,12),('1999-07-29',100500,41),('1999-07-29',100600,18),('1999-07-30',100500,41),('1999-07-31',100500,41),('1999-08-01',100700,34),('1999-08-03',100600,7),('1999-08-03',100600,29),('1999-08-04',100600,13),('1999-08-05',100500,42),('1999-08-05',100600,19),('1999-08-06',100500,42),('1999-08-07',100500,42),('1999-08-08',100500,42),('1999-08-10',100600,2),('1999-08-10',100600,9),('1999-08-10',100600,30),('1999-08-11',100600,14),('1999-08-12',100600,20),('1999-08-17',100500,8),('1999-08-17',100600,31),('1999-08-18',100600,15),('1999-08-19',100600,22),('1999-08-24',100600,3),('1999-08-24',100600,32),('1999-08-27',100500,43),('1999-08-31',100600,33),('1999-09-17',100100,37),('1999-09-18',100100,37),('1999-09-19',100100,37),('2000-12-18',100700,38);
-
-select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
-explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
-select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
-drop table t1;
-
-CREATE TABLE t1 (
-  PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
-  YEAR smallint(6) DEFAULT '0' NOT NULL,
-  ISSUE smallint(6) DEFAULT '0' NOT NULL,
-  CLOSED tinyint(4) DEFAULT '0' NOT NULL,
-  ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
-  PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
-);
-INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12');
-INSERT INTO t1 VALUES (1,1999,111,0,'1999-03-23');
-INSERT INTO t1 VALUES (1,1999,222,0,'1999-03-23');
-INSERT INTO t1 VALUES (3,1999,33,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,32,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,31,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,30,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,29,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,28,0,'1999-07-12');
-INSERT INTO t1 VALUES (1,1999,40,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,41,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,42,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,46,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,47,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,48,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,49,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,50,0,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,51,0,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,200,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,52,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,53,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,54,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,55,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,56,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,57,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,58,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,59,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,60,0,'1999-07-01');
-INSERT INTO t1 VALUES (3,1999,35,0,'1999-07-12');
-select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28))  order by YEAR,ISSUE;
-check table t1;
-repair table t1;
-drop table t1;
-
-CREATE TABLE t1 (
-  id int(11) NOT NULL auto_increment,
-  parent_id int(11) DEFAULT '0' NOT NULL,
-  level tinyint(4) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (id),
-  KEY parent_id (parent_id),
-  KEY level (level)
-);
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
-SELECT * FROM t1 WHERE level = 1 AND parent_id = 1;
-# The following select returned 0 rows in 3.23.8
-SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id;
-drop table t1;
-
-#
-# Testing of bug in range optimizer with many key parts and > and <
-#
-
-create table t1(
-		Satellite		varchar(25)	not null,
-		SensorMode		varchar(25)	not null,
-		FullImageCornersUpperLeftLongitude	double	not null,
-		FullImageCornersUpperRightLongitude	double	not null,
-		FullImageCornersUpperRightLatitude	double	not null,
-		FullImageCornersLowerRightLatitude	double	not null,
-	        index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude));
-
-insert into t1 values("OV-3","PAN1",91,-92,40,50);
-insert into t1 values("OV-4","PAN1",91,-92,40,50);
-
-select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000;
-drop table t1;
-
-create table t1 ( aString char(100) not null default "", key aString (aString(10)) );
-insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love");
-select * from t1 where aString < "believe in myself" order by aString;
-select * from t1 where aString > "believe in love" order by aString;
-alter table t1 drop key aString;
-select * from t1 where aString < "believe in myself" order by aString;
-select * from t1 where aString > "believe in love" order by aString;
-drop table t1;
-
-#
-# problem med primary key
-#
-
-CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  sites set('mt'),  PRIMARY KEY (program));
-# The following should give an error for wrong primary key
-ALTER TABLE t1 modify program enum('signup','unique','sliding');
-drop table t1;
-
-#
-# Test year
-#
-
-create table t1 (y year,y2 year(2));
-insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69);
-select * from t1;
-select * from t1 order by y;
-select * from t1 order by y2;
-drop table t1;
-
-#
-# Test of distinct
-#
-
-CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned);
-INSERT INTO t1 VALUES (1,1),(2,1);
-CREATE TABLE t2 (a int(10) unsigned not null, key (A));
-INSERT INTO t2 VALUES (1),(2);
-CREATE TABLE t3 (a int(10) unsigned, key(A), b text);
-INSERT INTO t3 VALUES (1,'1'),(2,'2');
-SELECT DISTINCT t3.b FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-INSERT INTO t2 values (1),(2),(3);
-INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
-explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-
-# Create a lot of data into t3;
-create temporary table t4 select * from t3;
-insert into t3 select * from t4;
-insert into t4 select * from t3;
-insert into t3 select * from t4;
-insert into t4 select * from t3;
-insert into t3 select * from t4;
-insert into t4 select * from t3;
-insert into t3 select * from t4;
-
-explain select distinct t1.a from t1,t3 where t1.a=t3.a;
-flush status;
-select distinct t1.a from t1,t3 where t1.a=t3.a;
-show status like 'Handler%';
-flush status;
-select distinct 1 from t1,t3 where t1.a=t3.a;
-show status like 'Handler%';
-drop table t1,t2,t3,t4;
-
-#
-# test of unsigned int
-#
-
-create table t1 (this int unsigned);
-insert into t1 values (1);
-select * from t1;
-drop table t1;
-
-#
-# Test of reverse with empty blob
-#
-
-create table t1 (a blob);
-insert into t1 values ("empty"),("");
-select a,reverse(a) from t1;
-drop table t1;
-
-#
-# Test of heap tables.
-#
-
-create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
-insert into t1 values(1,1),(2,2),(3,3),(4,4);
-delete from t1 where a=1 or a=0;
-show table status like "t1";
-show keys from t1;
-select * from t1;
-select * from t1 where a=4;
-update t1 set b=5 where a=4;
-update t1 set b=b+1 where a>=3;
-replace t1 values (3,3);
-select * from t1;
-alter table t1 add c int not null, add key (c,a);
-drop table t1;
-
-create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps";
-insert into t1 values(1,1),(2,2),(3,3),(4,4);
-alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
-show table status like "t1";
-select * from t1;
-drop table t1;
-
-create table t1 (a int not null) type=heap;
-insert into t1 values (869751),(736494),(226312),(802616);
-select * from t1 where a > 736494;
-alter table t1 add unique uniq_id(a);
-select * from t1 where a > 736494;
-select * from t1 where a = 736494;
-select * from t1 where a=869751 or a=736494;
-select * from t1 where a in (869751,736494,226312,802616);
-alter table t1 type=myisam;
-explain select * from t1 where a in (869751,736494,226312,802616);
-drop table t1;
-
-create table t1 (x int not null, y int not null, key x(x), unique y(y))
-type=heap;
-insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
-select * from t1 where x=1;
-select * from t1,t1 as t2 where t1.x=t2.y;
-explain select * from t1,t1 as t2 where t1.x=t2.y;
-drop table t1;
-
-create table t1 (a int) type=heap;
-insert into t1 values(1);
-select max(a) from t1;
-drop table t1;
-
-CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) TYPE=HEAP;
-insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
-select * from t1 where a=1; 
-insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
-select * from t1 where a=1;
-drop table t1;
-
-create table t1 (id int unsigned not null, primary key (id)) type=HEAP;
-insert into t1 values(1);
-select max(id) from t1; 
-insert into t1 values(2);
-select max(id) from t1; 
-replace into t1 values(1);
-drop table t1;
-
-create table t1 (n int) type=heap;
-drop table t1;
-
-create table t1 (n int) type=heap;
-drop table if exists t1;
-
-# Test of non unique index
-
-CREATE table t1(f1 int not null,f2 char(20) not 
-null,index(f2)) type=heap;
-INSERT into t1 set f1=12,f2="bill";
-INSERT into t1 set f1=13,f2="bill";
-INSERT into t1 set f1=14,f2="bill";
-INSERT into t1 set f1=15,f2="bill";
-INSERT into t1 set f1=16,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-delete from t1 where f2="bill";
-select * from t1;
-drop table t1;
-#
-# Test of auto_increment.
-#
-
-create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
-insert into t1 values (1,1),(NULL,3),(NULL,4);
-delete from t1 where a=4;
-insert into t1 values (NULL,5),(NULL,6);
-select * from t1;
-delete from t1 where a=6;
-show table status like "t1";
-replace t1 values (3,1);
-ALTER TABLE t1 add c int;
-replace t1 values (3,3,3);
-insert into t1 values (NULL,7,7);
-update t1 set a=8,b=b+1,c=c+1 where a=7;
-insert into t1 values (NULL,9,9);
-select * from t1;
-drop table t1;
-
-create table t1 (a int not null auto_increment,b int, primary key (a)) type=isam;
-insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
-delete from t1 where a=4 or a=2;
-insert into t1 values (NULL,4),(NULL,5),(6,6);
-select * from t1;
-delete from t1 where a=6;
-show table status like "t1";
-replace t1 values (3,1);
-replace t1 values (3,3);
-ALTER TABLE t1 add c int;
-insert into t1 values (NULL,6,6);
-select * from t1;
-drop table t1;
-
-create table t1 (
-  skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
-  sval char(20)
-);
-insert into t1 values (NULL, "hello");
-insert into t1 values (NULL, "hey");
-select * from t1;
-select _rowid,t1._rowid,skey,sval from t1;
-drop table t1;
-
-#
-# Test auto_increment on sub key
-#
-create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
-insert into t1 values ("a",1),("b",2),("a",2),("c",1);
-insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("d",NULL);
-insert into t1 (a) values ("a"),("b"),("c"),("d");
-insert into t1 (a) values ("a");
-insert into t1 values ("d",last_insert_id());
-select * from t1;
-drop table t1;
-
-create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ordid), index(ord,ordid)); 
-insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
-select * from t1;
-drop table t1;
-
-create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid));
-insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
-select * from t1;
-drop table t1;
-
-#
-# Test of some CREATE TABLE'S that should fail
-#
-
-create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) type=isam;
-create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) type=heap;
-create table t1 (ordid int(8), primary key (ordid));
-create table t1 (ordid int(8), unique (ordid)) type=isam;
-
-#
-# Test of temporary tables
-#
-CREATE TABLE t1 (c int not null, d char (10) not null);
-insert into t1 values(1,""),(2,"a"),(3,"b");
-CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
-insert into t1 values(4,"e"),(5,"f"),(6,"g");
-alter table t1 rename t2;
-select * from t1;
-select * from t2;
-CREATE TABLE t2 (x int not null, y int not null);
-alter table t2 rename t1;
-select * from t1;
-create TEMPORARY TABLE t2 type=heap select * from t1;
-
-# This should give errors
-CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
-ALTER TABLE t1 RENAME t2;
-
-select * from t2;
-alter table t2 add primary key (a,b);
-drop table t1,t2;
-select * from t1;
-drop table t2;
-create temporary table t1 select *,2 as "e" from t1;
-select * from t1;
-drop table t1;
-drop table t1;
-
-#
-# test of updating of keys
-#
-
-create table t1 (a int auto_increment , primary key (a));
-insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); 
-update t1 set a=a+10 where a > 34;
-update t1 set a=a+100 where a > 0;
-drop table t1;
-
-CREATE TABLE t1
- (
- place_id int (10) unsigned NOT NULL,
- shows int(10) unsigned DEFAULT '0' NOT NULL,
- ishows int(10) unsigned DEFAULT '0' NOT NULL,
- ushows int(10) unsigned DEFAULT '0' NOT NULL,
- clicks int(10) unsigned DEFAULT '0' NOT NULL,
- iclicks int(10) unsigned DEFAULT '0' NOT NULL,
- uclicks int(10) unsigned DEFAULT '0' NOT NULL,
- ts timestamp(14),
- PRIMARY KEY (place_id,ts)
- );
-
-INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts)
-VALUES (1,0,0,0,0,0,0,20000928174434);
-UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00";
-select place_id,shows from t1;
-drop table t1;
-
-#
-# Test of refering to old values
-#
-create table t1 (a int not null);
-insert into t1 values (1);
-insert into t1 values (a+2);
-insert into t1 values (a+3);
-insert into t1 values (4),(a+5);
-select * from t1;
-drop table t1;
-
-#
-# Test of LEFT JOIN + GROUP FUNCTIONS within functions:
-#
-
-CREATE TABLE t1 (
-  pcode varchar(8) DEFAULT '' NOT NULL
-);
-INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200');
-CREATE TABLE t2 (
-  pcode varchar(8) DEFAULT '' NOT NULL,
-  KEY pcode (pcode)
-);
-INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000');
-
-SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1
-LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode;
-SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode;
-drop table t1,t2;
-
-#
-# Another left join problem
-#
-
-CREATE TABLE t1 (
-  id int(11),
-  pid int(11),
-  rep_del tinyint(4),
-  KEY id (id),
-  KEY pid (pid)
-);
-INSERT INTO t1 VALUES (1,NULL,NULL);
-INSERT INTO t1 VALUES (2,1,NULL);
-select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL;
-create index rep_del ON t1(rep_del);
-select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL;
-drop table t1;
-
-CREATE TABLE t1 (
-  id int(11) DEFAULT '0' NOT NULL,
-  name tinytext DEFAULT '' NOT NULL,
-  UNIQUE id (id)
-);
-INSERT INTO t1 VALUES (1,'yes'),(2,'no');
-CREATE TABLE t2 (
-  id int(11) DEFAULT '0' NOT NULL,
-  idx int(11) DEFAULT '0' NOT NULL,
-  UNIQUE id (id,idx)
-);
-INSERT INTO t2 VALUES (1,1);
-explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
-SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
-drop table t1,t2;
-
-#
-# Test of update and delete with limit
-#
-create table t1 (a int primary key, b int not null);
-insert into t1 () values ();		-- Testing default values
-insert into t1 values (1,1),(2,1),(3,1);
-update t1 set a=4 where b=1 limit 1;
-select * from t1;
-update t1 set b=2 where b=1 limit 2;
-select * from t1;
-update t1 set b=4 where b=1;
-select * from t1;
-delete from t1 where b=2 limit 1;
-select * from t1;
-delete from t1 limit 1;
-select * from t1;
-drop table t1;
-
-#
-# Test of BLOB:s with NULL keys.
-#
-
-create table t1 (a blob, key (a(10)));
-insert into t1 values ("bye"),("hello"),("hello"),("hello word");
-select * from t1 where a like "hello%";
-drop table t1;
-
-#
-# Test of alter table
-#
-
-create table t1 (
-col1 int not null auto_increment primary key,
-col2 varchar(30) not null,
-col3 varchar (20) not null,
-col4 varchar(4) not null,
-col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
-col6 int not null);
-alter table t1
-add column col4_5 varchar(20) not null after col4,
-add column col7 varchar(30) not null after col6,
-add column col8 datetime not null;
-drop table t1;
-
-# Check that pack_keys and dynamic length rows are not forced. 
-
-CREATE TABLE t1 (
-GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
-LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
-NAME varchar(80) DEFAULT '' NOT NULL,
-PRIMARY KEY (GROUP_ID,LANG_ID),
-KEY NAME (NAME));
-show table status like "t1";
-ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
-SHOW COLUMNS FROM t1;
-DROP TABLE t1;
-
-#
-# Problem with INSERT ... SELECT
-#
-
-create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
-insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
-create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
-insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
-insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
-select * from t2;
-drop table t1,t2;
-
-#
-# problem with join
-#
-
-CREATE TABLE t1 (
-  id int(11) NOT NULL auto_increment,
-  token varchar(100) DEFAULT '' NOT NULL,
-  count int(11) DEFAULT '0' NOT NULL,
-  qty int(11),
-  phone char(1) DEFAULT '' NOT NULL,
-  timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
-  PRIMARY KEY (id),
-  KEY token (token(15)),
-  KEY timestamp (timestamp),
-  UNIQUE token_2 (token(75),count,phone)
-);
-
-INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');
-INSERT INTO t1 VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');
-INSERT INTO t1 VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');
-INSERT INTO t1 VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');
-INSERT INTO t1 VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');
-INSERT INTO t1 VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');
-INSERT INTO t1 VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');
-INSERT INTO t1 VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');
-INSERT INTO t1 VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');
-INSERT INTO t1 VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');
-INSERT INTO t1 VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');
-
-CREATE TABLE t2 (
-  id int(11) NOT NULL auto_increment,
-  category int(11) DEFAULT '0' NOT NULL,
-  county int(11) DEFAULT '0' NOT NULL,
-  state int(11) DEFAULT '0' NOT NULL,
-  phones int(11) DEFAULT '0' NOT NULL,
-  nophones int(11) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (id),
-  KEY category (category,county,state)
-);
-INSERT INTO t2 VALUES (3,2,11,12,5400,7800);
-INSERT INTO t2 VALUES (4,2,25,12,6500,11200);
-INSERT INTO t2 VALUES (5,1,37,6,10000,12000);
-
-select a.id, b.category as catid, b.state as stateid, b.county as
-countyid from t1 a, t2 b where (a.token =
-'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id);
-select a.id, b.category as catid, b.state as stateid, b.county as
-countyid from t1 a, t2 b where (a.token =
-'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id) order by a.id;
-
-drop table t1, t2;
-
-#
-# Test of join of many tables.
-
-create table t1 (a int primary key);
-insert into t1 values(1),(2);
-select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a);
-drop table t1;
-
-#
-# test of safe selects
-#
-SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
-create table t1 (a int primary key, b char(20));
-insert into t1 values(1,"test");
-SELECT SQL_BUFFER_RESULT * from t1;
-update t1 set b="a" where a=1;
-delete from t1 where a=1;
-insert into t1 values(1,"test"),(2,"test2");
-SELECT SQL_BUFFER_RESULT * from t1;
-update t1 set b="a" where a=1;
-select 1 from t1,t1 as t2,t1 as t3,t1 as t4;
-
-# The following should give errors:
-update t1 set b="a";
-update t1 set b="a" where b="test";
-delete from t1;
-delete from t1 where b="test";
-delete from t1 where a+0=1;
-select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
-
-# The following should be ok:
-update t1 set b="a" limit 1;
-update t1 set b="a" where b="b" limit 2; 
-delete from t1 where b="test" limit 1;
-delete from t1 where a+0=1 limit 2;
-drop table t1;
-
-SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
-
-# Test of raided tables
-
-DROP TABLE IF EXISTS raidtest;
-DROP TABLE IF EXISTS raidnew;
-CREATE TABLE raidtest (
-id int unsigned not null auto_increment primary key,
-c char(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123;
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from raidtest;
-ALTER TABLE raidtest ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE raidtest ADD KEY c (c);
-ALTER TABLE raidtest DROP KEY c;
-ALTER TABLE raidtest DROP COLUMN x;
-ALTER TABLE raidtest RENAME raidnew;
-select count(*) from raidnew;
-DROP TABLE raidnew;
-/* variable rows */
-DROP TABLE IF EXISTS raidnew;
-CREATE TABLE raidtest (
-id int unsigned not null auto_increment primary key,
-c varchar(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121;
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES 
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from raidtest;
-ALTER TABLE raidtest ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE raidtest ADD KEY c (c);
-ALTER TABLE raidtest DROP KEY c;
-ALTER TABLE raidtest DROP COLUMN x;
-ALTER TABLE raidtest RENAME raidnew;
-ALTER TABLE raidnew CHANGE COLUMN c c VARCHAR(251) NOT NULL;
-select count(*) from raidnew;
-DROP TABLE raidnew;
-
-#
-# Problem with count(distinct)
-#
-
-create table t1 (libname varchar(21) not null, city text, primary key (libname));
-create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
-create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
-insert into t2 values ('001','Daffy','A duck''s life');
-insert into t2 values ('002','Bugs','A rabbit\'s life');
-insert into t2 values ('003','Cowboy','Life on the range');
-insert into t2 values ('000','Anonymous','Wanna buy this book?');
-insert into t2 values ('004','Best Seller','One Heckuva book');
-insert into t2 values ('005','EveryoneBuys','This very book');
-insert into t2 values ('006','San Fran','It is a san fran lifestyle');
-insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');
-insert into t3 values('000','New York Public Libra','1');
-insert into t3 values('001','New York Public Libra','2');
-insert into t3 values('002','New York Public Libra','3');
-insert into t3 values('003','New York Public Libra','4');
-insert into t3 values('004','New York Public Libra','5');
-insert into t3 values('005','New York Public Libra','6');
-insert into t3 values('006','San Fransisco Public','5');
-insert into t3 values('007','Berkeley Public1','3');
-insert into t3 values('007','Berkeley Public2','3');
-insert into t3 values('001','NYC Lib','8');
-insert into t1 values ('New York Public Libra','New York');
-insert into t1 values ('San Fransisco Public','San Fran');
-insert into t1 values ('Berkeley Public1','Berkeley');
-insert into t1 values ('Berkeley Public2','Berkeley');
-insert into t1 values ('NYC Lib','New York');
-select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname;
-select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1;
-drop table t1, t2, t3;
-
-#
-# Problem with table dependencies
-#
-
-create table t1 (
-    id		int not null,
-    name	tinytext not null,
-    unique	(id)
-);
-create table t2 (
-    id		int not null,
-    idx		int not null,
-    unique	(id, idx)
-);
-create table t3 (
-    id		int not null,
-    idx		int not null,
-    unique	(id, idx)
-);
-insert into t1 values (1,'yes'), (2,'no');
-insert into t2 values (1,1);
-insert into t3 values (1,1);
-EXPLAIN
-SELECT DISTINCT
-    t1.id
-from
-    t1
-    straight_join
-    t2
-    straight_join
-    t3
-    straight_join
-    t1 as j_lj_t2 left join t2 as t2_lj
-        on j_lj_t2.id=t2_lj.id
-    straight_join
-    t1 as j_lj_t3 left join t3 as t3_lj
-        on j_lj_t3.id=t3_lj.id
-WHERE
-    ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
-    AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
-SELECT DISTINCT
-    t1.id
-from
-    t1
-    straight_join
-    t2
-    straight_join
-    t3
-    straight_join
-    t1 as j_lj_t2 left join t2 as t2_lj
-        on j_lj_t2.id=t2_lj.id
-    straight_join
-    t1 as j_lj_t3 left join t3 as t3_lj
-        on j_lj_t3.id=t3_lj.id
-WHERE
-    ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
-    AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
-drop table t1,t2,t3;
-
-#
-# Test of hex constants in WHERE:
-#
-
-create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) );
-insert into t1 set UNIQ=0x38afba1d73e6a18a;
-insert into t1 set UNIQ=123; 
-explain select * from t1 where UNIQ=0x38afba1d73e6a18a;
-drop table t1;
-
-#
-# Test of compressed decimal index.
-#
-
-CREATE TABLE t1 (
-  name varchar(50) DEFAULT '' NOT NULL,
-  author varchar(50) DEFAULT '' NOT NULL,
-  category decimal(10,0) DEFAULT '0' NOT NULL,
-  email varchar(50),
-  password varchar(50),
-  proxy varchar(50),
-  bitmap varchar(20),
-  msg varchar(255),
-  urlscol varchar(127),
-  urlhttp varchar(127),
-  timeout decimal(10,0),
-  nbcnx decimal(10,0),
-  creation decimal(10,0),
-  livinguntil decimal(10,0),
-  lang decimal(10,0),
-  type decimal(10,0),
-  subcat decimal(10,0),
-  subtype decimal(10,0),
-  reg char(1),
-  scs varchar(255),
-  capacity decimal(10,0),
-  userISP varchar(50),
-  CCident varchar(50) DEFAULT '' NOT NULL,
-  PRIMARY KEY (name,author,category)
-);
-INSERT INTO t1 VALUES
-('patnom','patauteur',0,'p.favre@cryo-networks.fr',NULL,NULL,'#p2sndnq6ae5g1u6t','essai\nsalut','scol://195.242.78.119:patauteur.patnom',NULL,NULL,NULL,950036174,-882087474,NULL,3,0,3,'1','Pub/patnom/futur_divers.scs',NULL,'pat','CC1');
-INSERT INTO t1 VALUES
-('LeNomDeMonSite','Marc',0,'m.barilley@cryo-networks.fr',NULL,NULL,NULL,NULL,'scol://195.242.78.119:Marc.LeNomDeMonSite',NULL,NULL,NULL,950560434,-881563214,NULL,3,0,3,'1','Pub/LeNomDeMonSite/domus_hibere.scs',NULL,'Marq','CC1');
-select * from t1 where name='patnom' and author='patauteur' and category=0;
-drop table t1;
-
-#
-# Test of group by bug in bugzilla
-#
-
-CREATE TABLE t1 (
-  bug_id mediumint(9) DEFAULT '0' NOT NULL auto_increment,
-  groupset bigint(20) DEFAULT '0' NOT NULL,
-  assigned_to mediumint(9) DEFAULT '0' NOT NULL,
-  bug_file_loc text,
-  bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
-  bug_status enum('NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
-  creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
-  delta_ts timestamp(14),
-  short_desc mediumtext,
-  long_desc mediumtext,
-  op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL,
-  priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL,
-  product varchar(64) DEFAULT '' NOT NULL,
-  rep_platform enum('All','PC','VTD-8','Other'),
-  reporter mediumint(9) DEFAULT '0' NOT NULL,
-  version varchar(16) DEFAULT '' NOT NULL,
-  component varchar(50) DEFAULT '' NOT NULL,
-  resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL,
-  target_milestone varchar(20) DEFAULT '' NOT NULL,
-  qa_contact mediumint(9) DEFAULT '0' NOT NULL,
-  status_whiteboard mediumtext NOT NULL,
-  votes mediumint(9) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (bug_id),
-  KEY assigned_to (assigned_to),
-  KEY creation_ts (creation_ts),
-  KEY delta_ts (delta_ts),
-  KEY bug_severity (bug_severity),
-  KEY bug_status (bug_status),
-  KEY op_sys (op_sys),
-  KEY priority (priority),
-  KEY product (product),
-  KEY reporter (reporter),
-  KEY version (version),
-  KEY component (component),
-  KEY resolution (resolution),
-  KEY target_milestone (target_milestone),
-  KEY qa_contact (qa_contact),
-  KEY votes (votes)
-);
-
-INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0);
-INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
-INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
-INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
-INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
-INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
-INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0);
-INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
-INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0);
-INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
-INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
-INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
-INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0);
-INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-CREATE TABLE t2 (
-  value tinytext,
-  program varchar(64),
-  initialowner tinytext NOT NULL,
-  initialqacontact tinytext NOT NULL,
-  description mediumtext NOT NULL
-);
-
-INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','','');
-INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','','');
-INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','','');
-INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
-INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
-select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
-select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
-
-drop table t1,t2;
-
-#
-# Problem with search on partial index
-#
-
-create table t1
-(
-  name_id int not null auto_increment,
-  name blob,
-  INDEX name_idx (name(5)),
-  primary key (name_id)
-);
-
-INSERT t1 VALUES(NULL,'/');
-INSERT t1 VALUES(NULL,'[T,U]_axpby');         
-SELECT * FROM t1 WHERE name='[T,U]_axpy';
-SELECT * FROM t1 WHERE name='[T,U]_axpby';
-create table t2
-(
-  name_id int not null auto_increment,
-  name char(255) binary,
-  INDEX name_idx (name(5)),
-  primary key (name_id)
-);
-INSERT t2 select * from t1;
-SELECT * FROM t2 WHERE name='[T,U]_axpy';
-SELECT * FROM t2 WHERE name='[T,U]_axpby';
-drop table t1,t2;
-
-#
-# Problem with many enums
-#
-
-CREATE TABLE t1 (
-  field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL,
-  KEY field (field)
-);
-INSERT INTO t1 VALUES ('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001010'),('001010'),('001010'),('001010'),('001010'),('001018'),('001018'),('001018'),('001018'),('001018'),('001018'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001021'),('001021'),('001021'),('001021'),('001021'),('001021'),('001027'),('001027'),('001028'),('001030'),('001030'),('001030'),('001030'),('001031'),('001031'),('001031'),('001031'),('001031'),('001100'),('001100'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('003002'),('003002'),('003002'),('003002'),('003002'),('003002'),('003003'),('003003'),('003003'),('003003'),('003003'),('003003'),('003004'),('003004'),('003004'),('003004'),('003004'),('003004'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003007'),('003007'),('003007'),('003007'),('003007'),('003008'),('003008'),('003008'),('003008'),('003008'),('003008'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003015'),('003015'),('003015'),('003015'),('003015'),('003015'),('003016'),('003016'),('003016'),('003016'),('003016'),('003016'),('003017'),('003017'),('003017'),('003017'),('003017'),('003018'),('003018'),('003018'),('003018'),('003018'),('003019'),('003019'),('004003'),('004005'),('004005'),('004005'),('004005'),('004005'),('004005'),('004006'),('004008'),('004010'),('004012'),('004012'),('004014'),('004014'),('004014'),('004014'),('004014'),('004016'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004020'),('004020'),('004020'),('004020'),('004020'),('004020'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004022'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004025'),('004026'),('004026'),('004026'),('004026'),('004026'),('006004'),('006006'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006011'),('006011'),('006011'),('006011'),('006011'),('006011'),('006012'),('006012'),('006012'),('006012'),('006012'),('006012'),('006014'),('006014'),('006014'),('007001'),('007001'),('007002'),('007003'),('007005'),('007007'),('007008'),('007009'),('007011'),('007012'),('007013'),('007015'),('007016'),('007017'),('007018'),('007019'),('007019'),('007020'),('007021'),('007021'),('007022'),('007023'),('007023'),('007025'),('007025'),('007025'),('007027'),('007029'),('007031'),('007031'),('007032'),('007034'),('007034'),('007036'),('007036'),('007036'),('007037'),('007037'),('007038'),('007040'),('007040'),('007040'),('007043'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009002'),('009002'),('009002'),('009002'),('009002'),('009004'),('009004'),('009004'),('009004'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009006'),('009006'),('009006'),('009006'),('009007'),('009007'),('009007'),('009007'),('009007'),('009007'),('009008'),('009010'),('009010'),('009010'),('009010'),('009010'),('009010'),('009011'),('009011'),('009011'),('009011'),('009011'),('009012'),('009013'),('009013'),('009013'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010005'),('010005'),('010005'),('010005'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010007'),('010007'),('010007'),('010007'),('010007'),('010007'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010009'),('010009'),('010009'),('010009'),('010009'),('010009'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010013'),('010013'),('010013'),('010013'),('010013'),('010013'),('010015'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010017'),('010017'),('010017'),('010017'),('010017'),('010017'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010019'),('010019'),('010019'),('010019'),('010019'),('010019'),('010020'),('010020'),('010020'),('010021'),('010021'),('010021'),('010021'),('010021'),('010021'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010026'),('010027'),('010028'),('010028'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011012'),('011012'),('011012'),('011013'),('011013'),('011013'),('011013'),('011013'),('011013'),('011014'),('011014'),('011014'),('011014'),('011015'),('011015'),('011015'),('011015'),('011015'),('011016'),('011016'),('011016'),('011016'),('011016'),('012017'),('012017'),('012027'),('012027'),('012032'),('012034'),('012036'),('012036'),('012037'),('012037'),('012038'),('012039'),('014001'),('014001'),('016016'),('016016'),('016016'),('016019'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016022'),('016022'),('016022'),('016023'),('016023'),('016023'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016026'),('016026'),('016026'),('016026'),('016026'),('016026'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016029'),('016029'),('016030'),('016031'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016033'),('016033'),('016033'),('016033'),('016033'),('016034'),('016034'),('016034'),('016034'),('016034'),('017002'),('017002'),('017002'),('017002'),('017002'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('019002'),('019002'),('019002'),('019002'),('019002'),('019002'),('019004'),('019004'),('019004'),('019004'),('019004'),('019004'),('020001'),('020001'),('020001'),('020001'),('020004'),('020006'),('020006'),('020006'),('020006'),('020006'),('020006'),('020008'),('020009'),('020009'),('020009'),('020009'),('020009'),('022001'),('022001'),('022001'),('022001'),('022002'),('022002'),('022002'),('022002'),('022003'),('022003'),('022003'),('022003'),('023001'),('023002'),('023002'),('023002'),('023002'),('023002'),('023002'),('023003'),('023003'),('023003'),('023003'),('023004'),('023004'),('023005'),('023005'),('023006'),('023006'),('023006'),('023006'),('023006'),('023006'),('023007'),('023007'),('023010'),('023010'),('023011'),('023011'),('023017'),('023019'),('023019'),('023019'),('023020'),('023020'),('023025'),('023025'),('023025'),('023026'),('023026'),('023026'),('023027'),('023027'),('023027'),('023028'),('023028'),('023029'),('023029'),('023030'),('023030'),('023032'),('023033'),('023033'),('023033'),('023033'),('023033'),('023033'),('023034'),('023035'),('023035'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025003'),('025003'),('025004'),('025004'),('025005'),('025005'),('025007'),('025007'),('025008'),('025008'),('025009'),('025010'),('025010'),('025010'),('025011'),('025011'),('025012'),('025012'),('025013'),('025013'),('025013'),('025014'),('025015'),('025016'),('025018'),('025018'),('025019'),('025019'),('025020'),('025020'),('025021'),('025022'),('025022'),('025023'),('025023'),('025024'),('025025'),('025025'),('025026'),('025026'),('025027'),('025027'),('025027'),('025028'),('025030'),('025031'),('025033'),('025034'),('025035'),('025037'),('025041'),('025042'),('025043'),('025046'),('025048'),('025048'),('025048'),('025049'),('025049'),('025049'),('025050'),('025050'),('025050'),('025051'),('025051'),('025052'),('025052'),('025052'),('025053'),('025053'),('025054'),('025054'),('025054'),('025054'),('025055'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025057'),('025057'),('025058'),('025058'),('025060'),('025060'),('025061'),('025062'),('025063'),('027001'),('027002'),('027011'),('036001'),('036001'),('036001'),('036001'),('036001'),('037003'),('037006'),('037007'),('037008'),('037008'),('038009'),('039001'),('039001'),('039001'),('039001'),('039001'),('039001'),('039002'),('039002'),('039002'),('039002'),('039002'),('039003'),('039003'),('039003'),('039003'),('039003'),('039003'),('039004'),('039004'),('039004'),('039004'),('039004'),('039005'),('039005'),('039005'),('039005'),('039005'),('039006'),('039006'),('039006'),('039006'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046007'),('046007'),('046007'),('046007'),('046007'),('046007'),('046008'),('046008'),('046008'),('046008'),('046008'),('046009'),('046009'),('046009'),('046010'),('046012'),('046012'),('046012'),('046013'),('046014'),('046014'),('046014'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('051003'),('051003'),('051003'),('051003'),('051003'),('051004'),('051004'),('051004'),('051004'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052002'),('052002'),('052005'),('052005'),('052005'),('052005'),('052005'),('052005'),('053016'),('053019'),('053019'),('053023'),('053023'),('053023'),('053023'),('053024'),('053024'),('053024'),('053026'),('053026'),('053026'),('053026'),('053028'),('053028'),('053029'),('053029'),('053029'),('053029'),('053033'),('053033'),('053033'),('053045'),('053046'),('053051'),('053051'),('053051'),('053054'),('053054'),('053054'),('053054'),('053057'),('053069'),('053069'),('053097'),('053107'),('053125'),('053125'),('053127'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054002'),('054002'),('054002'),('054002'),('054002'),('054002'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054006'),('054006'),('054006'),('054007'),('054007'),('054007'),('054007'),('054007'),('054009'),('054009'),('054009'),('054009'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056003'),('056003'),('056003'),('056003'),('056003'),('056003'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056009'),('056009'),('056009'),('056011'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056018'),('056018'),('056018'),('056018'),('056018'),('056018'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056020'),('056020'),('056020'),('056020'),('056022'),('056022'),('056022'),('056022'),('056022'),('057003'),('057003'),('057004'),('058002'),('058002'),('058002'),('058002'),('058003'),('058003'),('058003'),('058003'),('058004'),('058004'),('058004'),('058005'),('058005'),('058005'),('060001'),('060001'),('060001'),('060001'),('060001'),('060004'),('060004'),('060004'),('060004'),('060004'),('060004'),('060005'),('060005'),('060005'),('060005'),('060005'),('060005'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('061004'),('061004'),('061004'),('061004'),('061004'),('061004'),('061006'),('061006'),('061006'),('061006'),('061006'),('061006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069010'),('069010'),('069010'),('069010'),('069010'),('069010'),('069011'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069016'),('069016'),('069016'),('069016'),('069016'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069020'),('069020'),('069020'),('069020'),('069021'),('069023'),('071002'),('071002'),('071002'),('071002'),('071002'),('071003'),('071003'),('071003'),('071003'),('071003'),('071004'),('071004'),('071004'),('071004'),('071004'),('071005'),('071005'),('071005'),('071005'),('071005'),('071005'),('071006'),('071006'),('071006'),('071006'),('071008'),('071008'),('071008'),('071008'),('071008'),('071008'),('071011'),('071011'),('071011'),('071011'),('071011'),('071020'),('071020'),('071020'),('071020'),('071020'),('071021'),('071022'),('071022'),('071022'),('072001'),('072001'),('074001'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('075001'),('075001'),('075001'),('075007'),('075007'),('075007'),('075007'),('076101'),('076101'),('076101'),('076101'),('076102'),('076102'),('076102'),('076103'),('076103'),('076103'),('076103'),('076103'),('077001'),('077001'),('077001'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077004'),('077004'),('077004'),('077004'),('077004'),('077004'),('077006'),('077006'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('078005'),('078005'),('078005'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079003'),('079003'),('079004'),('079004'),('079005'),('079005'),('079005'),('079005'),('079005'),('079005'),('079006'),('079006'),('079006'),('079006'),('079007'),('079007'),('079007'),('079007'),('079007'),('081001'),('081001'),('081001'),('081001'),('081001'),('082011'),('082011'),('082011'),('082011'),('082011'),('082013'),('082013'),('082013'),('082013'),('082013'),('082013'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082015'),('082015'),('082015'),('082015'),('082015'),('082016'),('082016'),('082016'),('082016'),('082016'),('082016'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082021'),('082021'),('082022'),('082022'),('082022'),('082022'),('082022'),('082023'),('082023'),('082023'),('082023'),('082023'),('082024'),('082024'),('082024'),('082024'),('082024'),('082025'),('082025'),('082025'),('082025'),('082025'),('082026'),('082026'),('082026'),('082026'),('082026'),('082027'),('082027'),('082027'),('082027'),('082027'),('082028'),('082028'),('082028'),('082028'),('082029'),('082029'),('082029'),('082029'),('082029'),('082030'),('082030'),('082030'),('082030'),('082031'),('082031'),('082031'),('082031'),('082031'),('082032'),('082032'),('082032'),('082033'),('082033'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082035'),('082035'),('082035'),('082036'),('082036'),('082036'),('082036'),('082037'),('082037'),('082037'),('082038'),('082038'),('082038'),('082038'),('082039'),('082039'),('082039'),('082039'),('082040'),('082040'),('082040'),('082040'),('082040'),('082041'),('082041'),('082041'),('082041'),('082042'),('082042'),('082043'),('082043'),('082043'),('082043'),('082043'),('082044'),('082044'),('082044'),('082044'),('084001'),('084002'),('084002'),('084002'),('084002'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084004'),('084004'),('084004'),('084004'),('084004'),('084005'),('084005'),('084005'),('084005'),('084005'),('084007'),('084007'),('084007'),('084007'),('084007'),('084007'),('084008'),('084008'),('084008'),('084008'),('084008'),('084008'),('084009'),('084009'),('084009'),('084009'),('084009'),('084009'),('084011'),('084013'),('084013'),('084013'),('084013'),('084013'),('084014'),('084014'),('084014'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084027'),('084027'),('084027'),('084027'),('084027'),('084027'),('084032'),('084032'),('084033'),('084033'),('084033'),('084035'),('084035'),('084035'),('084036'),('084036'),('084036'),('084036'),('084036'),('084036'),('084037'),('084037'),('084038'),('084038'),('084038'),('084038'),('084038'),('084038'),('084039'),('084039'),('084039'),('084039'),('084040'),('084040'),('084040'),('084040'),('084040'),('084041'),('084041'),('084041'),('084041'),('084042'),('084042'),('084043'),('084043'),('084043'),('084043'),('084044'),('084044'),('084044'),('084044'),('084044'),('084045'),('084046'),('084046'),('084046'),('084047'),('084048'),('084048'),('084049'),('084049'),('084050'),('084051'),('084051'),('085001'),('085001'),('085001'),('085001'),('085001'),('085001'),('085002'),('085002'),('085002'),('085002'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085005'),('085005'),('085005'),('085005'),('085005'),('085005'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085009'),('085009'),('085009'),('085009'),('085009'),('085009'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085017'),('085017'),('085017'),('085017'),('085017'),('085018'),('085018'),('085018'),('085018'),('085018'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085020'),('085020'),('085020'),('085020'),('085020'),('085020'),('085022'),('085022'),('085022'),('085022'),('085022'),('085022'),('085023'),('085023'),('085023'),('085023'),('085023'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085033'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085035'),('085035'),('085035'),('085035'),('085035'),('085035'),('085036'),('085036'),('085036'),('085036'),('085036'),('085036'),('085037'),('085037'),('085037'),('085037'),('085037'),('085037'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085043'),('085043'),('085043'),('085043'),('085043'),('085043'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085045'),('085045'),('085045'),('085045'),('085045'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085063'),('085063'),('085063'),('085063'),('085063'),('085064'),('085064'),('085064'),('085064'),('085064'),('085065'),('085065'),('085068'),('085068'),('085068'),('085068'),('085068'),('085068'),('085071'),('085071'),('085071'),('085071'),('085071'),('085071'),('085073'),('085073'),('085082'),('085082'),('085082'),('085082'),('085082'),('085086'),('085086'),('085086'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085089'),('085089'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085091'),('085091'),('085091'),('085091'),('085091'),('085092'),('085092'),('085092'),('085093'),('085093'),('085095'),('085095'),('085095'),('085095'),('085095'),('085096'),('085096'),('085096'),('085096'),('085096'),('085096'),('085097'),('085097'),('085097'),('085097'),('085097'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085102'),('085102'),('085103'),('085103'),('085103'),('085104'),('085104'),('085104'),('085104'),('085104'),('085105'),('085105'),('085106'),('085106'),('085106'),('085106'),('085106'),('085106'),('085108'),('085108'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085110'),('085110'),('085110'),('085110'),('085110'),('085111'),('085111'),('085111'),('085112'),('085112'),('085112'),('085112'),('085113'),('085113'),('085113'),('085113'),('085113'),('085115'),('085120'),('085121'),('085121'),('085121'),('085121'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085125'),('085125'),('085125'),('085125'),('085125'),('085126'),('085126'),('085126'),('085126'),('085126'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085128'),('085128'),('085128'),('085128'),('085128'),('085129'),('085129'),('085129'),('085129'),('085129'),('085130'),('085130'),('085130'),('085130'),('085130'),('085132'),('085132'),('085132'),('085132'),('085132'),('085132'),('085133'),('085133'),('085133'),('085133'),('085133'),('085134'),('085134'),('085134'),('085135'),('085135'),('085135'),('085136'),('085136'),('085136'),('085136'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('086002'),('086002'),('086002'),('086002'),('086003'),('086003'),('086003'),('086003'),('086005'),('088001'),('088001'),('088001'),('088001'),('088001'),('088003'),('088003'),('088003'),('088003'),('088003'),('088003'),('088005'),('088005'),('088005'),('088005'),('088005'),('088006'),('088006'),('088006'),('088006'),('088006'),('088007'),('088007'),('088007'),('088008'),('088008'),('088008'),('088008'),('088009'),('088009'),('088009'),('088009'),('088009'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090002'),('090002'),('090002'),('090002'),('090002'),('090002'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090008'),('090008'),('090008'),('090008'),('090008'),('090009'),('090009'),('090009'),('090009'),('090009'),('090010'),('090010'),('090013'),('090013'),('090013'),('090016'),('090016'),('090017'),('090018'),('090022'),('090027'),('091001'),('091001'),('091001'),('091001'),('091001'),('091001'),('091002'),('091002'),('091002'),('091002'),('091002'),('091002'),('091009'),('091009'),('091009'),('091009'),('091009'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091012'),('091012'),('091013'),('091013'),('091013'),('091013'),('091013'),('091013'),('091015'),('091015'),('091015'),('091015'),('091015'),('091015'),('091016'),('091016'),('091016'),('091016'),('091016'),('091017'),('091017'),('091018'),('091018'),('091018'),('091018'),('093003'),('093003'),('093003'),('093003'),('093003'),('093003'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('100001'),('100001'),('100001'),('100001'),('106001'),('113005'),('113005'),('113005'),('113006'),('113006'),('113018'),('113019'),('113020'),('115001'),('115001'),('115001'),('115002'),('115002'),('115003'),('115004'),('115004'),('115004'),('115004'),('115005'),('115005'),('115005'),('115006'),('115006'),('115006'),('115007'),('115007'),('115007'),('115007'),('115007'),('115008'),('115008'),('115008'),('115009'),('115010'),('115010'),('115010'),('115010'),('115010'),('115011'),('115011'),('115011'),('115011'),('115012'),('115012'),('115013'),('115013'),('115013'),('115014'),('115014'),('115014'),('115014'),('115015'),('115015'),('115015'),('115016'),('115016'),('115016'),('115016'),('115017'),('115017'),('115017'),('115017'),('115017'),('115018'),('115018'),('115020'),('115020'),('115021'),('115021'),('115022'),('115022'),('115022'),('115023'),('115023'),('115023'),('115023'),('115023'),('115025'),('115025'),('115025'),('115026'),('115026'),('115027'),('115027'),('115027'),('115028'),('115028'),('115028'),('115028'),('115029'),('115029'),('115029'),('115030'),('115030'),('115030'),('115031'),('115031'),('115032'),('115032'),('115032'),('115033'),('115033'),('115033'),('115033'),('115034'),('115034'),('115034'),('115035'),('115035'),('115036'),('115036'),('115036'),('115036'),('115036'),('115039'),('115040'),('115040'),('115040'),('115041'),('115041'),('115041'),('115041'),('115041'),('115042'),('115042'),('115042'),('115042'),('115042'),('115043'),('115043'),('115043'),('115044'),('115044'),('115044'),('115044'),('115046'),('115046'),('115046'),('115047'),('115048'),('115050'),('115050'),('115050'),('115050'),('115050'),('115051'),('115051'),('115051'),('115052'),('115053'),('115053'),('115054'),('115054'),('115054'),('115055'),('115055'),('115055'),('115057'),('115059'),('115059'),('115059'),('115059'),('115060'),('115060'),('115060'),('115060'),('115060'),('115060'),('115061'),('115061'),('115061'),('115062'),('115062'),('115062'),('115062'),('115064'),('115064'),('115064'),('115065'),('115065'),('115065'),('115065'),('115066'),('115066'),('115066'),('115067'),('115067'),('115067'),('115068'),('115068'),('115068'),('115069'),('115069'),('115069'),('115069'),('115069'),('115070'),('115070'),('115070'),('115071'),('115071'),('115071'),('115072'),('115072'),('115072'),('115073'),('115073'),('115075'),('115075'),('115075'),('115076'),('115076'),('115076'),('115076'),('115076'),('115076'),('115081'),('115081'),('115081'),('115082'),('115082'),('115082'),('115085'),('115085'),('115085'),('115085'),('115085'),('115086'),('115086'),('115086'),('115087'),('115087'),('115088'),('115088'),('115088'),('115088'),('115088'),('115095'),('115095'),('115095'),('115096'),('115096'),('115097'),('115097'),('115098'),('115098'),('115099'),('115101'),('115102'),('115102'),('115102'),('115103'),('115103'),('115104'),('115104'),('115104'),('115104'),('115105'),('115105'),('115106'),('115106'),('115106'),('115106'),('115106'),('115108'),('115109'),('115111'),('115111'),('115111'),('115111'),('115112'),('115112'),('115112'),('115112'),('115112'),('115113'),('115113'),('115113'),('115114'),('115114'),('115114'),('115114'),('115114'),('115115'),('115115'),('115115'),('115115'),('115116'),('115117'),('115117'),('115117'),('115118'),('115118'),('115119'),('115119'),('115119'),('115119'),('115120'),('115121'),('115121'),('115122'),('115122'),('116001'),('116003'),('116003'),('116003'),('116003'),('116004'),('116004'),('116005'),('116005'),('116006'),('116006'),('116006'),('116007'),('116007'),('116008'),('116008'),('116009'),('116009'),('116009'),('116010'),('116010'),('116010'),('116010'),('116011'),('116011'),('116011'),('116011'),('116012'),('116012'),('123001'),('123001'),('123001'),('123001'),('123001'),('124065'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126012'),('126012'),('126012'),('126012'),('130001'),('130001'),('130001'),('130001'),('132001'),('132001'),('132001'),('132001'),('132001'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('133001'),('133001'),('133008'),('133009'),('133010'),('133011'),('133011'),('133011'),('133011'),('133011'),('133011'),('133012'),('133015'),('133015'),('133015'),('133015'),('133016'),('133018'),('133018'),('133018'),('133018'),('133018'),('133019'),('133021'),('133021'),('133022'),('133022'),('133023'),('133023'),('133024'),('133024'),('133024'),('133024'),('133024'),('133024'),('133025'),('133027'),('133027'),('133027'),('133027'),('133027'),('133028'),('133028'),('133028'),('133029'),('133029'),('133029'),('133029'),('133029'),('133029'),('133030'),('133030'),('133031'),('133031'),('133031'),('134001'),('134001'),('134001'),('135001'),('135001'),('135001'),('135001'),('135001'),('135002'),('135002'),('135002'),('135004'),('135010'),('135010'),('135010'),('135010'),('135010'),('135010'),('137010'),('137011'),('137012'),('137014'),('137015'),('137015'),('137016'),('137019'),('139001'),('140001'),('140001'),('140001'),('140001'),('140001'),('140001'),('141001'),('141001'),('141001'),('141001'),('141001'),('141002'),('141002'),('141002'),('141002'),('141002'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141007'),('141007'),('141007'),('141007'),('141007'),('141009'),('141009'),('141009'),('141009'),('141009'),('141011'),('141011'),('141011'),('141011'),('141011'),('141011'),('141012'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141015'),('141015'),('141015'),('141015'),('141015'),('141016'),('141016'),('141016'),('141016'),('141016'),('141016'),('141017'),('141017'),('141017'),('141017'),('141017'),('141017'),('141018'),('141018'),('141018'),('141018'),('141019'),('141019'),('141019'),('141019'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141021'),('141021'),('141021'),('141021'),('141021'),('141021'),('141022'),('141022'),('141022'),('141022'),('141022'),('141022'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141024'),('141025'),('141025'),('141025'),('141026'),('141026'),('141026'),('141026'),('141026'),('141026'),('141027'),('141027'),('141027'),('141027'),('141027'),('141028'),('141028'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('150009'),('150013'),('150014'),('150015'),('150015'),('150015'),('150016'),('150016'),('150017'),('150017'),('150017'),('150017'),('150020'),('152001'),('152001'),('152001'),('152002'),('152003'),('152003'),('152003'),('152003'),('152004'),('152005'),('152006'),('152006'),('152006'),('152006'),('152007'),('154001'),('154002'),('154002'),('155001'),('155001'),('155002'),('155003'),('155004'),('155004'),('155006'),('159001'),('159003'),('160001'),('160001'),('160001'),('160001'),('160002'),('160002'),('161001'),('162002'),('162002'),('162003'),('162003'),('162003'),('162003'),('162003'),('162007'),('162012'),('162012'),('162012'),('163001'),('163001'),('163001'),('163011'),('163015'),('163016'),('163016'),('165001'),('165001'),('165001'),('165001'),('165002'),('165002'),('165002'),('165002'),('165003'),('165003'),('165003'),('165004'),('165004'),('165004'),('165005'),('165005'),('165005'),('165006'),('165006'),('165006'),('165006'),('165007'),('165007'),('165007'),('165007'),('165008'),('165008'),('165008'),('165008'),('165009'),('165009'),('165009'),('165009'),('165010'),('165010'),('165010'),('165011'),('165011'),('165012'),('165012'),('165012'),('165013'),('165013'),('165013'),('165014'),('165014'),('165014'),('165015'),('165015'),('165015'),('165015'),('165016'),('165016'),('165016'),('165017'),('165017'),('165017'),('165017'),('165018'),('165018'),('165018'),('165018'),('165019'),('165019'),('165019'),('165019'),('165020'),('165020'),('165020'),('165020'),('165021'),('165021'),('165021'),('165021'),('165022'),('165022'),('165022'),('165023'),('165024'),('165024'),('165024'),('165025'),('165025'),('165025'),('165026'),('165026'),('165026'),('165028'),('165029'),('165030'),('165030'),('165030'),('165031'),('165031'),('165033'),('165033'),('165034'),('165034'),('165034'),('165035'),('165035'),('165035'),('165036'),('165036'),('165036'),('168003'),('168003'),('168004'),('168005'),('168014'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169003'),('169003'),('169003'),('169003'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169009'),('169009'),('169009'),('169009'),('169010'),('171006'),('171006'),('171007'),('171007'),('171008'),('171008'),('171008'),('171009'),('171009'),('171009'),('172001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176002'),('176002'),('176002'),('176002'),('176002'),('176003'),('176003'),('176003'),('176003'),('176003'),('176003'),('177001'),('177001'),('177001'),('177001'),('177001'),('177001'),('179007'),('179007'),('179012'),('179012'),('179012'),('179012'),('179012'),('179012'),('179013'),('179013'),('179013'),('179013'),('179013'),('179013'),('179042'),('179044'),('179045'),('180001'),('180013'),('180014'),('180014'),('180015'),('180017'),('180018'),('180020'),('180020'),('180021'),('180021'),('180027'),('180030'),('180033'),('180035'),('180036'),('180037'),('180038'),('180041'),('180042'),('180045'),('180045'),('180047'),('180048'),('180049'),('180050'),('180054'),('180060'),('180066'),('180067'),('180068'),('180070'),('182001'),('184001'),('184002'),('184005'),('184005'),('184005'),('184005'),('184006'),('184006'),('184006'),('184006'),('184008'),('184008'),('184008'),('184008'),('184009'),('184009'),('184009'),('184009'),('184010'),('184010'),('184010'),('184010'),('184011'),('184011'),('184011'),('184011'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('187001'),('191002'),('191002'),('192002'),('194003'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197005'),('197005'),('197005'),('197005'),('197005'),('197005'),('197006'),('197006'),('197006'),('197006'),('197006'),('198001'),('198001'),('198001'),('198001'),('198001'),('198001'),('198003'),('198003'),('198003'),('198004'),('198004'),('198004'),('198004'),('198004'),('198004'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198006'),('198006'),('198006'),('198006'),('198006'),('198006'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198008'),('198008'),('198008'),('198008'),('198008'),('198008'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198010'),('198010'),('198010'),('198010'),('198010'),('198010'),('198011'),('198012'),('198012'),('198012'),('198012'),('198015'),('198015'),('198016'),('198016'),('198016'),('198016'),('198016'),('198016'),('198017'),('198017'),('198017'),('198017'),('198017'),('198017'),('201001'),('201001'),('201001'),('201001'),('201001'),('201002'),('202001'),('202001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203002'),('203002'),('203002'),('203002'),('203003'),('203003'),('203003'),('203003'),('203003'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203018'),('203018'),('203018'),('203018'),('203018'),('203019'),('203019'),('203019'),('203019'),('203019'),('204001'),('204002'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('208001'),('208001'),('208002'),('208002'),('208002'),('208003'),('208003'),('208003'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208005'),('208005'),('208005'),('208005'),('208005'),('209001'),('209001'),('209001'),('209001'),('209001'),('209002'),('209002'),('209002'),('209002'),('209002'),('209003'),('209003'),('209003'),('209003'),('209003'),('210001'),('210001'),('210001'),('210001'),('210001'),('210004'),('210004'),('210004'),('210004'),('210004'),('210004'),('210009'),('210010'),('212001'),('212001'),('212002'),('212002'),('212002'),('212002'),('212003'),('212003'),('212003'),('212004'),('212004'),('212004'),('212005'),('212005'),('212005'),('212005'),('212005'),('212006'),('212006'),('212006'),('212007'),('212007'),('212008'),('212008'),('212008'),('212008'),('212009'),('212009'),('212009'),('212009'),('212010'),('212010'),('212010'),('212010'),('212011'),('212011'),('212012'),('212012'),('212013'),('212013'),('212013'),('218001'),('218004'),('218009'),('218011'),('218011'),('218015'),('218020'),('218021'),('218021'),('218022'),('218022'),('218022'),('218023'),('218024'),('218025'),('218026'),('218026'),('218027'),('218028'),('218029'),('218029'),('218029'),('218030'),('218031'),('221001'),('221001'),('221001'),('221001'),('221001'),('221001'),('221002'),('221002'),('221002'),('221002'),('221002'),('221002'),('221003'),('221003'),('221003'),('221003'),('221003'),('221003'),('221004'),('221004'),('221004'),('221004'),('221004'),('221004'),('221005'),('221005'),('221005'),('221005'),('221005'),('221006'),('221006'),('221006'),('221006'),('221006'),('221007'),('221007'),('221007'),('221007'),('221007'),('221007'),('221008'),('221008'),('221008'),('221008'),('221008'),('221008'),('221009'),('221009'),('221009'),('221009'),('221009'),('221009'),('221010'),('221010'),('221010'),('221010'),('221011'),('221011'),('221011'),('221011'),('221012'),('221012'),('221012'),('221012'),('221012'),('221012'),('221013'),('221013'),('221013'),('221013'),('221013'),('221013'),('223003'),('223003'),('224001'),('224001'),('224002'),('224002'),('224003'),('224007'),('224008'),('225001'),('225002'),('225002'),('225002'),('225003'),('225003'),('225003'),('225003'),('225004'),('225004'),('225004'),('225005'),('225005'),('225005'),('225005'),('225005'),('225005'),('225006'),('225006'),('225006'),('225007'),('225007'),('225007'),('225008'),('225008'),('225008'),('225008'),('225008'),('225009'),('225009'),('225009'),('225010'),('225010'),('225010'),('225011'),('225011'),('225011'),('225011'),('225011'),('225012'),('225012'),('225012'),('225012'),('225012'),('225012'),('225013'),('225013'),('226001'),('226002'),('226003'),('226003'),('226005'),('226005'),('226006'),('226007'),('226007'),('226007'),('226007'),('227011'),('227015'),('227015'),('227041'),('227045'),('227052'),('227056'),('227063'),('227064'),('227066'),('227067'),('227069'),('227071'),('227073'),('227085'),('227116'),('227119'),('227131'),('227133'),('227147'),('229005'),('229005'),('229005'),('233003'),('233004'),('235001'),('235001'),('235002'),('235003'),('235003'),('235003'),('235004'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('236001'),('236001'),('236001'),('236001'),('236002'),('236003'),('236003'),('236003'),('236003'),('236003'),('236003'),('238002'),('238002'),('238002'),('238002'),('238002'),('238002'),('238003'),('238003'),('238003'),('238003'),('238003'),('238003'),('238004'),('238004'),('238004'),('238004'),('238004'),('238005'),('238005'),('238005'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('334005'),('334006'),('337001'),('337001'),('337001'),('337002'),('337002'),('337003'),('337003'),('337003'),('337004'),('343001'),('343001'),('344001'),('344002'),('344003'),('344004'),('344005'),('344005'),('345001'),('345001'),('348001'),('348004'),('348005'),('348005'),('349001'),('349001'),('349002'),('349002'),('349002'),('350001'),('353002'),('353002'),('353002'),('353003'),('355001'),('355002'),('355005'),('355006'),('355006'),('356001'),('358001'),('358001'),('358001'),('359001'),('359001'),('359002'),('359002'),('359002'),('359002'),('360001'),('360001'),('360002'),('360002'),('360003'),('360003'),('360004'),('360004'),('360005'),('360005'),('360005'),('366001'),('366002'),('366002'),('366003'),('366004'),('369001'),('369001'),('373001'),('373002'),('373002'),('373003'),('373003'),('373005'),('373007'),('373008'),('373009'),('373009'),('373010'),('373010'),('373010'),('373011'),('373011'),('373011'),('373011'),('373012'),('373012'),('373012'),('373013'),('373013'),('373014'),('373014'),('373015'),('373015'),('373015'),('373015'),('373017'),('373017'),('373017'),('373017'),('373018'),('373021'),('374002'),('374004'),('374006'),('374007'),('374008'),('374009'),('374010'),('374011'),('374012'),('374015'),('374016'),('382001'),('382002'),('382002'),('384001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386006'),('386006'),('386006'),('386006'),('386006'),('386006'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386009'),('386009'),('386009'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386014'),('386014'),('386014'),('386014'),('389001'),('389002'),('389002'),('389003'),('389003'),('389003'),('389003'),('389004'),('389004'),('389004'),('389004'),('392001'),('393001'),('393002'),('393002'),('393003'),('393004'),('395001'),('395001'),('397001'),('397001'),('397001'),('397002'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399003'),('400001'),('400001'),('400001'),('400001'),('400002'),('403002'),('504001'),('504001'),('504002'),('504002'),('504002'),('504004'),('504004'),('504005'),('504006'),('504007'),('504007'),('504007'),('504008'),('504008'),('504009'),('504009'),('504009'),('504009'),('504009'),('504010'),('504011'),('504011'),('504012'),('504012'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504017'),('504017'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504022'),('504023'),('504023'),('504024'),('504024'),('504025'),('504025'),('506001'),('506001'),('506001'),('506001'),('506001'),('506001'),('506002'),('506002'),('506002'),('506002'),('506002'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511003'),('511003'),('511003'),('511003'),('511003'),('511003'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511007'),('511007'),('511007'),('511007'),('511007'),('511008'),('511008'),('511008'),('511008'),('511008'),('511008'),('511009'),('511009'),('511009'),('511009'),('511009'),('511009'),('511010'),('511010'),('511010'),('511010'),('511010'),('511010'),('511011'),('511011'),('511011'),('511011'),('511011'),('511011'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511014'),('511014'),('511014'),('511014'),('511014'),('511017'),('511018'),('511020'),('511021'),('511022'),('511024'),('511028'),('511029'),('511029'),('511029'),('511029'),('511029'),('511029'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513002'),('513002'),('513002'),('513002'),('513002'),('513002'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513004'),('513004'),('513004'),('515001'),('515001'),('515001'),('515001'),('515001'),('515002'),('515002'),('515003'),('515003'),('515007'),('515007'),('515008'),('515011'),('515011'),('515011'),('515011'),('515011'),('515011'),('515012'),('515012'),('515012'),('515012'),('515013'),('515013'),('515013'),('515013'),('515013'),('515014'),('515014'),('515014'),('515014'),('515014'),('515015'),('515015'),('515015'),('515015'),('515015'),('518001'),('518002'),('521001'),('521002'),('521002'),('521002'),('521003'),('521003'),('521003'),('521003'),('521004'),('521004'),('521004'),('521004'),('521005'),('521005'),('521005'),('521005'),('521006'),('521006'),('521006'),('521009'),('521010'),('521010'),('521010'),('521010'),('521011'),('521011'),('521011'),('521011'),('521012'),('521013'),('521013'),('521015'),('521016'),('521016'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523002'),('523002'),('523002'),('523002'),('523002'),('523002'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523004'),('523004'),('523004'),('523004'),('523004'),('523004'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('524001'),('700001'),('701001'),('701002'),('701003'),('702001'),('702002'),('702004'),('702005'),('704001'),('704004'),('705001'),('706001'),('706002'),('707001'),('707002'),('707003'),('708001'),('710001'),('710002'),('711001'),('711002'),('712001'),('714001'),('714002'),('715001'),('719001'),('719002'),('991002'),('991002'),('991002'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991004'),('991004'),('991004'),('991005'),('991005'),('991005'),('991006'),('991007'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996002'),('996002'),('996003'),('996003'),('996003'),('996003'),('996003'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998004'),('998004'),('998005'),('998005'),('998006'),('998007'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999002'),('999002'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011018'),('011018'),('011018'),('011018'),('034001'),('034001'),('034002'),('034002'),('071010'),('071010'),('071010'),('519001'),('126013'),('126013'),('126013'),('126013'),('126013'),('184012'),('184012'),('184012'),('404001'),('405002'),('405002'),('405001'),('405003'),('405006'),('240011'),('240011'),('240011'),('240011'),('240011'),('240011'),('240010'),('240010'),('240010'),('240009'),('240009'),('240009'),('240009'),('240008'),('240008'),('240008'),('240007'),('240007'),('240007'),('240007'),('240007'),('240007'),('240005'),('240005'),('240005'),('240005'),('240005'),('240004'),('240004'),('240004'),('240004'),('240004'),('240003'),('240003'),('240003'),('240003'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240001'),('240001'),('240001'),('240001'),('240001'),('240012'),('240012'),('240012'),('240012'),('240012'),('240013'),('240014'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240016'),('240016'),('240016'),('240016'),('240016'),('240016'),('240017'),('240017'),('240017'),('357001'),('357001'),('235006'),('235006'),('235007'),('235007'),('235007'),('235007'),('235007'),('056023'),('056023'),('056023'),('056023'),('056023'),('046015'),('019005'),('019005'),('126014'),('126014'),('126014'),('126014'),('126014'),('126014'),('241003'),('241003'),('241003'),('241003'),('241003'),('241003'),('241002'),('241002'),('241002'),('241002'),('241002'),('241002'),('241001'),('241001'),('241001'),('241001'),('241001'),('240020'),('240020'),('240020'),('240020'),('240020'),('240020'),('240019'),('240019'),('240019'),('242001'),('242002'),('242004'),('242005'),('242006'),('089002'),('089002'),('089002'),('089002'),('089002'),('089002'),('406001'),('406002'),('406003'),('406004'),('406004'),('243001'),('243005'),('243006'),('243007'),('243008'),('408001'),('408001'),('408001'),('408001'),('408001'),('366005'),('366005'),('016035'),('016035'),('016035'),('016035'),('077010'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('025064'),('025064'),('025064'),('025064'),('011019'),('011019'),('011019'),('011019'),('011019'),('115123'),('115123'),('504026'),('039007'),('039009'),('039008'),('039008'),('039010'),('039010'),('039011'),('039012'),('180072'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240023'),('240023'),('240023'),('240023'),('405008'),('405008'),('525002'),('410002'),('410002'),('410004'),('410005'),('410005'),('410006'),('410007'),('410007'),('410008'),('410009'),('410010'),('410011'),('410011'),('410012'),('410012'),('410013'),('410013'),('410014'),('410014'),('410016'),('410016'),('344006'),('240031'),('240031'),('240031'),('240031'),('240030'),('240030'),('240030'),('240030'),('240029'),('240029'),('240029'),('240029'),('240028'),('240028'),('240028'),('240028'),('240027'),('240027'),('240026'),('240026'),('240026'),('240025'),('240025'),('240025'),('240025'),('240024'),('240024'),('240034'),('240034'),('240034'),('240033'),('240033'),('240033'),('240032'),('240032'),('240032'),('240032'),('411001'),('411002'),('203020'),('069025'),('069025'),('069025'),('069025'),('069025'),('069025'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('240040'),('240037'),('405009'),('405009'),('405009'),('405010'),('405010'),('240043'),('240043'),('504028'),('504040'),('800001'),('410019'),('410019'),('410020'),('410020'),('410020'),('410021'),('410021'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('413001'),('344007'),('082045'),('082045'),('082045'),('082045'),('082045'),('010031'),('010031'),('010031'),('010031'),('010032'),('010032'),('010032'),('010032'),('010033'),('010033'),('010033'),('010033'),('010033'),('010034'),('010034'),('010034'),('010034'),('010035'),('010035'),('010035'),('010035'),('504044'),('515016'),('515016'),('515016'),('515016'),('801002'),('801003'),('801004'),('801005'),('802001'),('801001'),('414001'),('141029'),('803001'),('803002'),('803004'),('803005'),('803006'),('803007'),('803008'),('803009'),('803013'),('803014'),('803015'),('803016'),('803017'),('410022'),('410023'),('410023'),('803019'),('415002'),('415001'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('011020'),('011020'),('011020'),('011020'),('011023'),('011023'),('011023'),('011023'),('011022'),('011022'),('011022'),('011022'),('011022'),('011022'),('011021'),('011021'),('011021'),('011021'),('025065'),('025065'),('025065'),('025065'),('165037'),('165037'),('165038'),('165038'),('165038'),('165039'),('416001'),('416001'),('416001'),('416001'),('416001'),('416002'),('416003'),('417001'),('418001'),('504045'),('504045'),('504045'),('803022'),('240022'),('240022'),('240022'),('240022'),('420001'),('420001'),('420001'),('420001'),('804010'),('804005'),('804002'),('804018'),('804013'),('511019'),('511016'),('511015'),('511032'),('511031'),('511030'),('511027'),('511026'),('511025'),('511033'),('511023'),('133034'),('133034'),('133034'),('133033'),('169011'),('169011'),('169011'),('169011'),('169011'),('344008'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244026'),('244026'),('244026'),('244026'),('244026'),('244026'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244023'),('244023'),('244023'),('244023'),('244023'),('244023'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('082046'),('082046'),('082046'),('082046'),('082047'),('082047'),('082048'),('082048'),('126015'),('126015'),('126016'),('126016'),('126016'),('126016'),('126016'),('416005'),('421001'),('421001'),('421002'),('016037'),('016037'),('016037'),('016037'),('016036'),('016036'),('016036'),('016036'),('115124'),('115124'),('115126'),('240049'),('240049'),('240048'),('240048'),('240047'),('240047'),('240046'),('240046'),('240045'),('240044'),('244032'),('244033'),('422002'),('422004'),('422004'),('422004'),('422005'),('422005'),('184013'),('184013'),('184013'),('805001'),('805002'),('805003'),('805004'),('805005'),('056024'),('056024'),('056024'),('423001'),('344010'),('235009'),('235009'),('235009'),('235009'),('212014'),('212014'),('056025'),('056025'),('056025'),('056026'),('056026'),('056026'),('056026'),('056026'),('056026'),('244034'),('244034'),('244034'),('244034'),('244034'),('244034'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('203015'),('245002'),('245002'),('245001'),('245001'),('056029'),('056030'),('056032'),('424001'),('056034'),('056034'),('056034'),('056034'),('056033'),('056033'),('056033'),('805006'),('805007'),('805008'),('805009'),('805010'),('422008'),('422008'),('422007'),('422007'),('422006'),('422006'),('422010'),('422009'),('422009'),('422011'),('422011'),('209004'),('209004'),('150022'),('100002'),('056035'),('056035'),('056035'),('023036'),('023036'),('185005'),('246001'),('246001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247002'),('247002'),('425001'),('416006'),('416006'),('165042'),('165041'),('165040'),('165043'),('010040'),('010039'),('010038'),('010036'),('248001'),('248002'),('248003'),('248004'),('248005'),('249001'),('249003'),('249004'),('249005'),('250007'),('250001'),('250002'),('250003'),('250004'),('250005'),('250006'),('250008'),('250009'),('250010'),('250011'),('250012'),('250013'),('251001'),('251002'),('806001'),('806002'),('235010'),('243009'),('249007'),('249008'),('249009'),('011024'),('011025'),('429001'),('429001'),('429002'),('429002'),('429003'),('429003');
-select field from t1 group by field;
-drop table t1;
-
-#
-# test of problem with date fields
-#
-create table t1 (a char(16), b date, c datetime);
-insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
-select * from t1 where c = '2000-01-01';
-select * from t1 where b = '2000-01-01';
-drop table t1;
-
-#
-# Test of delete when the delete will cause a node to disappear and reappear
-# (This assumes a block size of 1024)
-#
-
-create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
-insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
-delete from t1 where a=26;
-drop table t1;
-create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
-insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
-delete from t1 where a=27;
-drop table t1;
-
-#
-# Test of ORDER BY (By found by Dean Edmonds)
-#
-
-create table t1 (ID int not null primary key, TransactionID int not null);
-insert into t1 (ID, TransactionID) values  (1,  87), (2,  89), (3,  92), (4,  94), (5,  486), (6,  490), (7,  753), (9,  828), (10, 832), (11, 834), (12, 840);
-create table t2 (ID int not null primary key, GroupID int not null);
- insert into t2 (ID, GroupID) values (87,  87), (89,  89), (92,  92), (94,  94), (486, 486), (490, 490),(753, 753), (828, 828), (832, 832), (834, 834), (840, 840);
-create table t3 (ID int not null primary key, DateOfAction date not null);
-insert into t3 (ID, DateOfAction) values  (87,  '1999-07-19'), (89,  '1999-07-19'), (92,  '1999-07-19'), (94,  '1999-07-19'), (486, '1999-07-18'), (490, '2000-03-27'), (753, '2000-03-28'), (828, '1999-07-27'), (832, '1999-07-27'),(834, '1999-07-27'), (840, '1999-07-27');
-select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t3.DateOfAction, t1.TransactionID; 
-select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t1.TransactionID,t3.DateOfAction; 
-drop table t1,t2,t3;
-
-#
-# Test of found bug in group on text key
-#
-
-CREATE TABLE t1 (
-       f1 int(11) DEFAULT '0' NOT NULL,
-       f2 varchar(16) DEFAULT '' NOT NULL,
-       f5 text,
-       KEY index_name (f1,f2,f5(16))
-    );
-INSERT INTO t1 VALUES (0,'traktor','1111111111111');
-INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
-select count(*) from t1 where f2='traktor';
-drop table t1;
-
-#
-# Test of lock tables
-#
-
-create table t1 ( n int auto_increment primary key);
-lock tables t1 write;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 read, t1 as t2 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 write, t1 as t2 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 write, t1 as t2 read, t1 as t3 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 write, t1 as t2 write;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-drop table t1;
-
-#
-# Test of procedure
-#
-
-create table t1 (i int, j int);
-insert into t1 values (1,2), (3,4), (5,6), (7,8);
-select * from t1 procedure analyse();
-create table t2 select * from t1 procedure analyse();
-select * from t2;
-drop table t1,t2;
-
-#
-# Bug when using comparions of strings and integers.
-#
-
-CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
-insert into t1 values ('000000000001'),('000000000002');
-explain select * from t1 where id=000000000001;
-select * from t1 where id=000000000001;
-delete from t1 where id=000000000002;
-select * from t1;
-drop table t1;
-
-#
-# Test of DATE_ADD
-#
-
-CREATE TABLE t1 (
-  visitor_id int(10) unsigned DEFAULT '0' NOT NULL,
-  group_id int(10) unsigned DEFAULT '0' NOT NULL,
-  hits int(10) unsigned DEFAULT '0' NOT NULL,
-  sessions int(10) unsigned DEFAULT '0' NOT NULL,
-  ts timestamp(14),
-  PRIMARY KEY (visitor_id,group_id)
-)/*! type=MyISAM */;
-INSERT INTO t1 VALUES (465931136,7,2,2,20000318160952);
-INSERT INTO t1 VALUES (173865424,2,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,8,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,39,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,7,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,3,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,6,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,60,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,1502,2,2,20000318233615);
-INSERT INTO t1 VALUES (48985536,2,2,2,20000319013932);
-INSERT INTO t1 VALUES (48985536,8,2,2,20000319013932);
-INSERT INTO t1 VALUES (48985536,39,2,2,20000319013932);
-INSERT INTO t1 VALUES (48985536,7,2,2,20000319013932);
-INSERT INTO t1 VALUES (465931136,3,2,2,20000318160951);
-INSERT INTO t1 VALUES (465931136,119,1,1,20000318160953);
-INSERT INTO t1 VALUES (465931136,2,1,1,20000318160950);
-INSERT INTO t1 VALUES (465931136,8,1,1,20000318160950);
-INSERT INTO t1 VALUES (465931136,39,1,1,20000318160950);
-INSERT INTO t1 VALUES (1092858576,14,1,1,20000319013445);
-INSERT INTO t1 VALUES (357917728,3,2,2,20000319145026);
-INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
-select visitor_id,max(ts) as mts from t1 group by visitor_id
-having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
-select visitor_id,max(ts) as mts from t1 group by visitor_id
-having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
-drop table t1;
-
-#
-# Test of rename table
-#
-
-create table t0 SELECT 1,"table 1";
-create table t2 SELECT 2,"table 2";
-create table t3 SELECT 3,"table 3";
-rename table t0 to t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
-select * from t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
-select * from t1;
-# The following should give errors;
-rename table t1 to t2;
-rename table t1 to t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2;
-show tables like "t_";
-rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1;
-rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
-
-select * from t1;
-select * from t2;
-select * from t3;
-drop table if exists t1,t2,t3,t4;
-
-#
-# Test bug with long primary key
-#
-
-create table t1
-(
-   SEQNO                         numeric(12 ) not null,
-   MOTYPEID                 numeric(12 ) not null,
-   MOINSTANCEID     numeric(12 ) not null,
-   ATTRID                       numeric(12 ) not null,
-   VALUE                         varchar(120) not null,
-   primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE )
-);
-INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); 
-INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); 
-INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');  # This should give an error
-drop table t1;
-
-#
-# Test of database indirection
-#
-
-use kf96;
-
-create table test.t1 (a int);
-insert into test.t1 values(1);
-update test.t1 set a=2 where a=1;
-delete from test.t1;
-use test;
-alter table t1 add b int, rename ok.t2;
-lock table ok.t2 WRITE;
-alter table ok.t2 rename ok.t3;
-lock table ok.t3 WRITE;
-alter table ok.t3 rename test.t4;
-drop table t4;
-UNLOCK TABLES;
-
-select count(ok.station.stationsnr) from ok.station;
-
-#
-# Test create and destroy of databases
-#
-
-create database bench_test;
-create table bench_test.test (a int);
-drop database bench_test;
-create database bench_test;
-create table bench_test.test (a int) raid_type=1;
-drop database bench_test;
-
-#
-# These should give errors:
-#
-create table gurgel.test (a int);
-select count(ok.station.stationsnr) from station;
-select count(station.stationsnr) from test.station;
-select count(gurgel.station.stationsnr) from ok.station;
-select count(gurgel.station.stationsnr) from gurgel.station;
-select 1 from ok.station order by 2;
-select 1 from ok.station group by 2;
-select 1 from ok.station order by ok.station.gurgel;
-select count(*),stationsnr from ok.station;
-create table `a/a` (a int);
-create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
-create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
-
-#
-# Test of REPLACE with ISAM and MyISAM
-#
-
-CREATE TABLE t1 (
-  gesuchnr int(11) DEFAULT '0' NOT NULL,
-  benutzer_id int(11) DEFAULT '0' NOT NULL,
-  TitelGesuch varchar(60) DEFAULT '' NOT NULL,
-  text text DEFAULT '' NOT NULL,
-  seconds int(11) DEFAULT '0' NOT NULL,
-  neu char(1) DEFAULT '' NOT NULL,
-  eingang date DEFAULT '0000-00-00' NOT NULL,
-  bewerber_id int(10) unsigned DEFAULT '0' NOT NULL,
-  server_id tinyint(4) DEFAULT '0' NOT NULL,
-  deleted char(1) DEFAULT '' NOT NULL,
-  KEY berwerber_id (bewerber_id),
-  PRIMARY KEY (gesuchnr,benutzer_id),
-  KEY benutzer_id (benutzer_id)
-) type=ISAM;
-
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-alter table t1 type=myisam;
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-drop table t1;
-
-#
-# test of MERGE
-#
-create table t1 (a int not null primary key auto_increment, message char(20));
-create table t2 (a int not null primary key auto_increment, message char(20));
-INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
-INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
-create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(t1,t2);
-select * from t3;
-select * from t3 order by a desc;
-drop table t3;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(t1,t2);
-explain select * from t3 where a < 10;
-explain select * from t3 where a > 10 and a < 20;
-select * from t3 where a = 10;
-select * from t3 where a < 10;
-select * from t3 where a > 10 and a < 20;
-explain select a from t3 order by a desc limit 10;
-select a from t3 order by a desc limit 10;
-select a from t3 order by a desc limit 300,10;
-
-# The following should give errors
-create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
-
-drop table if exists t1,t2,t3,t4;
-
-create table t1 (c char(10)) type=myisam;
-create table t2 (c char(10)) type=myisam;
-create table t3 (c char(10)) union=(t1,t2) type=merge;
-insert into t1 (c) values ('test1');
-insert into t1 (c) values ('test1');
-insert into t1 (c) values ('test1');
-insert into t2 (c) values ('test2');
-insert into t2 (c) values ('test2');
-insert into t2 (c) values ('test2');
-select * from t3;
-flush tables;
-select * from t3;
-delete from t3;
-select * from t3;
-select * from t1;
-drop table t3,t2,t1;
-
-#
-# Test of fulltext
-#
-CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
-INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),('Full-text indexes', 'are called collections'),('Only MyISAM tables','support collections'),('Function MATCH ... AGAINST()','is used to do a search'),('Full-text search in MySQL', 'implements vector space model');
-select * from t1 where MATCH(a,b) AGAINST ("collections");
-select * from t1 where MATCH(a,b) AGAINST ("indexes");
-select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
-delete from t1 where a like "MySQL%";
-drop table t1;
-
-#
-# Test of Berkeley DB
-#
-
-CREATE TABLE t1 (
-  id int(11) NOT NULL auto_increment,
-  parent_id int(11) DEFAULT '0' NOT NULL,
-  level tinyint(4) DEFAULT '0' NOT NULL,
-  PRIMARY KEY (id),
-  KEY parent_id (parent_id),
-  KEY level (level)
-) type=bdb;
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
-update t1 set parent_id=parent_id+100;
-select * from t1 where parent_id=102;
-update t1 set id=id+1000;
-update t1 set id=1024 where id=1009; 
-select * from t1;
-update ignore t1 set id=id+1; # This will change all rows
-select * from t1;
-update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
-drop table t1;
-
-create table t1 (n int not null primary key) type=bdb;
-set autocommit=0;
-insert into t1 values (4);
-select n, "before rollback" from t1;
-rollback;
-select n, "after rollback" from t1;
-insert into t1 values (4);
-select n, "before commit" from t1;
-commit;
-select n, "after commit" from t1;
-commit;
-drop table t1;
-set autocommit=1;
-
-CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) TYPE=BDB;
-INSERT INTO t1 VALUES (1, 'Jochen');
-select * from t1;
-drop table t1;
-
-CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) TYPE=BDB;
-set autocommit=0;
-INSERT INTO t1  SET _userid='marc@anyware.co.uk';
-COMMIT;
-SELECT * FROM t1;
-SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
-drop table t1;
-set autocommit=1;
-
-CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=bdb;
-insert into t1 values ('pippo', 12);
-insert into t1 values ('pippo', 12); # Gives error
-delete from t1;
-delete from t1 where id = 'pippo';
-select * from t1;
-
-insert into t1 values ('pippo', 12);
-set autocommit=0;
-delete from t1;
-rollback;
-select * from t1;
-delete from t1;
-commit;
-select * from t1;
-drop table t1;
-set autocommit=1;
-
-#
-# Test when reading on part of unique key
-#
-CREATE TABLE t1 (
-  user_id int(10) DEFAULT '0' NOT NULL,
-  name varchar(100),
-  phone varchar(100),
-  ref_email varchar(100) DEFAULT '' NOT NULL,
-  detail varchar(200),
-  PRIMARY KEY (user_id,ref_email)
-)type=bdb;
-
-INSERT INTO t1 VALUES (10292,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10292,'shirish','2333604','shirish@yahoo.com','ddsds'),(10292,'sonali','323232','sonali@bolly.com','filmstar');
-select * from t1 where user_id=10292;
-INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
-select * from t1 where user_id=10292;
-select * from t1 where user_id>=10292;
-select * from t1 where user_id>10292;
-select * from t1 where user_id<10292;
-drop table t1;
-
-#
-# Test of ALTER TABLE and BDB tables
-#
-
-create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
-alter table t1 type=BDB;
-insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
-select * from t1;
-update t1 set col2='7' where col1='4';
-select * from t1;
-alter table t1 add co3 int not null;
-select * from t1;
-update t1 set col2='9' where col1='2';
-select * from t1;
-drop table t1;
-
-#
-# INSERT INTO BDB tables
-#
-
-create table t1 (a int not null , b int, primary key (a)) type = BDB;
-create table t2 (a int not null , b int, primary key (a)) type = myisam;
-insert into t1 VALUES (1,3) , (2,3), (3,3);
-select * from t1;
-insert into t2 select * from t1;
-select * from t2;
-delete from t1 where b = 3;
-select * from t1;
-insert into t1 select * from t2;
-select * from t1;
-select * from t2;
-drop table t1,t2;
-
-#
-# Search on unique key
-#
-
-CREATE TABLE t1 (
-  id int(11) NOT NULL auto_increment,
-  ggid varchar(32) binary DEFAULT '' NOT NULL,
-  email varchar(64) DEFAULT '' NOT NULL,
-  passwd varchar(32) binary DEFAULT '' NOT NULL,
-  PRIMARY KEY (id),
-  UNIQUE ggid (ggid)
-) TYPE=BDB;
-
-insert into t1 (ggid,passwd) values ('test1','xxx');
-insert into t1 (ggid,passwd) values ('test2','yyy');
-
-select * from t1 where ggid='test1';
-select * from t1 where passwd='xxx';
-select * from t1 where id=2;
-drop table t1;
-
-#
-# ORDER BY on not primary key
-#
-
-CREATE TABLE t1 (
-  user_name varchar(12),
-  password text,
-  subscribed char(1),
-  user_id int(11) DEFAULT '0' NOT NULL,
-  quota bigint(20),
-  weight double,
-  access_date date,
-  access_time time,
-  approved datetime,
-  dummy_primary_key int(11) NOT NULL auto_increment,
-  PRIMARY KEY (dummy_primary_key)
-) TYPE=BDB;
-INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
-INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
-INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
-INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
-INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
-select  user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
-drop table t1;
diff --git a/mysql-test/r/gemini.result b/mysql-test/r/gemini.result
index 46e14d3eee6..0b43b4f5192 100644
--- a/mysql-test/r/gemini.result
+++ b/mysql-test/r/gemini.result
@@ -362,3 +362,9 @@ _userid
 marc@anyware.co.uk
 _userid
 marc@anyware.co.uk
+f1
+65
+379
+468
+469
+508
diff --git a/mysql-test/std_data/gemini.dat b/mysql-test/std_data/gemini.dat
new file mode 100644
index 00000000000..c2e1045f5ac
--- /dev/null
+++ b/mysql-test/std_data/gemini.dat
@@ -0,0 +1,5 @@
+65,-1,1
+379,-1,1
+468,-1,1
+469,-1,1
+508,-1,1  
diff --git a/mysql-test/t/gemini.test b/mysql-test/t/gemini.test
index 3bbd4d4f23d..9d4451c3551 100644
--- a/mysql-test/t/gemini.test
+++ b/mysql-test/t/gemini.test
@@ -338,3 +338,18 @@ SELECT * FROM t1;
 SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
 drop table t1;
 set autocommit=1;
+
+#
+# Test of load data infile
+#
+
+CREATE TABLE if not exists `t1` (
+  `f1` int(11) unsigned NOT NULL default '0',
+  `f2` tinyint(3) unsigned NOT NULL default '0',
+  `f3` tinyint(3) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`f1`)
+) TYPE=Gemini;
+lock table t1 write;
+load data infile ''../../std_data/gemini.dat' ignore into table t1 fields terminated by ',';
+select f1 from t1;
+drop table t1;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 274b1814674..9d3b899d31b 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -71,6 +71,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   String *field_term=ex->field_term,*escaped=ex->escaped,
     *enclosed=ex->enclosed;
   bool is_fifo=0;
+  bool using_transactions;
+
   DBUG_ENTER("mysql_load");
 
   if (escaped->length() > 1 || enclosed->length() > 1)
@@ -239,8 +241,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   free_blobs(table);				/* if pack_blob was used */
   table->copy_blobs=0;
   thd->count_cuted_fields=0;			/* Don`t calc cuted fields */
+  using_transactions = table->file->has_transactions();
   if (error)
-    DBUG_RETURN(-1);				// Error on read
+  {
+    if (using_transactions)
+      ha_autocommit_or_rollback(thd,error);
+    DBUG_RETURN(-1);                           // Error on read
+  }
   sprintf(name,ER(ER_LOAD_INFO),info.records,info.deleted,
 	  info.records-info.copied,thd->cuted_fields);
   send_ok(&thd->net,info.copied+info.deleted,0L,name);
@@ -248,7 +255,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   if(!thd->slave_thread)
     mysql_update_log.write(thd,thd->query,thd->query_length);
   
-  if (!table->file->has_transactions())
+  if (!using_transactions)
     thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
   if (!read_file_from_client && mysql_bin_log.is_open())
   {
@@ -257,7 +264,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
 			 handle_duplicates);
     mysql_bin_log.write(&qinfo);
   }
-  DBUG_RETURN(0);
+  if (using_transactions)
+    error=ha_autocommit_or_rollback(thd,error); 
+  DBUG_RETURN(error);
 }
 
 
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 71ee60e1eca..5869feefdc3 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -182,6 +182,8 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
   TABLE_LIST table_list;
   DBUG_ENTER("mysql_find_files");
 
+  if (wild && !wild[0])
+    wild=0;
   bzero((char*) &table_list,sizeof(table_list));
 
   if (!(dirp = my_dir(path,MYF(MY_WME | (dir ? MY_WANT_STAT : 0)))))
@@ -200,7 +202,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
 #endif
       {
         if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat.st_mode) ||
-            (wild && wild[0] && wild_compare(file->name,wild)))
+            (wild && wild_compare(file->name,wild)))
           continue;
       }
     }
@@ -211,8 +213,16 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
           is_prefix(file->name,tmp_file_prefix))
         continue;
       *ext=0;
-      if (wild && wild[0] && wild_compare(file->name,wild))
-        continue;
+      if (wild)
+      {
+	if (lower_case_table_names)
+	{
+	  if (wild_case_compare(file->name,wild))
+	    continue;
+	}
+	else if (wild_compare(file->name,wild))
+	  continue;
+      }
     }
     /* Don't show tables where we don't have any privileges */
     if (db && !(col_access & TABLE_ACLS))
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 174d07d8ec4..e6cdd089bf1 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -542,8 +542,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
 #endif
 
 int wild_case_compare(const char *str,const char *str_end,
-			     const char *wildstr,const char *wildend,
-			     char escape)
+		      const char *wildstr,const char *wildend,
+		      char escape)
 {
   int result= -1;				// Not found, using wildcards
 #ifdef USE_MB
@@ -677,7 +677,7 @@ int wild_case_compare(String &match,String &wild, char escape)
 */
 
 int wild_compare(const char *str,const char *str_end,
-			const char *wildstr,const char *wildend,char escape)
+		 const char *wildstr,const char *wildend,char escape)
 {
   int result= -1;				// Not found, using wildcards
   while (wildstr != wildend)

From e39aaf80738a21402eadf09eb42576bbb47fac0b Mon Sep 17 00:00:00 2001
From: unknown <tim@white.box>
Date: Tue, 28 Aug 2001 18:48:13 -0400
Subject: [PATCH 28/51] Update the SCO (now Caldera)/SysV tests.  This should
 allow OpenUnix8 to work automatically.  Thanks to Boyd Lynn Gerber for the
 patch.

---
 config.guess |  68 ++++--------------
 config.sub   | 198 ++++++++++++++++++++++++++++++++++++++-------------
 configure.in |  53 +++++++++++++-
 ltconfig     |  25 +++++++
 4 files changed, 238 insertions(+), 106 deletions(-)

diff --git a/config.guess b/config.guess
index eb88894019f..a3369c0f908 100755
--- a/config.guess
+++ b/config.guess
@@ -790,7 +790,7 @@ EOF
     i?86:DYNIX/ptx:4*:*)
 	echo i386-sequent-sysv4
 	exit 0 ;;
-    i?86:UNIX_SV:4.2MP:2.*)
+    i*86:UNIX_SV:4.2MP:2.*)
         # Unixware is an offshoot of SVR4, but it has its own version
         # number series starting with 2...
         # I am not positive that other SVR4 systems won't match this,
@@ -798,64 +798,24 @@ EOF
         # Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit 0 ;;
-    i?86:UnixWare:5:7)  # Unixware 7.0.0t (uname -v reports 7) has native threads
-        # uname -m incorrectly reports CPU type (uname -m reports i386 always)
-        # compiler supports following optimization flags:i386,i486,pentium,pentium_pro and blended
-        # compiler does NOT support: i586,i686,Pentium,Pentium Pro,pentiumpro,pentium_II or Pentium II
-	if /bin/uname machine 2>/dev/null >/dev/null ; then
-	  (/bin/uname machine|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-	  (/bin/uname machine|egrep 'Pentium' >/dev/null) && UNAME_MACHINE=pentium
-	  (/bin/uname machine|egrep 'Pentium Pro' >/dev/null) && UNAME_MACHINE=pentium_pro
-	  (/bin/uname machine|egrep 'Pentium II' >/dev/null) && UNAME_MACHINE=pentium_II
-	  echo ${UNAME_MACHINE}-pc-unixware7.0.0
-	else
-	  echo ${UNAME_MACHINE}-pc-unixware7.0.0
-	fi
-        exit 0 ;;
-    i?86:UnixWare:5:7.0.1)  # Unixware 7.0.1 (uname -v reports 7.0.1) has POSIX threads
-        # uname -m incorrectly reports CPU type (uname -m reports i386 always)
-        # compiler supports following optimization flags:i386,i486,pentium,pentium_pro and blended
-        # compiler does NOT support: i586,i686,Pentium,Pentium Pro,pentiumpro,pentium_II or Pentium II
-	if /bin/uname machine 2>/dev/null >/dev/null ; then
-	  (/bin/uname machine|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-	  (/bin/uname machine|egrep 'Pentium' >/dev/null) && UNAME_MACHINE=pentium
-	  (/bin/uname machine|egrep 'Pentium Pro' >/dev/null) && UNAME_MACHINE=pentium_pro
-	  (/bin/uname machine|egrep 'Pentium II' >/dev/null) && UNAME_MACHINE=pentium_II
-	  echo ${UNAME_MACHINE}-pc-unixware7.0.1
-	else
-	  echo ${UNAME_MACHINE}-pc-unixware7.0.1
-	fi
-        exit 0 ;;
-     # SysVr5/Unixware7
-     i?86:*:5*:* | i?86:SYSTEM_V:5*:*)
-        if uname -a | grep SCO >/dev/null 2>/dev/null ; then
-          (/bin/uname -s|egrep UnixWare >/dev/null) && UNAME_VER=uw${UNAME_VERSION}
-          if /bin/uname -X 2>/dev/null >/dev/null ; then
-            (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-            (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
-          fi
-          echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}${UNAME_VER}
-        else
-          echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
-        fi
-        exit 0 ;;
-
-    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+        UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
 	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
 	else
-		echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
 	fi
 	exit 0 ;;
-    i?86:*:5:7*)
-	UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
-	(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-	(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
-	(/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686
-	(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585
-	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+    i*86:*:5:[78]*)
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+
 	exit 0 ;;
-    i?86:*:3.2:*)
+    i*86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
 		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
 		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
diff --git a/config.sub b/config.sub
index 8f28d3f7be8..70716b4e206 100755
--- a/config.sub
+++ b/config.sub
@@ -45,23 +45,66 @@
 #	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
 # It is wrong to echo any other type of specification.
 
-if [ x$1 = x ]
-then
-	echo Configuration name missing. 1>&2
-	echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
-	echo "or     $0 ALIAS" 1>&2
-	echo where ALIAS is a recognized configuration type. 1>&2
-	exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
 
-# First pass through any local machine types.
-case $1 in
-	*local*)
-		echo $1
-		exit 0
-		;;
-	*)
-	;;
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
 esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
@@ -168,27 +211,40 @@ esac
 case $basic_machine in
 	# Recognize the basic CPU types without company name.
 	# Some are omitted here because they have special meanings below.
-	tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
-		| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+	        | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+		| pyramid | mn10200 | mn10300 | tron | a29k \
 		| 580 | i960 | h8300 \
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle \
 		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
-		| alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
-		| we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
-		| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
+		| we32k | ns16k | clipper | i370 | sh | sh[34] \
+		| powerpc | powerpcle \
+		| 1750a | dsp16xx | pdp10 | pdp11 \
+		| mips16 | mips64 | mipsel | mips64el \
 		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
 		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
-		| mips64vr5000 | miprs64vr5000el \
-		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
-		| thumb | d10v)
+		| mips64vr5000 | mips64vr5000el | mcore | s390 | s390x \
+		| sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
+		| v850 | c4x \
+		| thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
+		| pj | pjl | h8500 | z8k)
 		basic_machine=$basic_machine-unknown
 		;;
-	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65)
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
 		;;
 
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
-	i[34567]86)
+	i*86 | x86_64)
 	  basic_machine=$basic_machine-pc
 	  ;;
 	# Object if more than one company name word.
@@ -197,23 +253,31 @@ case $basic_machine in
 		exit 1
 		;;
 	# Recognize the basic CPU types with company name.
-	vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
-	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+	# FIXME: clean up the formatting here.
+	vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+	      | arm-*  | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
 	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
 	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
 	      | xmp-* | ymp-* \
-	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
-	      | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
 	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
 	      | clipper-* | orion-* \
-	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
-	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+	      | sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \
+	      | powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
+	      | mips16-* | mips64-* | mipsel-* \
 	      | mips64el-* | mips64orion-* | mips64orionel-* \
 	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
-	      | mipstx39-* | mipstx39el-* \
-	      | f301-* | armv*-* | t3e-* \
+	      | mipstx39-* | mipstx39el-* | mcore-* \
+	      | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
+	      | [cjt]90-* \
 	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
-	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | ia64-* )
+	      | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
+	      | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
@@ -431,22 +495,21 @@ case $basic_machine in
 		;;
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
-		os=-mvs
 		;;
 # I'm not sure what "Sysv32" means.  Should this be sysv3.2?
-	i[34567]86v32)
+	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
 		;;
-	i[34567]86v4*)
+	i*86v4*)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv4
 		;;
-	i[34567]86v)
+	i*86v)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv
 		;;
-	i[34567]86sol2)
+	i*86sol2)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-solaris2
 		;;
@@ -577,9 +640,16 @@ case $basic_machine in
 		basic_machine=i960-intel
 		os=-mon960
 		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
 	np1)
 		basic_machine=np1-gould
 		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
 	op50n-* | op60c-*)
 		basic_machine=hppa1.1-oki
 		os=-proelf
@@ -609,28 +679,28 @@ case $basic_machine in
         pc532 | pc532-*)
 		basic_machine=ns32k-pc532
 		;;
-	pentium | p5 | k5 | k6 | nexen)
+	pentium | p5 | k5 | k6 | nexgen)
 		basic_machine=i586-pc
 		;;
-	pentiumpro | p6 | 6x86)
+	pentiumpro | p6 | 6x86 | athlon)
 		basic_machine=i686-pc
 		;;
 	pentiumii | pentium2)
-		basic_machine=i786-pc
+		basic_machine=i686-pc
 		;;
-	pentium-* | p5-* | k5-* | k6-* | nexen-*)
+	pentium-* | p5-* | k5-* | k6-* | nexgen-*)
 		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
-	pentiumpro-* | p6-* | 6x86-*)
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
 		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pentiumii-* | pentium2-*)
-		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	pn)
 		basic_machine=pn-gould
 		;;
-	power)	basic_machine=rs6000-ibm
+	power)	basic_machine=power-ibm
 		;;
 	ppc)	basic_machine=powerpc-unknown
 	        ;;
@@ -645,6 +715,10 @@ case $basic_machine in
 	ps2)
 		basic_machine=i386-ibm
 		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
 	rom68k)
 		basic_machine=m68k-rom68k
 		os=-coff
@@ -855,6 +929,9 @@ case $basic_machine in
 		basic_machine=c4x-none
 		os=-coff
 		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
 	*)
 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
 		exit 1
@@ -917,14 +994,29 @@ case $os in
 	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -rhapsody* | -darwin* | -openstep* | -oskit*)
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
 	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
 	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
-	      | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 		;;
 	-mac*)
 		os=`echo $os | sed -e 's|mac|macos|'`
@@ -1225,3 +1317,11 @@ case $basic_machine in
 esac
 
 echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure.in b/configure.in
index f046251567a..60227701ac8 100644
--- a/configure.in
+++ b/configure.in
@@ -264,7 +264,16 @@ case "$target_os" in
        ;;
      esac
   ;;
-  sysv5uw7*) 
+  sysv5UnixWare*) 
+    if test "$GCC" != "yes"; then
+      # We are using built-in inline function
+      CFLAGS="$CFLAGS -Kalloca"
+      CXX="$CXX -DNO_CPLUSPLUS_ALLOCA"
+    else
+      CXX="$CXX -DNO_CPLUSPLUS_ALLOCA"
+    fi
+  ;;
+  sysv5OpenUNIX8*) 
     if test "$GCC" != "yes"; then
       # We are using built-in inline function
       CFLAGS="$CFLAGS -Kalloca"
@@ -274,7 +283,6 @@ case "$target_os" in
     fi
   ;;
 esac
-
 AC_SUBST(CC)
 AC_SUBST(CFLAGS)
 AC_SUBST(CXX)
@@ -990,7 +998,7 @@ fi
 if test "$with_named_thread" = "no"
 then
   AC_MSG_CHECKING("SCO UnixWare7 native threads")
-  if expr "$SYSTEM_TYPE" : ".*unixware7*" > /dev/null
+  if expr "$SYSTEM_TYPE" : ".*UnixWare*" > /dev/null
   then
     if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
     then
@@ -1020,6 +1028,45 @@ then
   fi
 fi
 
+# Hack for Caldera OpenUNIX8
+#
+if test "$with_named_thread" = "no"
+then
+  AC_MSG_CHECKING("OpenUNIX8 native threads")
+  if expr "$SYSTEM_TYPE" : ".*OpenUNIX*" > /dev/null
+  then
+    if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
+    then
+      MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
+      with_named_thread="-Kthread -lsocket -lnsl"
+      if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null
+      then
+#        AC_DEFINE(HAVE_OpenUNIX8_THREADS)
+        AC_DEFINE(HAVE_UNIXWARE7_THREADS)
+      else
+#        AC_DEFINE(HAVE_OpenUNIX8_POSIX)
+        AC_DEFINE(HAVE_UNIXWARE7_POSIX)
+      fi
+      # We must have cc
+      AC_MSG_CHECKING("for gcc")
+      if expr "$CC" : ".*gcc.*"
+      then
+	{ echo "configure: error: On OpenUNIX8 and UnixWare7 MySQL must be compiled with cc. See the Installation chapter in the Reference Manual." 1>&2; exit 1; };
+      else
+#	CC="$CC -Kthread -DOpenUNIX8";
+#	CXX="$CXX -Kthread -DOpenUNIX8";
+	CC="$CC -Kthread -DUNIXWARE_7";
+	CXX="$CXX -Kthread -DUNIXWARE_7";
+      fi
+      AC_MSG_RESULT("yes")
+    else
+      { echo "configure: error: Can't find thread libs on Caldera OpenUNIX 8. See the Installation chapter in the Reference Manual." 1>&2; exit 1; };
+    fi
+  else
+    AC_MSG_RESULT("no")
+  fi
+fi
+
 # Hack for Siemens UNIX
 if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
 then
diff --git a/ltconfig b/ltconfig
index 10d6a395719..18af7c4dce8 100755
--- a/ltconfig
+++ b/ltconfig
@@ -742,6 +742,12 @@ else
     wl='-Qoption ld '
     ;;
 
+   sysv5UnixWare* | sysv5OpenUNIX*)
+    pic_flag='-KPIC'
+    link_static_flag='-Bstatic'
+    wl='-Wl,'
+    ;;
+
   sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
     pic_flag='-KPIC'
     link_static_flag='-Bstatic'
@@ -1496,6 +1502,18 @@ else
     export_dynamic_flag_spec='-Bexport'
     ;;
 
+  sysv5UnixWare* | sysv5OpenUNIX*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$UW7_compile_command -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+    hardcode_libdir_flag_spec=
+    hardcode_shlibpath_var=no
+    runpath_var='LD_RUN_PATH'
+    ;;
+
   sysv5*)
     no_undefined_flag=' -z text'
     # $CC -shared without GNU ld will not create a library from C++
@@ -2097,6 +2115,13 @@ sunos4*)
   need_version=yes
   ;;
 
+sysv5UnixWare* | sysv5OpenUNIX*)
+  version_type=linux
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
   version_type=linux
   library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'

From 9dffefc40e712f1419ba216f09892db3798d6443 Mon Sep 17 00:00:00 2001
From: unknown <serg@serg.mysql.com>
Date: Wed, 29 Aug 2001 13:42:14 +0200
Subject: [PATCH 29/51] "freeing of unallocated pointer" bug fixed

---
 myisam/mi_check.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index fd327b96e6d..587f90e0929 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -1111,6 +1111,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
   SORT_INFO *sort_info= &param->sort_info;
   DBUG_ENTER("mi_repair");
 
+  sort_info->buff=sort_info->record=0;
   start_records=info->state->records;
   new_header_length=(param->testflag & T_UNPACK) ? 0L :
     share->pack.header_length;
@@ -1329,9 +1330,7 @@ err:
     }
     mi_mark_crashed_on_repair(info);
   }
-  if (sort_info->record)
-    my_free(sort_info->record,MYF(0));
-
+  my_free(sort_info->record,MYF(MY_ALLOW_ZERO_PTR));
   my_free(sort_info->buff,MYF(MY_ALLOW_ZERO_PTR));
   VOID(end_io_cache(&param->read_cache));
   info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);

From d46365fb0ffc1b04c8ff4bc6603028b8a493954a Mon Sep 17 00:00:00 2001
From: unknown <serg@serg.mysql.com>
Date: Wed, 29 Aug 2001 14:03:02 +0200
Subject: [PATCH 30/51] News-3.23.42 section updated

---
 Docs/manual.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 6e77f0110cd..b19717b7471 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46683,6 +46683,8 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixed coredump during REPAIR of some particulary broken tables.
+@item
 Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
 @item
 Applied large patch for OS/2 from Yuri Dario.

From 1143555835b07430f12d043cf50aaecb234d5bb8 Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Wed, 29 Aug 2001 16:40:00 +0300
Subject: [PATCH 31/51] ha_innobase.cc	Fix a bug in connection with SET
 INSERT_ID:caused repliaction to fail

sql/ha_innobase.cc:
  Fix a bug in connection with SET INSERT_ID:caused repliaction to fail
---
 sql/ha_innobase.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index fdbc0b107f5..be81bee7891 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -180,6 +180,50 @@ convert_error_code_to_mysql(
     	}
 }
 
+extern "C" {
+/*****************************************************************
+Prints info of a THD object (== user session thread) to the
+standatd output. NOTE that mysql/innobase/trx/trx0trx.c must contain
+the prototype for this function! */
+
+void
+innobase_mysql_print_thd(
+/*=====================*/
+        void* input_thd)/* in: pointer to a MySQL THD object */
+{
+  THD*  thd;
+
+  thd = (THD*) input_thd;
+
+  printf("MySQL thread id %lu, query id %lu",
+	 thd->thread_id, thd->query_id);
+  
+  if (thd->host) {
+    printf(" %s", thd->host);
+  }
+
+  if (thd->ip) {
+    printf(" %s", thd->ip);
+  }
+
+  if (thd->user) {
+    printf(" %s", thd->user);
+  }
+
+  if (thd->proc_info) {
+    printf(" %s", thd->proc_info);
+  }
+
+  if (thd->query) {
+    printf(" %50.50s", thd->query);
+  }
+
+  
+
+  printf("\n");
+}
+}
+
 /*************************************************************************
 Gets the InnoDB transaction handle for a MySQL handler object, creates
 an InnoDB transaction struct if the corresponding MySQL thread struct still
@@ -199,6 +243,8 @@ check_trx_exists(
 	        dbug_assert(thd != NULL);
 		trx = trx_allocate_for_mysql();
 
+		trx->mysql_thd = thd;
+
 		thd->transaction.all.innobase_tid = trx;
 
 		/* The execution of a single SQL statement is denoted by
@@ -633,7 +679,7 @@ innobase_commit(
 
 	if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) {
 		trx_commit_for_mysql(trx);
-		trx_mark_sql_stat_end(trx);
+		trx_mark_sql_stat_end_do_not_start_new(trx);
 	} else {
 		trx_mark_sql_stat_end(trx);
 	}
@@ -672,6 +718,7 @@ innobase_rollback(
 
 	if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) {
 		error = trx_rollback_for_mysql(trx);
+		trx_mark_sql_stat_end_do_not_start_new(trx);
 	} else {
 		error = trx_rollback_last_sql_stat_for_mysql(trx);
 		trx_mark_sql_stat_end(trx);
@@ -1335,6 +1382,15 @@ ha_innobase::write_row(
 	        
 	        auto_inc = table->next_number_field->val_int();
 
+		/* In replication and also otherwise the auto-inc column 
+		can be set with SET INSERT_ID. Then we must look at
+		user_thd->next_insert_id. If it is nonzero and the user
+		has not supplied a value, we must use it. */
+
+		if (auto_inc == 0 && user_thd->next_insert_id != 0) {
+		        auto_inc = user_thd->next_insert_id;
+		}
+
 		if (auto_inc != 0) {
 			/* This call will calculate the max of the
 			current value and the value supplied by the user, if

From 1241395fce6c953f38b5940978593f3705e2666d Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Wed, 29 Aug 2001 17:33:41 +0300
Subject: [PATCH 32/51] Test that all MERGE tables comes from the same database

Docs/manual.texi:
  Changelog and more documentation about ALTER TABLE
include/mysqld_error.h:
  New error message
mysql-test/t/merge.test:
  Test of error conditions
sql/gen_lex_hash.cc:
  Smaller array
sql/ha_myisammrg.cc:
  Cleanup
sql/share/czech/errmsg.txt:
  New message
sql/share/danish/errmsg.txt:
  New message
sql/share/dutch/errmsg.txt:
  New message
sql/share/english/errmsg.txt:
  New message
sql/share/estonian/errmsg.txt:
  New message
sql/share/french/errmsg.txt:
  New message
sql/share/german/errmsg.txt:
  New message
sql/share/greek/errmsg.txt:
  New message
sql/share/hungarian/errmsg.txt:
  New message
sql/share/italian/errmsg.txt:
  New message
sql/share/japanese/errmsg.txt:
  New message
sql/share/korean/errmsg.txt:
  New message
sql/share/norwegian-ny/errmsg.txt:
  New message
sql/share/norwegian/errmsg.txt:
  New message
sql/share/polish/errmsg.txt:
  New message
sql/share/portuguese/errmsg.txt:
  New message
sql/share/romanian/errmsg.txt:
  New message
sql/share/russian/errmsg.txt:
  New message
sql/share/slovak/errmsg.txt:
  New message
sql/share/spanish/errmsg.txt:
  New message
sql/share/swedish/errmsg.txt:
  New message
---
 Docs/manual.texi                  | 40 ++++++++++++++++++++++++-------
 include/mysqld_error.h            |  3 ++-
 mysql-test/t/merge.test           |  6 ++++-
 sql/gen_lex_hash.cc               |  2 +-
 sql/ha_myisammrg.cc               |  6 -----
 sql/share/czech/errmsg.txt        |  1 +
 sql/share/danish/errmsg.txt       |  1 +
 sql/share/dutch/errmsg.txt        |  1 +
 sql/share/english/errmsg.txt      |  1 +
 sql/share/estonian/errmsg.txt     |  1 +
 sql/share/french/errmsg.txt       |  1 +
 sql/share/german/errmsg.txt       |  1 +
 sql/share/greek/errmsg.txt        |  1 +
 sql/share/hungarian/errmsg.txt    |  1 +
 sql/share/italian/errmsg.txt      |  1 +
 sql/share/japanese/errmsg.txt     |  1 +
 sql/share/korean/errmsg.txt       |  1 +
 sql/share/norwegian-ny/errmsg.txt |  1 +
 sql/share/norwegian/errmsg.txt    |  1 +
 sql/share/polish/errmsg.txt       |  1 +
 sql/share/portuguese/errmsg.txt   |  1 +
 sql/share/romanian/errmsg.txt     |  1 +
 sql/share/russian/errmsg.txt      |  1 +
 sql/share/slovak/errmsg.txt       |  1 +
 sql/share/spanish/errmsg.txt      |  1 +
 sql/share/swedish/errmsg.txt      |  1 +
 sql/sql_parse.cc                  | 12 ++++++++--
 27 files changed, 71 insertions(+), 19 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 6e77f0110cd..a54b3327e17 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -4502,6 +4502,13 @@ Minimum respective maximum possible @code{double} value.
 
 @item
 @code{LIMIT} on negative numbers are treated as big positive numbers.
+@item
+If you use @code{ALTER TABLE} to first add an @code{UNIQUE} index to a
+table used in a @code{MERGE} table and then use @code{ALTER TABLE} to
+add a normal index on the @code{MERGE} table, the key order will be
+different for the tables if there was an old not-unique key in the
+table. This is because @code{ALTER TABLE} puts @code{UNIQUE} keys before
+normal keys to be able to detect duplicate keys as early as possible.
 @end itemize
 
 The following are known bugs in earlier versions of MySQL:
@@ -11688,9 +11695,9 @@ work:
 
 @example
 CC="cc -pthread"
-CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host"
+CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
 CXX="cxx -pthread"
-CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host"
+CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
 export CC CFLAGS CXX CXXFLAGS
 ./configure \
 --prefix=/usr/local/mysql \
@@ -34149,6 +34156,12 @@ index exists, it drops the first @code{UNIQUE} index in the table.
 (MySQL marks the first @code{UNIQUE} key as the @code{PRIMARY KEY}
 if no @code{PRIMARY KEY} was specified explicitly.)
 
+@findex UNIQUE
+@findex PRIMARY KEY
+If you add a @code{UNIQUE INDEX} or @code{PRIMARY KEY} to a table, this
+is stored before any not @code[UNIQUE} index so that MySQL can detect
+duplicate keys as early as possible.
+
 @findex ORDER BY
 @item
 @code{ORDER BY} allows you to create the new table with the rows in a
@@ -35558,14 +35571,15 @@ mapped tables. (We plan to fix this in 4.0).
 
 With identical tables we mean that all tables are created with identical
 column and key information.  You can't put a MERGE over tables where the
-columns are packed differently or doesn't have exactly the same columns.
-Some of the tables can however be compressed with @code{myisampack}.
-@xref{myisampack}.
+columns are packed differently, doesn't have exactly the same columns or
+have the keys in different order.  Some of the tables can however be
+compressed with @code{myisampack}.  @xref{myisampack}.
 
 When you create a @code{MERGE} table, you will get a @code{.frm} table
 definition file and a @code{.MRG} table list file.  The @code{.MRG} just
 contains a list of the index files (@code{.MYI} files) that should
-be used as one.
+be used as one.  All used tables must be in the same database as the
+@code{MERGE} table itself.
 
 For the moment you need to have @code{SELECT}, @code{UPDATE}, and
 @code{DELETE} privileges on the tables you map to a @code{MERGE} table.
@@ -35691,7 +35705,6 @@ Change the @code{.MRG} file and issue a @code{FLUSH TABLE} on the
 read the new definition file.
 @end itemize
 
-
 @node ISAM, HEAP, MERGE, Table types
 @section ISAM Tables
 
@@ -46683,15 +46696,26 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Enforce that all tables in a @code{MERGE} table comes from the same
+database.
+@item
+Fixed bug with @code{LOAD DATA INFILE} and transactional tables.
+@item
+Fix bug when using @code{INSERT DELAYED} with wrong column definition.
+@item
 Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
 @item
+Fixed critical bug in @code{InnoDB} and @code{BLOB}'s.  If one has used
+@code{BLOB}'s larger than 8K in an @code{InnoDB} table one must dump
+the table with @code{mysqldump}, drop it and restore it from the dump.
+@item
 Applied large patch for OS/2 from Yuri Dario.
 @item
 Fixed problem with InnoDB when one could get the error @code{Can't
 execute the given command...} even when one didn't have an active
 transaction.
 @item
-Applied some fixes for Gemini.
+Applied some minor fixes that concerns Gemini.
 @item
 Use real arithmetic operations even in integer context if not
 all arguments are integers. (Fixes uncommon bug in some integer
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 758c74fc122..08e621f4a2a 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -212,4 +212,5 @@
 #define ER_CREATE_DB_WITH_READ_LOCK 1209
 #define ER_WRONG_ARGUMENTS 1210
 #define ER_NO_PERMISSON_TO_CREATE_USER 1211
-#define ER_ERROR_MESSAGES 212
+#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
+#define ER_ERROR_MESSAGES 213
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 59da525990c..6820242d562 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -35,9 +35,13 @@ show create table t3;
 
 # The following should give errors
 create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
+--error 1016
+select * from t4;
+--error 1212
+create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
 
 # Because of windows, it's important that we drop the merge tables first!
-drop table if exists t4,t3,t1,t2;
+drop table if exists t5,t4,t3,t1,t2;
 
 create table t1 (c char(10)) type=myisam;
 create table t2 (c char(10)) type=myisam;
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index d55197a8b60..e05fdafcbc4 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -472,7 +472,7 @@ int main(int argc,char **argv)
   int error;
 
   MY_INIT(argv[0]);
-  start_value=4597269L;  best_t1=6001982L;  best_t2=5063828L;  best_type=4; /* mode=4513  add=8  type: 0 */
+  start_value=6130115L; best_t1=3632784L;  best_t2=86437L;  best_type=3; /* mode=4229  add=2  type: 0 */
   if (get_options(argc,(char **) argv))
     exit(1);
 
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index 866fd1e69f9..1feaa4e5d66 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -86,7 +86,6 @@ int ha_myisammrg::delete_row(const byte * buf)
 int ha_myisammrg::index_read(byte * buf, const byte * key,
 			  uint key_len, enum ha_rkey_function find_flag)
 {
-//  return (my_errno=HA_ERR_WRONG_COMMAND);
   statistic_increment(ha_read_key_count,&LOCK_status);
   int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -96,7 +95,6 @@ int ha_myisammrg::index_read(byte * buf, const byte * key,
 int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
 				 uint key_len, enum ha_rkey_function find_flag)
 {
-//  return (my_errno=HA_ERR_WRONG_COMMAND);
   statistic_increment(ha_read_key_count,&LOCK_status);
   int error=myrg_rkey(file,buf,index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -105,7 +103,6 @@ int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
 
 int ha_myisammrg::index_next(byte * buf)
 {
-//  return (my_errno=HA_ERR_WRONG_COMMAND);
   statistic_increment(ha_read_next_count,&LOCK_status);
   int error=myrg_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -114,7 +111,6 @@ int ha_myisammrg::index_next(byte * buf)
 
 int ha_myisammrg::index_prev(byte * buf)
 {
-// return (my_errno=HA_ERR_WRONG_COMMAND);
   statistic_increment(ha_read_prev_count,&LOCK_status);
   int error=myrg_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -123,7 +119,6 @@ int ha_myisammrg::index_prev(byte * buf)
 
 int ha_myisammrg::index_first(byte * buf)
 {
-//  return (my_errno=HA_ERR_WRONG_COMMAND);
   statistic_increment(ha_read_first_count,&LOCK_status);
   int error=myrg_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -132,7 +127,6 @@ int ha_myisammrg::index_first(byte * buf)
 
 int ha_myisammrg::index_last(byte * buf)
 {
-//  return (my_errno=HA_ERR_WRONG_COMMAND);
   statistic_increment(ha_read_last_count,&LOCK_status);
   int error=myrg_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index f67496da923..1ca2aa9b02b 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -222,3 +222,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 34c3d8ed95d..e6c828625eb 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -216,3 +216,4 @@
 "CREATE DATABASE er ikke tilladt mens en tr�d holder p� globalt read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index b4573a551dc..abaa475402e 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -217,3 +217,4 @@
 "CREATE DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit",
 "Foutieve parameters voor %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 80b99c58940..7fc0928d67d 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 59a8b156ab2..d9c98fa919d 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -217,3 +217,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 98902e847b9..6dc6f150d57 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index 1d9e770ea8d..262390d42ea 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -216,3 +216,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index f879c281422..146f196852b 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index 303032d73b2..1d76fd1d898 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -215,3 +215,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index c927eceb163..79e8c8aed8b 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index a177fcf81a8..2971882d431 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -215,3 +215,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 5c12cbf7d42..7fbc60b8953 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index 05562e675bb..9fb3f5f5666 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -215,3 +215,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index 8d973a57137..cc04859d99d 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -215,3 +215,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 705eb7f86ef..989c1f7f45d 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -217,3 +217,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 9bb32287543..82670f503b0 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE n�o permitido enquanto uma 'thread' est� mantendo um travamento global de leitura",
 "Argumentos errados para %s",
 "N�o � permitido a %-.32s@%-.64s criar novos usu�rios",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index 2364bbb6d7d..ba214e540e6 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -217,3 +217,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index 0d778d67f11..94889100847 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -216,3 +216,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index e990e00722b..652f50c77c8 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -221,3 +221,4 @@
 "CREATE DATABASE not allowed while thread is holding global read lock",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index 35788a72935..271b362f63f 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -214,3 +214,4 @@
 "CREATE DATABASE no permitido mientras un thread est� ejerciendo un bloqueo de lectura global",
 "Wrong arguments to %s",
 "%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 5914ea31188..1eb3e9db1e7 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -213,3 +213,4 @@
 "CREATE DATABASE �r inte till�tet n�r man har ett globalt l�s-l�s",
 "Felaktiga argument till %s",
 "%-.32s@%-.64s har inte r�ttigheter att skapa nya anv�ndare",
+"Felaktig tabell definition: Alla tabeller i en MERGE tabell m�ste vara i samma databas",
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2e5333925e7..99fc0fc8fbf 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2178,10 +2178,18 @@ static bool check_merge_table_access(THD *thd, char *db,
   int error=0;
   if (table_list)
   {
-    /* Force all tables to use the current database */
+    /* Check that all tables use the current database */
     TABLE_LIST *tmp;
     for (tmp=table_list; tmp ; tmp=tmp->next)
-      tmp->db=db;
+    {
+      if (!tmp->db || !tmp->db[0])
+	tmp->db=db;
+      else if (!strcmp(tmp->db,db))
+      {
+	send_error(&thd->net,ER_UNION_TABLES_IN_DIFFERENT_DIR);
+	return 1;
+      }
+    }
     error=check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
 			     table_list);
   }

From dd9fa926b390d59a13f4d2a8e2fef6d653372651 Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Wed, 29 Aug 2001 19:42:23 +0300
Subject: [PATCH 33/51] trx0roll.c	Fix the primary key update + BLOB bug,
 improve InnoDB Monitor prints trx0sys.c	Fix the primary key update +
 BLOB bug, improve InnoDB Monitor prints trx0trx.c	Fix the primary key
 update + BLOB bug, improve InnoDB Monitor prints row0mysql.c	Fix the
 primary key update + BLOB bug, improve InnoDB Monitor prints row0purge.c
 Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
 row0sel.c	Fix the primary key update + BLOB bug, improve InnoDB Monitor
 prints row0uins.c	Fix the primary key update + BLOB bug, improve InnoDB
 Monitor prints row0umod.c	Fix the primary key update + BLOB bug, improve
 InnoDB Monitor prints row0upd.c	Fix the primary key update + BLOB bug,
 improve InnoDB Monitor prints srv0srv.c	Fix the primary key update +
 BLOB bug, improve InnoDB Monitor prints srv0start.c	Fix the primary key
 update + BLOB bug, improve InnoDB Monitor prints sync0arr.c	Fix the
 primary key update + BLOB bug, improve InnoDB Monitor prints fil0fil.c	Fix
 the primary key update + BLOB bug, improve InnoDB Monitor prints ibuf0ibuf.c
 Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
 lock0lock.c	Fix the primary key update + BLOB bug, improve InnoDB Monitor
 prints os0file.c	Fix the primary key update + BLOB bug, improve InnoDB
 Monitor prints btr0btr.c	Fix the primary key update + BLOB bug, improve
 InnoDB Monitor prints btr0cur.c	Fix the primary key update + BLOB bug,
 improve InnoDB Monitor prints btr0sea.c	Fix the primary key update +
 BLOB bug, improve InnoDB Monitor prints buf0buf.c	Fix the primary key
 update + BLOB bug, improve InnoDB Monitor prints data0data.c	Fix the
 primary key update + BLOB bug, improve InnoDB Monitor prints srv0srv.h	Fix
 the primary key update + BLOB bug, improve InnoDB Monitor prints trx0sys.h
 Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
 trx0trx.h	Fix the primary key update + BLOB bug, improve InnoDB Monitor
 prints btr0cur.h	Fix the primary key update + BLOB bug, improve InnoDB
 Monitor prints buf0buf.h	Fix the primary key update + BLOB bug, improve
 InnoDB Monitor prints data0data.h	Fix the primary key update + BLOB bug,
 improve InnoDB Monitor prints ha_innobase.cc	Fix the
 auto-inc+REPLACE+replication bug, improve InnoDB Monitor prints

sql/ha_innobase.cc:
  Fix the auto-inc+REPLACE+replication bug, improve InnoDB Monitor prints
innobase/include/btr0cur.h:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/include/buf0buf.h:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/include/data0data.h:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/include/srv0srv.h:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/include/trx0sys.h:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/include/trx0trx.h:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/btr/btr0btr.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/btr/btr0cur.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/btr/btr0sea.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/buf/buf0buf.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/data/data0data.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/fil/fil0fil.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/ibuf/ibuf0ibuf.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/lock/lock0lock.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/os/os0file.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/row/row0mysql.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/row/row0purge.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/row/row0sel.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/row/row0uins.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/row/row0umod.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/row/row0upd.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/srv/srv0srv.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/srv/srv0start.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/sync/sync0arr.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/trx/trx0roll.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/trx/trx0sys.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
innobase/trx/trx0trx.c:
  Fix the primary key update + BLOB bug, improve InnoDB Monitor prints
---
 innobase/btr/btr0btr.c       |   4 +-
 innobase/btr/btr0cur.c       | 286 +++++++++++++++++++++++++++++++++--
 innobase/btr/btr0sea.c       |   5 +
 innobase/buf/buf0buf.c       |  21 +++
 innobase/data/data0data.c    |  25 ++-
 innobase/fil/fil0fil.c       |  11 +-
 innobase/ibuf/ibuf0ibuf.c    |   2 +-
 innobase/include/btr0cur.h   |  70 ++++++++-
 innobase/include/buf0buf.h   |  11 ++
 innobase/include/data0data.h |   7 +-
 innobase/include/srv0srv.h   |  16 +-
 innobase/include/trx0sys.h   |   3 +
 innobase/include/trx0trx.h   |  24 +++
 innobase/lock/lock0lock.c    |  74 ++++++---
 innobase/os/os0file.c        |  34 +++--
 innobase/row/row0mysql.c     |  97 +++++++++++-
 innobase/row/row0purge.c     |   8 +-
 innobase/row/row0sel.c       |  21 +++
 innobase/row/row0uins.c      |   4 +-
 innobase/row/row0umod.c      |  33 ++--
 innobase/row/row0upd.c       |  77 ++++++----
 innobase/srv/srv0srv.c       |  80 ++++++++--
 innobase/srv/srv0start.c     |   7 +-
 innobase/sync/sync0arr.c     |  40 ++++-
 innobase/trx/trx0roll.c      |   8 +
 innobase/trx/trx0sys.c       |   3 +-
 innobase/trx/trx0trx.c       | 103 ++++++++++++-
 sql/ha_innobase.cc           | 104 +++++++++++--
 28 files changed, 1027 insertions(+), 151 deletions(-)

diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c
index af2029bf1e8..6da323867fb 100644
--- a/innobase/btr/btr0btr.c
+++ b/innobase/btr/btr0btr.c
@@ -1738,8 +1738,8 @@ btr_node_ptr_delete(
 
 	btr_cur_position(UT_LIST_GET_FIRST(tree->tree_indexes), node_ptr,
 								&cursor);
-	compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, mtr);
-
+	compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE,
+									mtr);
 	ut_a(err == DB_SUCCESS);
 
 	if (!compressed) {
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 47a67d425cd..7783f618d6d 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -80,6 +80,9 @@ btr_rec_free_updated_extern_fields(
 				X-latched */
 	rec_t*		rec,	/* in: record */
 	upd_t*		update,	/* in: update vector */
+	ibool		do_not_free_inherited,/* in: TRUE if called in a
+				rollback and we do not want to free
+				inherited fields */
 	mtr_t*		mtr);	/* in: mini-transaction handle which contains
 				an X-latch to record page and to the tree */
 
@@ -813,7 +816,7 @@ calculate_sizes_again:
 		/* The record is so big that we have to store some fields
 		externally on separate database pages */
 		
-                big_rec_vec = dtuple_convert_big_rec(index, entry);
+                big_rec_vec = dtuple_convert_big_rec(index, entry, NULL, 0);
 
 		if (big_rec_vec == NULL) {
 		
@@ -1021,7 +1024,7 @@ btr_cur_pessimistic_insert(
 		/* The record is so big that we have to store some fields
 		externally on separate database pages */
 		
-                big_rec_vec = dtuple_convert_big_rec(index, entry);
+                big_rec_vec = dtuple_convert_big_rec(index, entry, NULL, 0);
 
 		if (big_rec_vec == NULL) {
 		
@@ -1242,6 +1245,7 @@ btr_cur_update_in_place(
 	rec_t*		rec;
 	dulint		roll_ptr;
 	trx_t*		trx;
+	ibool		was_delete_marked;
 
 	/* Only clustered index records are updated using this function */
 	ut_ad((cursor->index)->type & DICT_CLUSTERED);
@@ -1270,6 +1274,8 @@ btr_cur_update_in_place(
 
 	/* FIXME: in a mixed tree, all records may not have enough ordering
 	fields for btr search: */
+
+	was_delete_marked = rec_get_deleted_flag(rec);
 	
 	row_upd_rec_in_place(rec, update);
 
@@ -1279,6 +1285,13 @@ btr_cur_update_in_place(
 
 	btr_cur_update_in_place_log(flags, rec, index, update, trx, roll_ptr,
 									mtr);
+	if (was_delete_marked && !rec_get_deleted_flag(rec)) {
+		/* The new updated record owns its possible externally
+		stored fields */
+
+		btr_cur_unmark_extern_fields(rec, mtr);
+	}
+
 	return(DB_SUCCESS);
 }
 
@@ -1434,6 +1447,13 @@ btr_cur_optimistic_update(
 
 	ut_a(rec); /* <- We calculated above the insert would fit */
 
+	if (!rec_get_deleted_flag(rec)) {
+		/* The new inserted record owns its possible externally
+		stored fields */
+
+		btr_cur_unmark_extern_fields(rec, mtr);
+	}
+
 	/* Restore the old explicit lock state on the record */
 
 	lock_rec_restore_from_page_infimum(rec, page);
@@ -1655,11 +1675,15 @@ btr_cur_pessimistic_update(
 	if (flags & BTR_NO_UNDO_LOG_FLAG) {
 		/* We are in a transaction rollback undoing a row
 		update: we must free possible externally stored fields
-		which got new values in the update */
+		which got new values in the update, if they are not
+		inherited values. They can be inherited if we have
+		updated the primary key to another value, and then
+		update it back again. */
 
 		ut_a(big_rec_vec == NULL);
 		
-		btr_rec_free_updated_extern_fields(index, rec, update, mtr);
+		btr_rec_free_updated_extern_fields(index, rec, update,
+						 		TRUE, mtr);
 	}
 
 	/* We have to set appropriate extern storage bits in the new
@@ -1676,8 +1700,8 @@ btr_cur_pessimistic_update(
 				page_get_free_space_of_empty() / 2)
 	    || (rec_get_converted_size(new_entry) >= REC_MAX_DATA_SIZE)) {
 
-                big_rec_vec = dtuple_convert_big_rec(index, new_entry);
-
+                big_rec_vec = dtuple_convert_big_rec(index, new_entry,
+                					ext_vect, n_ext_vect);
 		if (big_rec_vec == NULL) {
 
 			mem_heap_free(heap);
@@ -1694,6 +1718,13 @@ btr_cur_pessimistic_update(
 		lock_rec_restore_from_page_infimum(rec, page);
 		rec_set_field_extern_bits(rec, ext_vect, n_ext_vect, mtr);
 		
+		if (!rec_get_deleted_flag(rec)) {
+			/* The new inserted record owns its possible externally
+			stored fields */
+
+			btr_cur_unmark_extern_fields(rec, mtr);
+		}
+
 		btr_cur_compress_if_useful(cursor, mtr);
 
 		err = DB_SUCCESS;
@@ -1725,6 +1756,13 @@ btr_cur_pessimistic_update(
 
 	rec_set_field_extern_bits(rec, ext_vect, n_ext_vect, mtr);
 
+	if (!rec_get_deleted_flag(rec)) {
+		/* The new inserted record owns its possible externally
+		stored fields */
+
+		btr_cur_unmark_extern_fields(rec, mtr);
+	}
+
 	lock_rec_restore_from_page_infimum(rec, page);
 
 	/* If necessary, restore also the correct lock state for a new,
@@ -2183,6 +2221,7 @@ btr_cur_pessimistic_delete(
 				if compression does not occur, the cursor
 				stays valid: it points to successor of
 				deleted record on function exit */
+	ibool		in_rollback,/* in: TRUE if called in rollback */
 	mtr_t*		mtr)	/* in: mtr */
 {
 	page_t*		page;
@@ -2218,7 +2257,8 @@ btr_cur_pessimistic_delete(
 	}
 
 	btr_rec_free_externally_stored_fields(cursor->index,
-					btr_cur_get_rec(cursor), mtr);
+			btr_cur_get_rec(cursor), in_rollback, mtr);
+
 	if ((page_get_n_recs(page) < 2)
 	    && (dict_tree_get_page(btr_cur_get_tree(cursor))
 					!= buf_frame_get_page_no(page))) {
@@ -2516,6 +2556,199 @@ btr_estimate_number_of_different_key_vals(
 
 /*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
 
+/***********************************************************************
+Sets the ownership bit of an externally stored field in a record. */
+static
+void
+btr_cur_set_ownership_of_extern_field(
+/*==================================*/
+	rec_t*	rec,	/* in: clustered index record */
+	ulint	i,	/* in: field number */
+	ibool	val,	/* in: value to set */
+	mtr_t*	mtr)	/* in: mtr */
+{
+	byte*	data;
+	ulint	local_len;
+	ulint	byte_val;
+
+	data = rec_get_nth_field(rec, i, &local_len);
+	
+	ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+	local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+	byte_val = mach_read_from_1(data + local_len + BTR_EXTERN_LEN);
+
+	if (val) {
+		byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
+	} else {
+		byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
+	}
+	
+	mlog_write_ulint(data + local_len + BTR_EXTERN_LEN, byte_val,
+							MLOG_1BYTE, mtr);
+}
+
+/***********************************************************************
+Marks not updated extern fields as not-owned by this record. The ownership
+is transferred to the updated record which is inserted elsewhere in the
+index tree. In purge only the owner of externally stored field is allowed
+to free the field. */
+
+void
+btr_cur_mark_extern_inherited_fields(
+/*=================================*/
+	rec_t*	rec,	/* in: record in a clustered index */
+	upd_t*	update,	/* in: update vector */
+	mtr_t*	mtr)	/* in: mtr */
+{
+	ibool	is_updated;
+	ulint	n;
+	ulint	j;
+	ulint	i;
+	
+	n = rec_get_n_fields(rec);
+
+	for (i = 0; i < n; i++) {
+		if (rec_get_nth_field_extern_bit(rec, i)) {
+			
+			/* Check it is not in updated fields */
+			is_updated = FALSE;
+
+			if (update) {
+				for (j = 0; j < upd_get_n_fields(update);
+								j++) {
+					if (upd_get_nth_field(update, j)
+							->field_no == i) {
+						is_updated = TRUE;
+					}
+				}
+			}
+
+			if (!is_updated) {
+				btr_cur_set_ownership_of_extern_field(rec, i,
+								FALSE, mtr);
+			}
+		}
+	}
+}
+
+/***********************************************************************
+The complement of the previous function: in an update entry may inherit
+some externally stored fields from a record. We must mark them as inherited
+in entry, so that they are not freed in a rollback. */
+
+void
+btr_cur_mark_dtuple_inherited_extern(
+/*=================================*/
+	dtuple_t*	entry,		/* in: updated entry to be inserted to
+					clustered index */
+	ulint*		ext_vec,	/* in: array of extern fields in the
+					original record */
+	ulint		n_ext_vec,	/* in: number of elements in ext_vec */
+	upd_t*		update)		/* in: update vector */
+{
+	dfield_t* dfield;
+	ulint	byte_val;
+	byte*	data;
+	ulint	len;
+	ibool	is_updated;
+	ulint	j;
+	ulint	i;
+
+	if (ext_vec == NULL) {
+
+		return;
+	}
+	
+	for (i = 0; i < n_ext_vec; i++) {
+
+		/* Check ext_vec[i] is in updated fields */
+		is_updated = FALSE;
+
+		for (j = 0; j < upd_get_n_fields(update); j++) {
+			if (upd_get_nth_field(update, j)->field_no
+							== ext_vec[i]) {
+				is_updated = TRUE;
+			}
+		}
+
+		if (!is_updated) {
+			dfield = dtuple_get_nth_field(entry, ext_vec[i]);
+
+			data = dfield_get_data(dfield);
+			len = dfield_get_len(dfield);
+		
+			len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+			byte_val = mach_read_from_1(data + len
+							+ BTR_EXTERN_LEN);
+
+			byte_val = byte_val | BTR_EXTERN_INHERITED_FLAG;
+		
+			mach_write_to_1(data + len + BTR_EXTERN_LEN, byte_val);
+		}
+	}
+}
+
+/***********************************************************************
+Marks all extern fields in a record as owned by the record. This function
+should be called if the delete mark of a record is removed: a not delete
+marked record always owns all its extern fields. */
+
+void
+btr_cur_unmark_extern_fields(
+/*=========================*/
+	rec_t*	rec,	/* in: record in a clustered index */
+	mtr_t*	mtr)	/* in: mtr */
+{
+	ulint	n;
+	ulint	i;
+
+	n = rec_get_n_fields(rec);
+
+	for (i = 0; i < n; i++) {
+		if (rec_get_nth_field_extern_bit(rec, i)) {
+			
+			btr_cur_set_ownership_of_extern_field(rec, i,
+								TRUE, mtr);
+		}
+	}	
+}
+
+/***********************************************************************
+Marks all extern fields in a dtuple as owned by the record. */
+
+void
+btr_cur_unmark_dtuple_extern_fields(
+/*================================*/
+	dtuple_t*	entry,		/* in: clustered index entry */
+	ulint*		ext_vec,	/* in: array of numbers of fields
+					which have been stored externally */
+	ulint		n_ext_vec)	/* in: number of elements in ext_vec */
+{
+	dfield_t* dfield;
+	ulint	byte_val;
+	byte*	data;
+	ulint	len;
+	ulint	i;
+
+	for (i = 0; i < n_ext_vec; i++) {
+		dfield = dtuple_get_nth_field(entry, ext_vec[i]);
+
+		data = dfield_get_data(dfield);
+		len = dfield_get_len(dfield);
+		
+		len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+		byte_val = mach_read_from_1(data + len + BTR_EXTERN_LEN);
+
+		byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
+		
+		mach_write_to_1(data + len + BTR_EXTERN_LEN, byte_val);
+	}	
+}
+
 /***********************************************************************
 Stores the positions of the fields marked as extern storage in the update
 vector, and also those fields who are marked as extern storage in rec
@@ -2766,7 +2999,9 @@ btr_store_big_rec_extern_fields(
 
 /***********************************************************************
 Frees the space in an externally stored field to the file space
-management. */
+management if the field in data is owned the externally stored field,
+in a rollback we may have the additional condition that the field must
+not be inherited. */
 
 void
 btr_free_externally_stored_field(
@@ -2777,6 +3012,9 @@ btr_free_externally_stored_field(
 					+ reference to the externally
 					stored part */
 	ulint		local_len,	/* in: length of data */
+	ibool		do_not_free_inherited,/* in: TRUE if called in a
+					rollback and we do not want to free
+					inherited fields */
 	mtr_t*		local_mtr)	/* in: mtr containing the latch to
 					data an an X-latch to the index
 					tree */
@@ -2828,6 +3066,26 @@ btr_free_externally_stored_field(
 			return;
 		}
 
+		if (mach_read_from_1(data + local_len + BTR_EXTERN_LEN)
+						& BTR_EXTERN_OWNER_FLAG) {
+			/* This field does not own the externally
+			stored field: do not free! */
+
+			mtr_commit(&mtr);
+
+			return;
+		}
+
+		if (do_not_free_inherited
+			&& mach_read_from_1(data + local_len + BTR_EXTERN_LEN)
+						& BTR_EXTERN_INHERITED_FLAG) {
+			/* Rollback and inherited field: do not free! */
+
+			mtr_commit(&mtr);
+
+			return;
+		}
+		
 		page = buf_page_get(space_id, page_no, RW_X_LATCH, &mtr);
 		
 		buf_page_dbg_add_level(page, SYNC_EXTERN_STORAGE);
@@ -2872,6 +3130,9 @@ btr_rec_free_externally_stored_fields(
 	dict_index_t*	index,	/* in: index of the data, the index
 				tree MUST be X-latched */
 	rec_t*		rec,	/* in: record */
+	ibool		do_not_free_inherited,/* in: TRUE if called in a
+				rollback and we do not want to free
+				inherited fields */
 	mtr_t*		mtr)	/* in: mini-transaction handle which contains
 				an X-latch to record page and to the index
 				tree */
@@ -2896,7 +3157,8 @@ btr_rec_free_externally_stored_fields(
 		if (rec_get_nth_field_extern_bit(rec, i)) {
 
 			data = rec_get_nth_field(rec, i, &len);
-			btr_free_externally_stored_field(index, data, len, mtr);
+			btr_free_externally_stored_field(index, data, len,
+						do_not_free_inherited, mtr);
 		}
 	}
 }
@@ -2912,6 +3174,9 @@ btr_rec_free_updated_extern_fields(
 				X-latched */
 	rec_t*		rec,	/* in: record */
 	upd_t*		update,	/* in: update vector */
+	ibool		do_not_free_inherited,/* in: TRUE if called in a
+				rollback and we do not want to free
+				inherited fields */
 	mtr_t*		mtr)	/* in: mini-transaction handle which contains
 				an X-latch to record page and to the tree */
 {
@@ -2938,7 +3203,8 @@ btr_rec_free_updated_extern_fields(
 		if (rec_get_nth_field_extern_bit(rec, ufield->field_no)) {
 
 			data = rec_get_nth_field(rec, ufield->field_no, &len);
-			btr_free_externally_stored_field(index, data, len, mtr);
+			btr_free_externally_stored_field(index, data, len,
+						do_not_free_inherited, mtr);
 		}
 	}
 }
diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
index ac4e7c5ba3f..616f8911aba 100644
--- a/innobase/btr/btr0sea.c
+++ b/innobase/btr/btr0sea.c
@@ -769,6 +769,11 @@ btr_search_guess_on_hash(
 		buf_page_make_young(page);
 	}	
 
+	/* Increment the page get statistics though we did not really
+	fix the page: for user info only */
+
+	buf_pool->n_page_gets++;
+
 	return(TRUE);	
 
 	/*-------------------------------------------*/
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 3fabe6c6d0e..f485088a5b7 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -349,6 +349,10 @@ buf_pool_create(
 	buf_pool->n_pages_written = 0;
 	buf_pool->n_pages_created = 0;
 
+	buf_pool->n_page_gets = 0;
+	buf_pool->n_page_gets_old = 0;
+	buf_pool->n_pages_read_old = 0;
+	
 	/* 2. Initialize flushing fields
 	   ---------------------------- */
 	UT_LIST_INIT(buf_pool->flush_list);
@@ -667,6 +671,7 @@ buf_page_get_gen(
 #ifndef UNIV_LOG_DEBUG
 	ut_ad(!ibuf_inside() || ibuf_page(space, offset));
 #endif
+	buf_pool->n_page_gets++;
 loop:
 	mutex_enter_fast(&(buf_pool->mutex));
 
@@ -846,6 +851,8 @@ buf_page_optimistic_get_func(
 	ut_ad(mtr && guess);
 	ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
 
+	buf_pool->n_page_gets++;
+
 	block = buf_block_align(guess);
 	
 	mutex_enter(&(buf_pool->mutex));
@@ -976,6 +983,8 @@ buf_page_get_known_nowait(
 	ut_ad(mtr);
 	ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
 
+	buf_pool->n_page_gets++;
+
 	block = buf_block_align(guess);
 	
 	mutex_enter(&(buf_pool->mutex));
@@ -1643,6 +1652,18 @@ buf_print_io(void)
 	printf("Pages read %lu, created %lu, written %lu\n",
 			buf_pool->n_pages_read, buf_pool->n_pages_created,
 						buf_pool->n_pages_written);
+
+	if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
+		printf("Buffer pool hit rate %lu / 1000\n",
+		1000
+		- ((1000 *
+		    (buf_pool->n_pages_read - buf_pool->n_pages_read_old))
+		/ (buf_pool->n_page_gets - buf_pool->n_page_gets_old)));
+	}
+
+	buf_pool->n_page_gets_old = buf_pool->n_page_gets;
+	buf_pool->n_pages_read_old = buf_pool->n_pages_read;
+
 	mutex_exit(&(buf_pool->mutex));
 }
 
diff --git a/innobase/data/data0data.c b/innobase/data/data0data.c
index 4172fb9c8ce..97db9d72f98 100644
--- a/innobase/data/data0data.c
+++ b/innobase/data/data0data.c
@@ -395,7 +395,12 @@ dtuple_convert_big_rec(
 				the entry enough, i.e., if there are
 				too many short fields in entry */
 	dict_index_t*	index,	/* in: index */
-	dtuple_t*	entry)	/* in: index entry */
+	dtuple_t*	entry,	/* in: index entry */
+	ulint*		ext_vec,/* in: array of externally stored fields,
+				or NULL: if a field already is externally
+				stored, then we cannot move it to the vector
+				this function returns */
+	ulint		n_ext_vec)/* in: number of elements is ext_vec */
 {
 	mem_heap_t*	heap;
 	big_rec_t*	vector;
@@ -404,7 +409,9 @@ dtuple_convert_big_rec(
 	ulint		n_fields;
 	ulint		longest;
 	ulint		longest_i;
+	ibool		is_externally_stored;
 	ulint		i;
+	ulint		j;
 	
 	size = rec_get_converted_size(entry);
 
@@ -431,9 +438,23 @@ dtuple_convert_big_rec(
 		for (i = dict_index_get_n_unique_in_tree(index);
 				i < dtuple_get_n_fields(entry); i++) {
 
+			/* Skip over fields which already are externally
+			stored */
+
+			is_externally_stored = FALSE;
+
+			if (ext_vec) {
+				for (j = 0; j < n_ext_vec; j++) {
+					if (ext_vec[j] == i) {
+						is_externally_stored = TRUE;
+					}
+				}
+			}
+				
 			/* Skip over fields which are ordering in some index */
 
-			if (dict_field_get_col(
+			if (!is_externally_stored &&
+			    dict_field_get_col(
 			    	dict_index_get_nth_field(index, i))
 			    ->ord_part == 0) {
 
diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
index 5c783627721..b386f224d11 100644
--- a/innobase/fil/fil0fil.c
+++ b/innobase/fil/fil0fil.c
@@ -19,6 +19,7 @@ Created 10/25/1995 Heikki Tuuri
 #include "log0log.h"
 #include "log0recv.h"
 #include "fsp0fsp.h"
+#include "srv0srv.h"
 
 /*
 		IMPLEMENTATION OF THE LOW-LEVEL FILE SYSTEM
@@ -1152,6 +1153,7 @@ fil_aio_wait(
 	ut_ad(fil_validate());
 
 	if (os_aio_use_native_aio) {
+		srv_io_thread_op_info[segment] = "native aio handle";
 #ifdef WIN_ASYNC_IO
 		ret = os_aio_windows_handle(segment, 0, &fil_node, &message,
 								&type);
@@ -1161,12 +1163,16 @@ fil_aio_wait(
 		ut_a(0);
 #endif
 	} else {
+		srv_io_thread_op_info[segment] = "simulated aio handle";
+
 		ret = os_aio_simulated_handle(segment, (void**) &fil_node,
 	                                               &message, &type);
 	}
 	
 	ut_a(ret);
-	
+
+	srv_io_thread_op_info[segment] = "complete io for fil node";
+
 	mutex_enter(&(system->mutex));
 
 	fil_node_complete_io(fil_node, fil_system, type);
@@ -1178,9 +1184,10 @@ fil_aio_wait(
 	/* Do the i/o handling */
 
 	if (buf_pool_is_block(message)) {
-	
+		srv_io_thread_op_info[segment] = "complete io for buf page";
 		buf_page_io_complete(message);
 	} else {
+		srv_io_thread_op_info[segment] = "complete io for log";
 		log_io_complete(message);
 	}
 }
diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
index fd7b415551f..fa1c630dc08 100644
--- a/innobase/ibuf/ibuf0ibuf.c
+++ b/innobase/ibuf/ibuf0ibuf.c
@@ -2341,7 +2341,7 @@ ibuf_delete_rec(
 	root = ibuf_tree_root_get(ibuf_data, space, mtr);
 
 	btr_cur_pessimistic_delete(&err, TRUE, btr_pcur_get_btr_cur(pcur),
-									mtr);
+							FALSE, mtr);
 	ut_a(err == DB_SUCCESS);
 
 #ifdef UNIV_IBUF_DEBUG
diff --git a/innobase/include/btr0cur.h b/innobase/include/btr0cur.h
index ffae434a5d9..f56a5662253 100644
--- a/innobase/include/btr0cur.h
+++ b/innobase/include/btr0cur.h
@@ -353,6 +353,7 @@ btr_cur_pessimistic_delete(
 				if compression does not occur, the cursor
 				stays valid: it points to successor of
 				deleted record on function exit */
+	ibool		in_rollback,/* in: TRUE if called in rollback */
 	mtr_t*		mtr);	/* in: mtr */
 /***************************************************************
 Parses a redo log record of updating a record in-place. */
@@ -418,6 +419,52 @@ btr_estimate_number_of_different_key_vals(
 				/* out: estimated number of key values */
 	dict_index_t*	index);	/* in: index */
 /***********************************************************************
+Marks not updated extern fields as not-owned by this record. The ownership
+is transferred to the updated record which is inserted elsewhere in the
+index tree. In purge only the owner of externally stored field is allowed
+to free the field. */
+
+void
+btr_cur_mark_extern_inherited_fields(
+/*=================================*/
+	rec_t*	rec,	/* in: record in a clustered index */
+	upd_t*	update,	/* in: update vector */
+	mtr_t*	mtr);	/* in: mtr */
+/***********************************************************************
+The complement of the previous function: in an update entry may inherit
+some externally stored fields from a record. We must mark them as inherited
+in entry, so that they are not freed in a rollback. */
+
+void
+btr_cur_mark_dtuple_inherited_extern(
+/*=================================*/
+	dtuple_t*	entry,		/* in: updated entry to be inserted to
+					clustered index */
+	ulint*		ext_vec,	/* in: array of extern fields in the
+					original record */
+	ulint		n_ext_vec,	/* in: number of elements in ext_vec */
+	upd_t*		update);	/* in: update vector */
+/***********************************************************************
+Marks all extern fields in a record as owned by the record. This function
+should be called if the delete mark of a record is removed: a not delete
+marked record always owns all its extern fields. */
+
+void
+btr_cur_unmark_extern_fields(
+/*=========================*/
+	rec_t*	rec,	/* in: record in a clustered index */
+	mtr_t*	mtr);	/* in: mtr */
+/***********************************************************************
+Marks all extern fields in a dtuple as owned by the record. */
+
+void
+btr_cur_unmark_dtuple_extern_fields(
+/*================================*/
+	dtuple_t*	entry,		/* in: clustered index entry */
+	ulint*		ext_vec,	/* in: array of numbers of fields
+					which have been stored externally */
+	ulint		n_ext_vec);	/* in: number of elements in ext_vec */
+/***********************************************************************
 Stores the fields in big_rec_vec to the tablespace and puts pointers to
 them in rec. The fields are stored on pages allocated from leaf node
 file segment of the index tree. */
@@ -435,7 +482,9 @@ btr_store_big_rec_extern_fields(
 					rec and to the tree */
 /***********************************************************************
 Frees the space in an externally stored field to the file space
-management. */
+management if the field in data is owned the externally stored field,
+in a rollback we may have the additional condition that the field must
+not be inherited. */
 
 void
 btr_free_externally_stored_field(
@@ -446,6 +495,9 @@ btr_free_externally_stored_field(
 					+ reference to the externally
 					stored part */
 	ulint		local_len,	/* in: length of data */
+	ibool		do_not_free_inherited,/* in: TRUE if called in a
+					rollback and we do not want to free
+					inherited fields */
 	mtr_t*		local_mtr);	/* in: mtr containing the latch to
 					data an an X-latch to the index
 					tree */
@@ -458,6 +510,9 @@ btr_rec_free_externally_stored_fields(
 	dict_index_t*	index,	/* in: index of the data, the index
 				tree MUST be X-latched */
 	rec_t*		rec,	/* in: record */
+	ibool		do_not_free_inherited,/* in: TRUE if called in a
+				rollback and we do not want to free
+				inherited fields */
 	mtr_t*		mtr);	/* in: mini-transaction handle which contains
 				an X-latch to record page and to the index
 				tree */
@@ -620,10 +675,21 @@ and sleep this many microseconds in between */
 						on that page */
 #define BTR_EXTERN_LEN			12	/* 8 bytes containing the
 						length of the externally
-						stored part of the BLOB */
+						stored part of the BLOB.
+						The 2 highest bits are
+						reserved to the flags below. */
 /*--------------------------------------*/
 #define BTR_EXTERN_FIELD_REF_SIZE	20
 
+/* The highest bit of BTR_EXTERN_LEN (i.e., the highest bit of the byte
+at lowest address) is set to 1 if this field does not 'own' the externally
+stored field; only the owner field is allowed to free the field in purge!
+If the 2nd highest bit is 1 then it means that the externally stored field
+was inherited from an earlier version of the row. In rollback we are not
+allowed to free an inherited external field. */
+
+#define BTR_EXTERN_OWNER_FLAG		128
+#define BTR_EXTERN_INHERITED_FLAG	64
 
 extern ulint	btr_cur_n_non_sea;
 
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 8b22561adf8..66071030402 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -771,6 +771,17 @@ struct buf_pool_struct{
 	ulint		n_pages_written;/* number write operations */
 	ulint		n_pages_created;/* number of pages created in the pool
 					with no read */
+	ulint		n_page_gets;	/* number of page gets performed;
+					also successful seraches through
+					the adaptive hash index are
+					counted as page gets; this field
+					is NOT protected by the buffer
+					pool mutex */
+	ulint		n_page_gets_old;/* n_page_gets when buf_print was
+					last time called: used to calculate
+					hit rate */
+	ulint		n_pages_read_old;/* n_pages_read when buf_print was
+					last time called */
 	/* 2. Page flushing algorithm fields */
 
 	UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h
index f695e0989a5..c314281d758 100644
--- a/innobase/include/data0data.h
+++ b/innobase/include/data0data.h
@@ -329,7 +329,12 @@ dtuple_convert_big_rec(
 				the entry enough, i.e., if there are
 				too many short fields in entry */
 	dict_index_t*	index,	/* in: index */
-	dtuple_t*	entry);	/* in: index entry */
+	dtuple_t*	entry,	/* in: index entry */
+	ulint*		ext_vec,/* in: array of externally stored fields,
+				or NULL: if a field already is externally
+				stored, then we cannot move it to the vector
+				this function returns */
+	ulint		n_ext_vec);/* in: number of elements is ext_vec */
 /******************************************************************
 Puts back to entry the data stored in vector. Note that to ensure the
 fields in entry can accommodate the data, vector must have been created
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index e635964e5ec..3f014adb76c 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -62,7 +62,15 @@ extern int      srv_query_thread_priority;
 
 /*-------------------------------------------*/
 
+extern ulint	srv_n_rows_inserted;
+extern ulint	srv_n_rows_updated;
+extern ulint	srv_n_rows_deleted;
+extern ulint	srv_n_rows_read;
+
 extern ibool	srv_print_innodb_monitor;
+extern ibool    srv_print_innodb_lock_monitor;
+extern ibool    srv_print_innodb_tablespace_monitor;
+
 extern ulint	srv_n_spin_wait_rounds;
 extern ulint	srv_spin_wait_delay;
 extern ibool	srv_priority_boost;
@@ -105,13 +113,19 @@ extern mutex_t*	kernel_mutex_temp;/* mutex protecting the server, trx structs,
 				it from dynamic memory to get it to the
 				same DRAM page as other hotspot semaphores */
 #define kernel_mutex (*kernel_mutex_temp)
+
+#define SRV_MAX_N_IO_THREADS	100
 				
+/* Array of English strings describing the current state of an
+i/o handler thread */
+extern char* srv_io_thread_op_info[];
+
 typedef struct srv_sys_struct	srv_sys_t;
 
 /* The server system */
 extern srv_sys_t*	srv_sys;
 
-/* Alternatives for fiel flush option in Unix; see the InnoDB manual about
+/* Alternatives for the field flush option in Unix; see the InnoDB manual about
 what these mean */
 #define SRV_UNIX_FDATASYNC   1
 #define SRV_UNIX_O_DSYNC     2
diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
index e26f7e19850..0295cd6abff 100644
--- a/innobase/include/trx0sys.h
+++ b/innobase/include/trx0sys.h
@@ -315,6 +315,9 @@ struct trx_sys_struct{
 					/* List of active and committed in
 					memory transactions, sorted on trx id,
 					biggest first */
+	UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list;
+					/* List of transactions created
+					for MySQL */
 	UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list;
 					/* List of rollback segment objects */
 	trx_rseg_t*	latest_rseg;	/* Latest rollback segment in the
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index f67ba43162d..fdef041e929 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -130,6 +130,14 @@ void
 trx_mark_sql_stat_end(
 /*==================*/
 	trx_t*	trx);	/* in: trx handle */
+/**************************************************************************
+Marks the latest SQL statement ended but does not start a new transaction
+if the trx is not started. */
+
+void
+trx_mark_sql_stat_end_do_not_start_new(
+/*===================================*/
+	trx_t*	trx);	/* in: trx handle */
 /************************************************************************
 Assigns a read view for a consistent read query. All the consistent reads
 within the same transaction will get the same read view, which is created
@@ -236,6 +244,14 @@ trx_commit_step(
 /*============*/
 				/* out: query thread to run next, or NULL */
 	que_thr_t*	thr);	/* in: query thread */
+/**************************************************************************
+Prints info about a transaction to the standard output. The caller must
+own the kernel mutex. */
+
+void
+trx_print(
+/*======*/
+	  trx_t* trx); /* in: transaction */
 
 
 /* Signal to a transaction */
@@ -270,6 +286,9 @@ rolling back after a database recovery */
 struct trx_struct{
 	/* All the next fields are protected by the kernel mutex, except the
 	undo logs which are protected by undo_mutex */
+	char*		op_info;	/* English text describing the
+					current operation, or an empty
+					string */
 	ulint		type;		/* TRX_USER, TRX_PURGE */
 	ulint		conc_state;	/* state of the trx from the point
 					of view of concurrency control:
@@ -284,6 +303,8 @@ struct trx_struct{
 					table */
 	dulint		table_id;	/* table id if the preceding field is
 					TRUE */
+        void*           mysql_thd;      /* MySQL thread handle corresponding
+                                        to this trx, or NULL */
 	os_thread_id_t	mysql_thread_id;/* id of the MySQL thread associated
 					with this transaction object */
 	ulint		n_mysql_tables_in_use; /* number of Innobase tables
@@ -302,6 +323,9 @@ struct trx_struct{
                                         of a duplicate key error */
 	UT_LIST_NODE_T(trx_t)
 			trx_list;	/* list of transactions */
+	UT_LIST_NODE_T(trx_t)
+			mysql_trx_list;	/* list of transactions created for
+					MySQL */
 	/*------------------------------*/
 	mutex_t		undo_mutex;	/* mutex protecting the fields in this
 					section (down to undo_no_arr), EXCEPT
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 5f8f538f392..819c559ceb4 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -13,6 +13,7 @@ Created 5/7/1996 Heikki Tuuri
 #endif
 
 #include "usr0sess.h"
+#include "trx0purge.h"
 
 /* When releasing transaction locks, this specifies how often we release
 the kernel mutex for a moment to give also others access to it */
@@ -3184,7 +3185,7 @@ lock_table_print(
 	ut_ad(mutex_own(&kernel_mutex));
 	ut_a(lock_get_type(lock) == LOCK_TABLE);
 
-	printf("\nTABLE LOCK table %s trx id %lu %lu",
+	printf("TABLE LOCK table %s trx id %lu %lu",
 		lock->un_member.tab_lock.table->name,
 		(lock->trx)->id.high, (lock->trx)->id.low);
 
@@ -3220,6 +3221,8 @@ lock_rec_print(
 	ulint	page_no;
 	ulint	i;
 	ulint	count	= 0;
+	ulint   len;
+	char    buf[200];
 	mtr_t	mtr;
 
 	ut_ad(mutex_own(&kernel_mutex));
@@ -3228,7 +3231,7 @@ lock_rec_print(
 	space = lock->un_member.rec_lock.space;
  	page_no = lock->un_member.rec_lock.page_no;
 
-	printf("\nRECORD LOCKS space id %lu page no %lu n bits %lu",
+	printf("RECORD LOCKS space id %lu page no %lu n bits %lu",
 		    space, page_no, lock_rec_get_n_bits(lock));
 
 	printf(" table %s index %s trx id %lu %lu",
@@ -3251,10 +3254,10 @@ lock_rec_print(
 		printf(" waiting");
 	}
 
-	printf("\n");
-
 	mtr_start(&mtr);
 
+	printf("\n");
+
 	/* If the page is not in the buffer pool, we cannot load it
 	because we have the kernel mutex and ibuf operations would
 	break the latching order */
@@ -3280,12 +3283,14 @@ lock_rec_print(
 			printf("Record lock, heap no %lu ", i);
 
 			if (page) {
-				rec_print(page_find_rec_with_heap_no(page, i));
+			  len = rec_sprintf(buf, 190,
+				      page_find_rec_with_heap_no(page, i));
+			  buf[len] = '\0';
+			  printf("%s", buf);
 			}
 
-			count++;
-
 			printf("\n");
+			count++;
 		}
 
 		if (count >= 3) {
@@ -3342,12 +3347,32 @@ lock_print_info(void)
 	ulint	nth_lock	= 0;
 	ulint	i;
 	mtr_t	mtr;
-	
-	lock_mutex_enter_kernel();
 
-	printf("LOCK INFO:\n");
-	printf("Number of locks in the record hash table %lu\n",
+	printf(
+	"Purge done for all trx's with n:o < %lu %lu, undo n:o < %lu %lu\n",
+		ut_dulint_get_high(purge_sys->purge_trx_no),
+		ut_dulint_get_low(purge_sys->purge_trx_no),
+		ut_dulint_get_high(purge_sys->purge_undo_no),
+		ut_dulint_get_low(purge_sys->purge_undo_no));
+	
+	lock_mutex_enter_kernel();		
+
+	printf("Total number of lock structs in row lock hash table %lu\n",
 						lock_get_n_rec_locks());
+
+	/* First print info on non-active transactions */
+
+	trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
+
+	while (trx) {
+		if (trx->conc_state == TRX_NOT_STARTED) {
+		        printf("---");
+			trx_print(trx);
+		}
+			
+		trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
+	}
+
 loop:
 	trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
 
@@ -3367,11 +3392,21 @@ loop:
 	}
 
 	if (nth_lock == 0) {
-		printf("\nLOCKS FOR TRANSACTION ID %lu %lu\n", trx->id.high,
-								trx->id.low);
+	        printf("---");
+		trx_print(trx);
+
+	        if (trx->read_view) {
+	  	        printf(
+       "Trx read view will not see trx with id >= %lu %lu, sees < %lu %lu\n",
+		       	ut_dulint_get_high(trx->read_view->low_limit_id),
+       			ut_dulint_get_low(trx->read_view->low_limit_id),
+       			ut_dulint_get_high(trx->read_view->up_limit_id),
+       			ut_dulint_get_low(trx->read_view->up_limit_id));
+	        }
+
 		if (trx->que_state == TRX_QUE_LOCK_WAIT) {
 			printf(
-			"################# TRX IS WAITING FOR THE LOCK: ###\n");
+			"------------------TRX IS WAITING FOR THE LOCK:\n");
 
 			if (lock_get_type(trx->wait_lock) == LOCK_REC) {
 				lock_rec_print(trx->wait_lock);
@@ -3380,10 +3415,15 @@ loop:
 			}
 
 			printf(
-			"##################################################\n");
+			"------------------\n");
 		}
 	}
 
+	if (!srv_print_innodb_lock_monitor) {
+	  	nth_trx++;
+	  	goto loop;
+	}
+
 	i = 0;
 
 	lock = UT_LIST_GET_FIRST(trx->trx_locks);
@@ -3431,9 +3471,9 @@ loop:
 
 	nth_lock++;
 
-	if (nth_lock >= 25) {
+	if (nth_lock >= 10) {
 		printf(
-		"25 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n");
+		"10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n");
 	
 		nth_trx++;
 		nth_lock = 0;
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 0525fd7b59a..d4d30f6aabc 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -1577,6 +1577,7 @@ os_aio_windows_handle(
 	void**	message2,
 	ulint*	type)		/* out: OS_FILE_WRITE or ..._READ */
 {
+	ulint		orig_seg	= segment;
 	os_aio_array_t*	array;
 	os_aio_slot_t*	slot;
 	ulint		n;
@@ -1602,10 +1603,14 @@ os_aio_windows_handle(
 	n = array->n_slots / array->n_segments;
 
 	if (array == os_aio_sync_array) {
+		srv_io_thread_op_info[orig_seg] = "wait windows aio for 1 page";
+
 		ut_ad(pos < array->n_slots); 
 		os_event_wait(array->events[pos]);
 		i = pos;
 	} else {
+		srv_io_thread_op_info[orig_seg] =
+						"wait windows aio for n pages";
 		i = os_event_wait_multiple(n, (array->events) + segment * n);
 	}
 
@@ -1615,6 +1620,7 @@ os_aio_windows_handle(
 
 	ut_a(slot->reserved);
 
+	srv_io_thread_op_info[orig_seg] = "get windows aio return value";
 	ret = GetOverlappedResult(slot->file, &(slot->control), &len, TRUE);
 
 	*message1 = slot->message1;
@@ -1887,6 +1893,8 @@ consecutive_loop:
 		}
 	}
 
+	srv_io_thread_op_info[global_segment] = "doing file i/o";
+
 	/* Do the i/o with ordinary, synchronous i/o functions: */
 	if (slot->type == OS_FILE_WRITE) {
 		ret = os_file_write(slot->name, slot->file, combined_buf,
@@ -1897,7 +1905,8 @@ consecutive_loop:
 	}
 
 	ut_a(ret);
-	
+	srv_io_thread_op_info[global_segment] = "file i/o done";	
+
 /* printf("aio: %lu consecutive %lu:th segment, first offs %lu blocks\n",
 			n_consecutive, global_segment, slot->offset
 					/ UNIV_PAGE_SIZE); */
@@ -1953,6 +1962,8 @@ wait_for_io:
 
 	os_mutex_exit(array->mutex);
 
+	srv_io_thread_op_info[global_segment] = "waiting for i/o request";
+
 	os_event_wait(os_aio_segment_wait_events[global_segment]);
 
 	goto restart;
@@ -2023,7 +2034,12 @@ os_aio_print(void)
 	ulint		n_reserved;
 	ulint		i;
 
-	printf("Pending normal aio reads:\n");
+	for (i = 0; i < srv_n_file_io_threads; i++) {
+		printf("I/O thread %lu state: %s\n", i,
+					srv_io_thread_op_info[i]);
+	}
+
+	printf("Pending normal aio reads: ");
 
 	array = os_aio_read_array;
 loop:
@@ -2041,21 +2057,21 @@ loop:
 	
 		if (slot->reserved) {
 			n_reserved++;
-			printf("Reserved slot, messages %lx %lx\n",
+			/* printf("Reserved slot, messages %lx %lx\n",
 					(ulint)slot->message1,
 					(ulint)slot->message2);
-			ut_a(slot->len > 0);
+			*/			ut_a(slot->len > 0);
 		}
 	}
 
 	ut_a(array->n_reserved == n_reserved);
 
-	printf("Total of %lu reserved aio slots\n", n_reserved);
+	printf("%lu\n", n_reserved);
 	
 	os_mutex_exit(array->mutex);
 
 	if (array == os_aio_read_array) {
-		printf("Pending aio writes:\n");
+		printf("Pending aio writes: ");
 	
 		array = os_aio_write_array;
 
@@ -2063,21 +2079,21 @@ loop:
 	}
 
 	if (array == os_aio_write_array) {
-		printf("Pending insert buffer aio reads:\n");
+		printf("Pending insert buffer aio reads: ");
 		array = os_aio_ibuf_array;
 
 		goto loop;
 	}
 
 	if (array == os_aio_ibuf_array) {
-		printf("Pending log writes or reads:\n");
+		printf("Pending log writes or reads: ");
 		array = os_aio_log_array;
 
 		goto loop;
 	}
 
 	if (array == os_aio_log_array) {
-		printf("Pending synchronous reads or writes:\n");		
+		printf("Pending synchronous reads or writes: ");		
 		array = os_aio_sync_array;
 
 		goto loop;
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 9bbc45a5c9a..373ee4ac4bd 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -462,6 +462,8 @@ row_insert_for_mysql(
 	ut_ad(trx);
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
 	
+	trx->op_info = "inserting";
+
 	if (node == NULL) {
 		row_get_prebuilt_insert_row(prebuilt);
 		node = prebuilt->ins_node;
@@ -499,6 +501,8 @@ run_again:
 			goto run_again;
 		}
 
+		trx->op_info = "";
+
 		return(err);
 	}
 
@@ -506,12 +510,15 @@ run_again:
 	
 	prebuilt->table->stat_n_rows++;
 
+	srv_n_rows_inserted++;
+	
 	if (prebuilt->table->stat_n_rows == 0) {
 		/* Avoid wrap-over */
 		prebuilt->table->stat_n_rows--;
 	}	
 
 	row_update_statistics_if_needed(prebuilt);
+	trx->op_info = "";
 
 	return((int) err);
 }
@@ -627,6 +634,8 @@ row_update_for_mysql(
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
 	UT_NOT_USED(mysql_rec);
 	
+	trx->op_info = "updating or deleting";
+
 	node = prebuilt->upd_node;
 
 	clust_index = dict_table_get_first_index(table);
@@ -700,6 +709,7 @@ run_again:
 		
 		if (err == DB_RECORD_NOT_FOUND) {
 			trx->error_state = DB_SUCCESS;
+			trx->op_info = "";
 
 			return((int) err);
 		}
@@ -710,6 +720,8 @@ run_again:
 			goto run_again;
 		}
 
+		trx->op_info = "";
+
 		return(err);
 	}
 
@@ -719,10 +731,16 @@ run_again:
 		if (prebuilt->table->stat_n_rows > 0) {
 			prebuilt->table->stat_n_rows--;
 		}
-	}	
+
+		srv_n_rows_deleted++;
+	} else {
+		srv_n_rows_updated++;
+	}
 
 	row_update_statistics_if_needed(prebuilt);
 
+	trx->op_info = "";
+
 	return((int) err);
 }
 
@@ -798,6 +816,8 @@ row_create_table_for_mysql(
 
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
 	
+	trx->op_info = "creating table";
+
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks can occur then in these operations */
 
@@ -825,16 +845,22 @@ row_create_table_for_mysql(
 		trx_general_rollback_for_mysql(trx, FALSE, NULL);
 
 		if (err == DB_OUT_OF_FILE_SPACE) {
-		         row_drop_table_for_mysql(table->name, trx, TRUE);
+		     	row_drop_table_for_mysql(table->name, trx, TRUE);
 		} else {
-		         assert(err == DB_DUPLICATE_KEY);
-			 fprintf(stderr, 
+		       	assert(err == DB_DUPLICATE_KEY);
+			fprintf(stderr, 
      "InnoDB: Error: table %s already exists in InnoDB internal\n"
      "InnoDB: data dictionary. Have you deleted the .frm file\n"
      "InnoDB: and not used DROP TABLE? Have you used DROP DATABASE\n"
-     "InnoDB: for InnoDB tables in MySQL version <= 3.23.39?\n"
+     "InnoDB: for InnoDB tables in MySQL version <= 3.23.42?\n"
      "InnoDB: See the Restrictions section of the InnoDB manual.\n",
 				 table->name);
+			fprintf(stderr,
+     "InnoDB: You can drop the orphaned table inside InnoDB by\n"
+     "InnoDB: creating an InnoDB table with the same name in another\n"
+     "InnoDB: database and moving the .frm file to the current database.\n"
+     "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n"
+     "InnoDB: succeed.\n");
 		}
 
 		trx->error_state = DB_SUCCESS;
@@ -852,11 +878,32 @@ row_create_table_for_mysql(
  				
 			srv_print_innodb_monitor = TRUE;
 		}
+
+		keywordlen = ut_strlen("innodb_lock_monitor");
+
+		if (namelen >= keywordlen
+		    && 0 == ut_memcmp(table->name + namelen - keywordlen,
+ 				"innodb_lock_monitor", keywordlen)) {
+
+			srv_print_innodb_monitor = TRUE;
+			srv_print_innodb_lock_monitor = TRUE;
+		}
+
+		keywordlen = ut_strlen("innodb_tablespace_monitor");
+
+		if (namelen >= keywordlen
+		    && 0 == ut_memcmp(table->name + namelen - keywordlen,
+ 				"innodb_tablespace_monitor", keywordlen)) {
+
+			srv_print_innodb_tablespace_monitor = TRUE;
+		}
 	}
 
 	mutex_exit(&(dict_sys->mutex));
 	que_graph_free((que_t*) que_node_get_parent(thr));
-	
+
+	trx->op_info = "";
+
 	return((int) err);
 }
 
@@ -879,6 +926,8 @@ row_create_index_for_mysql(
 	
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
 	
+	trx->op_info = "creating index";
+
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks can occur then in these operations */
 
@@ -915,6 +964,8 @@ row_create_index_for_mysql(
 
 	que_graph_free((que_t*) que_node_get_parent(thr));
 	
+	trx->op_info = "";
+
 	return((int) err);
 }
 
@@ -945,7 +996,9 @@ row_drop_table_for_mysql(
 
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
 	ut_a(name != NULL);
-	
+
+	trx->op_info = "dropping table";
+
 	namelen = ut_strlen(name);
 	keywordlen = ut_strlen("innodb_monitor");
 
@@ -957,6 +1010,26 @@ row_drop_table_for_mysql(
 		stop monitor prints */
  				
 		srv_print_innodb_monitor = FALSE;
+		srv_print_innodb_lock_monitor = FALSE;
+	}
+
+	keywordlen = ut_strlen("innodb_lock_monitor");
+
+	if (namelen >= keywordlen
+		    && 0 == ut_memcmp(name + namelen - keywordlen,
+ 				"innodb_lock_monitor", keywordlen)) {
+
+		srv_print_innodb_monitor = FALSE;
+		srv_print_innodb_lock_monitor = FALSE;
+	}
+
+	keywordlen = ut_strlen("innodb_tablespace_monitor");
+
+	if (namelen >= keywordlen
+		    && 0 == ut_memcmp(name + namelen - keywordlen,
+ 				"innodb_tablespace_monitor", keywordlen)) {
+
+		srv_print_innodb_tablespace_monitor = FALSE;
 	}
 
 	/* We use the private SQL parser of Innobase to generate the
@@ -1071,6 +1144,8 @@ funct_exit:
 
 	que_graph_free(graph);
 	
+	trx->op_info = "";
+
 	return((int) err);
 }
 
@@ -1099,6 +1174,8 @@ row_rename_table_for_mysql(
 	ut_a(old_name != NULL);
 	ut_a(new_name != NULL);
 
+	trx->op_info = "renaming table";
+
 	str1 =
 	"PROCEDURE RENAME_TABLE_PROC () IS\n"
 	"BEGIN\n"
@@ -1168,6 +1245,8 @@ funct_exit:
 
 	que_graph_free(graph);
 	
+	trx->op_info = "";
+
 	return((int) err);
 }
 
@@ -1279,6 +1358,8 @@ row_check_table_for_mysql(
 	ulint		n_rows;
 	ulint		n_rows_in_table;
 	ulint		ret 	= DB_SUCCESS;
+
+	prebuilt->trx->op_info = "checking table";
 	
 	index = dict_table_get_first_index(table);
 
@@ -1311,5 +1392,7 @@ row_check_table_for_mysql(
 		index = dict_table_get_next_index(index);
 	}
 
+	prebuilt->trx->op_info = "";
+
 	return(ret);
 }
diff --git a/innobase/row/row0purge.c b/innobase/row/row0purge.c
index ec880d3fe04..43bc166347a 100644
--- a/innobase/row/row0purge.c
+++ b/innobase/row/row0purge.c
@@ -132,7 +132,7 @@ row_purge_remove_clust_if_poss_low(
 		success = btr_cur_optimistic_delete(btr_cur, &mtr);
 	} else {
 		ut_ad(mode == BTR_MODIFY_TREE);
-		btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+		btr_cur_pessimistic_delete(&err, FALSE, btr_cur, FALSE, &mtr);
 
 		if (err == DB_SUCCESS) {
 			success = TRUE;
@@ -254,8 +254,8 @@ row_purge_remove_sec_if_poss_low(
 			success = btr_cur_optimistic_delete(btr_cur, &mtr);
 		} else {
 			ut_ad(mode == BTR_MODIFY_TREE);
-			btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
-
+			btr_cur_pessimistic_delete(&err, FALSE, btr_cur,
+							FALSE, &mtr);
 			if (err == DB_SUCCESS) {
 				success = TRUE;
 			} else if (err == DB_OUT_OF_FILE_SPACE) {
@@ -437,7 +437,7 @@ skip_secondaries:
 			data_field_len = ufield->new_val.len;
 
 			btr_free_externally_stored_field(index, data_field,
-							data_field_len, &mtr);
+						data_field_len, FALSE, &mtr);
 			mtr_commit(&mtr);
 		}
 	}
diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c
index 0ad6b7084e2..d041e34a558 100644
--- a/innobase/row/row0sel.c
+++ b/innobase/row/row0sel.c
@@ -2488,6 +2488,8 @@ row_search_for_mysql(
 	printf("N tables locked %lu\n", trx->mysql_n_tables_locked);
 */
 	if (direction == 0) {
+		trx->op_info = "starting index read";
+	
 		prebuilt->n_rows_fetched = 0;
 		prebuilt->n_fetch_cached = 0;
 		prebuilt->fetch_cache_first = 0;
@@ -2497,6 +2499,8 @@ row_search_for_mysql(
 			row_prebuild_sel_graph(prebuilt);
 		}
 	} else {
+		trx->op_info = "fetching rows";
+
 		if (prebuilt->n_rows_fetched == 0) {
 			prebuilt->fetch_direction = direction;
 		}
@@ -2519,6 +2523,9 @@ row_search_for_mysql(
 
 			prebuilt->n_rows_fetched++;
 
+			srv_n_rows_read++;
+			trx->op_info = "";
+
 			return(DB_SUCCESS);
 		}
 
@@ -2529,6 +2536,7 @@ row_search_for_mysql(
 		    	cache, but the cache was not full at the time of the
 		    	popping: no more rows can exist in the result set */
 		    
+			trx->op_info = "";
 		    	return(DB_RECORD_NOT_FOUND);
 		}
 		
@@ -2560,6 +2568,7 @@ row_search_for_mysql(
 
 			/* printf("%s record not found 1\n", index->name); */
 	
+			trx->op_info = "";
 			return(DB_RECORD_NOT_FOUND);
 		}
 
@@ -2599,6 +2608,9 @@ row_search_for_mysql(
 
  				/* printf("%s shortcut\n", index->name); */
 
+				srv_n_rows_read++;
+
+				trx->op_info = "";
 				return(DB_SUCCESS);
 			
 			} else if (shortcut == SEL_EXHAUSTED) {
@@ -2607,6 +2619,7 @@ row_search_for_mysql(
 
 				/* printf("%s record not found 2\n",
 							index->name); */
+				trx->op_info = "";
 				return(DB_RECORD_NOT_FOUND);
 			}
 
@@ -2980,6 +2993,8 @@ lock_wait_or_error:
 
 	/* printf("Using index %s cnt %lu ret value %lu err\n", index->name,
 							cnt, err); */
+	trx->op_info = "";
+
 	return(err);
 
 normal_return:
@@ -2995,5 +3010,11 @@ normal_return:
 
 	/* printf("Using index %s cnt %lu ret value %lu\n", index->name,
 							cnt, err); */
+	if (ret == DB_SUCCESS) {
+		srv_n_rows_read++;
+	}
+
+	trx->op_info = "";
+
 	return(ret);
 }
diff --git a/innobase/row/row0uins.c b/innobase/row/row0uins.c
index 47807877779..27d1fbcb9ba 100644
--- a/innobase/row/row0uins.c
+++ b/innobase/row/row0uins.c
@@ -89,7 +89,7 @@ retry:
 							&(node->pcur), &mtr);
 	ut_a(success);
 
-	btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+	btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr);
 
 	/* The delete operation may fail if we have little
 	file space left: TODO: easiest to crash the database
@@ -174,7 +174,7 @@ row_undo_ins_remove_sec_low(
 	} else {
 		ut_ad(mode == BTR_MODIFY_TREE);
 
-		btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+		btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr);
 	}
 
 	btr_pcur_close(&pcur);
diff --git a/innobase/row/row0umod.c b/innobase/row/row0umod.c
index 0221c51b985..a7c8957d61a 100644
--- a/innobase/row/row0umod.c
+++ b/innobase/row/row0umod.c
@@ -179,7 +179,11 @@ row_undo_mod_remove_clust_low(
 	} else {
 		ut_ad(mode == BTR_MODIFY_TREE);
 
-		btr_cur_pessimistic_delete(&err, FALSE, btr_cur, mtr);
+		/* Note that since this operation is analogous to purge,
+		we can free also inherited externally stored fields:
+		hence the last FALSE in the call below */
+
+		btr_cur_pessimistic_delete(&err, FALSE, btr_cur, FALSE, mtr);
 
 		/* The delete operation may fail if we have little
 		file space left: TODO: easiest to crash the database
@@ -356,7 +360,8 @@ row_undo_mod_del_mark_or_remove_sec_low(
 		} else {
 			ut_ad(mode == BTR_MODIFY_TREE);
 
-			btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+			btr_cur_pessimistic_delete(&err, FALSE, btr_cur,
+							TRUE, &mtr);
 
 			/* The delete operation may fail if we have little
 			file space left: TODO: easiest to crash the database
@@ -423,22 +428,22 @@ row_undo_mod_del_unmark_sec(
 	found = row_search_index_entry(index, entry, BTR_MODIFY_LEAF, &pcur,
 									&mtr);
 	if (!found) {
-	  err_buf = mem_alloc(1000);
-	  dtuple_sprintf(err_buf, 900, entry);
+	  	err_buf = mem_alloc(1000);
+	  	dtuple_sprintf(err_buf, 900, entry);
 
-	  fprintf(stderr, "InnoDB: error in sec index entry del undo in\n"
-		  "InnoDB: index %s table %s\n", index->name,
-		  index->table->name);
-	  fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
+	  	fprintf(stderr, "InnoDB: error in sec index entry del undo in\n"
+		  	"InnoDB: index %s table %s\n", index->name,
+		  	index->table->name);
+	  	fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
 
-	  rec_sprintf(err_buf, 900, btr_pcur_get_rec(&pcur));
-	  fprintf(stderr, "InnoDB: record %s\n", err_buf);
+	  	rec_sprintf(err_buf, 900, btr_pcur_get_rec(&pcur));
+	  	fprintf(stderr, "InnoDB: record %s\n", err_buf);
 
-	  fprintf(stderr, "InnoDB: Make a detailed bug report and send it\n");
-	  fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
-
-	  mem_free(err_buf);
+	  	fprintf(stderr,
+			"InnoDB: Make a detailed bug report and send it\n");
+	  	fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
 
+	  	mem_free(err_buf);
 	} else {
          	btr_cur = btr_pcur_get_btr_cur(&pcur);
 
diff --git a/innobase/row/row0upd.c b/innobase/row/row0upd.c
index 67a5925a3f5..3fa98db3a02 100644
--- a/innobase/row/row0upd.c
+++ b/innobase/row/row0upd.c
@@ -840,32 +840,31 @@ row_upd_sec_index_entry(
 	rec = btr_cur_get_rec(btr_cur);
 
 	if (!found) {
+	  	err_buf = mem_alloc(1000);
+	  	dtuple_sprintf(err_buf, 900, entry);
 
-	  err_buf = mem_alloc(1000);
-	  dtuple_sprintf(err_buf, 900, entry);
+	  	fprintf(stderr, "InnoDB: error in sec index entry update in\n"
+		  	"InnoDB: index %s table %s\n", index->name,
+		  	index->table->name);
+	  	fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
 
-	  fprintf(stderr, "InnoDB: error in sec index entry update in\n"
-		  "InnoDB: index %s table %s\n", index->name,
-		  index->table->name);
-	  fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
+	  	rec_sprintf(err_buf, 900, rec);
+	  	fprintf(stderr, "InnoDB: record %s\n", err_buf);
 
-	  rec_sprintf(err_buf, 900, rec);
-	  fprintf(stderr, "InnoDB: record %s\n", err_buf);
+	  	fprintf(stderr,
+			"InnoDB: Make a detailed bug report and send it\n");
+	  	fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
 
-	  fprintf(stderr, "InnoDB: Make a detailed bug report and send it\n");
-	  fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
-
-	  mem_free(err_buf);
+	  	mem_free(err_buf);
 	} else {
+ 	  	/* Delete mark the old index record; it can already be
+          	delete marked if we return after a lock wait in
+          	row_ins_index_entry below */
 
- 	  /* Delete mark the old index record; it can already be
-          delete marked if we return after a lock wait in
-          row_ins_index_entry below */
-
-	  if (!rec_get_deleted_flag(rec)) {
-		err = btr_cur_del_mark_set_sec_rec(0, btr_cur, TRUE, thr,
-									&mtr);
-	  }
+	  	if (!rec_get_deleted_flag(rec)) {
+			err = btr_cur_del_mark_set_sec_rec(0, btr_cur, TRUE,
+								thr, &mtr);
+	  	}
 	}
 
 	btr_pcur_close(&pcur);
@@ -907,7 +906,7 @@ row_upd_sec_step(
 				|| (node->state == UPD_NODE_UPDATE_SOME_SEC));
 	ut_ad(!(node->index->type & DICT_CLUSTERED));
 	
-	if ((node->state == UPD_NODE_UPDATE_ALL_SEC)
+	if (node->state == UPD_NODE_UPDATE_ALL_SEC
 			|| row_upd_changes_ord_field(node->row, node->index,
 							node->update)) {
 		err = row_upd_sec_index_entry(node, thr);
@@ -933,15 +932,13 @@ row_upd_clust_rec_by_insert(
 	dict_index_t*	index,	/* in: clustered index of the record */
 	que_thr_t*	thr,	/* in: query thread */
 	mtr_t*		mtr)	/* in: mtr; gets committed here */
-{	
+{
+	mem_heap_t*	heap;
 	btr_pcur_t*	pcur;
 	btr_cur_t*	btr_cur;
 	trx_t*		trx;
 	dict_table_t*	table;
-	mem_heap_t*	heap;
 	dtuple_t*	entry;
-	ulint*		ext_vec;
-	ulint		n_ext_vec;
 	ulint		err;
 	
 	ut_ad(node);
@@ -961,17 +958,20 @@ row_upd_clust_rec_by_insert(
 
 			return(err);
 		}
+		/* Mark as not-owned the externally stored fields which the new
+		row inherits from the delete marked record: purge should not
+		free those externally stored fields even if the delete marked
+		record is removed from the index tree, or updated. */
+
+		btr_cur_mark_extern_inherited_fields(btr_cur_get_rec(btr_cur),
+							node->update, mtr);
 	} 
 
 	mtr_commit(mtr);
 
 	node->state = UPD_NODE_INSERT_CLUSTERED;
 
-	heap = mem_heap_create(1024);
-
-	ext_vec = mem_heap_alloc(heap,
-			sizeof(ulint) * dtuple_get_n_fields(node->row));
-	n_ext_vec = 0;
+	heap = mem_heap_create(500);
 	
 	entry = row_build_index_entry(node->row, index, heap);
 
@@ -979,10 +979,23 @@ row_upd_clust_rec_by_insert(
 	
 	row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id);
 	
+	/* If we return from a lock wait, for example, we may have
+	extern fields marked as not-owned in entry (marked if the
+	if-branch above). We must unmark them. */
+	
+	btr_cur_unmark_dtuple_extern_fields(entry, node->ext_vec,
+							node->n_ext_vec);
+	/* We must mark non-updated extern fields in entry as inherited,
+	so that a possible rollback will not free them */
+	
+	btr_cur_mark_dtuple_inherited_extern(entry, node->ext_vec,
+						node->n_ext_vec,
+						node->update);
+	
 	err = row_ins_index_entry(index, entry, node->ext_vec,
 						node->n_ext_vec, thr);
-	mem_heap_free(heap);	
-
+	mem_heap_free(heap);
+	
 	return(err);
 }
 
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 8dd9c9f3feb..ba556e1c050 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -111,7 +111,14 @@ ibool	srv_print_buf_io		= FALSE;
 ibool	srv_print_log_io		= FALSE;
 ibool	srv_print_latch_waits		= FALSE;
 
+ulint	srv_n_rows_inserted		= 0;
+ulint	srv_n_rows_updated		= 0;
+ulint	srv_n_rows_deleted		= 0;
+ulint	srv_n_rows_read			= 0;
+
 ibool	srv_print_innodb_monitor	= FALSE;
+ibool   srv_print_innodb_lock_monitor   = FALSE;
+ibool   srv_print_innodb_tablespace_monitor = FALSE;
 
 /* The parameters below are obsolete: */
 
@@ -137,6 +144,11 @@ ulint	srv_test_n_reserved_rnds = ULINT_MAX;
 ulint	srv_test_array_size	= ULINT_MAX;
 ulint	srv_test_n_mutexes	= ULINT_MAX;
 
+/* Array of English strings describing the current state of an
+i/o handler thread */
+
+char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];
+
 /*
 	IMPLEMENTATION OF THE SERVER MAIN PROGRAM
 	=========================================
@@ -1926,23 +1938,25 @@ loop:
 	}
 
 background_loop:
-	/* In this loop we run background operations while the server
+	/* In this loop we run background operations when the server
 	is quiet */
 
 	current_time = time(NULL);
 	
-	if (srv_print_innodb_monitor
-	    && difftime(current_time, last_monitor_time) > 8) {
+	if (difftime(current_time, last_monitor_time) > 15) {
+
+	    last_monitor_time = time(NULL);
+
+	    if (srv_print_innodb_monitor) {
 	
-	        printf("================================\n");
-		last_monitor_time = time(NULL);
+	        printf("=====================================\n");
 		ut_print_timestamp(stdout);
 	
 		printf(" INNODB MONITOR OUTPUT\n"
-	       	       "================================\n");
-		printf("--------------------------\n"
-		       "LOCKS HELD BY TRANSACTIONS\n"
-		       "--------------------------\n");
+	       	       "=====================================\n");
+		printf("------------\n"
+		       "TRANSACTIONS\n"
+		       "------------\n");
 		lock_print_info();
 		printf("-----------------------------------------------\n"
 		       "CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS\n"
@@ -1955,11 +1969,40 @@ background_loop:
 		       "BUFFER POOL\n"
 		       "-----------\n");
 		buf_print_io();
+		printf("--------------\n"
+		       "ROW OPERATIONS\n"
+		       "--------------\n");
+		printf(
+	"Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n",
+			srv_n_rows_inserted, 
+			srv_n_rows_updated, 
+			srv_n_rows_deleted, 
+			srv_n_rows_read);
+		printf("Server activity counter %lu\n", srv_activity_count);
 		printf("----------------------------\n"
 		       "END OF INNODB MONITOR OUTPUT\n"
 		       "============================\n");
-	}
+            }
+
+            if (srv_print_innodb_tablespace_monitor) {
 	
+		printf("================================================\n");
+
+		ut_print_timestamp(stdout);
+
+		printf(" INNODB TABLESPACE MONITOR OUTPUT\n"
+		       "================================================\n");
+	       
+		fsp_print(0);
+		fprintf(stderr, "Validating tablespace\n");
+		fsp_validate(0);
+		fprintf(stderr, "Validation ok\n");
+		printf("---------------------------------------\n"
+	       		"END OF INNODB TABLESPACE MONITOR OUTPUT\n"
+	       		"=======================================\n");
+	    }
+	}
+
 	mutex_enter(&kernel_mutex);
 	if (srv_activity_count != old_activity_count) {
 		mutex_exit(&kernel_mutex);
@@ -2009,8 +2052,18 @@ background_loop:
 	}
 	mutex_exit(&kernel_mutex);
 	
+	if (srv_print_innodb_monitor) {
+		ut_print_timestamp(stdout);
+		printf(" InnoDB (main thread) starts buffer pool flush\n");
+	}
+
 	n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
 
+	if (srv_print_innodb_monitor) {
+		ut_print_timestamp(stdout);
+		printf(" InnoDB flushed %lu pages\n", n_pages_flushed);
+	}
+
 	mutex_enter(&kernel_mutex);
 	if (srv_activity_count != old_activity_count) {
 		mutex_exit(&kernel_mutex);
@@ -2038,12 +2091,7 @@ background_loop:
 		
 /*	mem_print_new_info();
  */
-/*
-	fsp_print(0);
-	fprintf(stderr, "Validating tablespace\n");
-	fsp_validate(0);
-	fprintf(stderr, "Validation ok\n");
-*/
+
 #ifdef UNIV_SEARCH_PERF_STAT
 /*	btr_search_print_info(); */
 #endif
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index b3f5dbb28b5..c4002767226 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -67,8 +67,6 @@ os_file_t	files[1000];
 mutex_t		ios_mutex;
 ulint		ios;
 
-#define SRV_MAX_N_IO_THREADS		1000
-
 ulint		n[SRV_MAX_N_IO_THREADS + 5];
 os_thread_id_t	thread_ids[SRV_MAX_N_IO_THREADS + 5];
 
@@ -591,6 +589,11 @@ innobase_start_or_create_for_mysql(void)
 		return((int) err);
 	}
 
+	/* Restrict the maximum number of file i/o threads */
+	if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
+		srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
+	}
+
 #if !(defined(WIN_ASYNC_IO) || defined(POSIX_ASYNC_IO))
 	/* In simulated aio we currently have use only for 4 threads */
 
diff --git a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
index 48d043e1e04..4183f3f1c4c 100644
--- a/innobase/sync/sync0arr.c
+++ b/innobase/sync/sync0arr.c
@@ -438,22 +438,48 @@ sync_array_cell_print(
 /*==================*/
 	sync_cell_t*	cell)	/* in: sync cell */
 {
-	char*	str	 = NULL;
-	ulint	type;
+	mutex_t*	mutex;
+	rw_lock_t*	rwlock;
+	char*		str	 = NULL;
+	ulint		type;
 
 	type = cell->request_type;
 
 	if (type == SYNC_MUTEX) {
 		str = "MUTEX ENTER";
-	} else if (type == RW_LOCK_EX) {
-		str = "X-LOCK";
-	} else if (type == RW_LOCK_SHARED) {
-		str = "S-LOCK";
+		mutex = (mutex_t*)cell->wait_object;
+
+		printf("Mutex created in file %s line %lu",
+				mutex->cfile_name, mutex->cline);
+	} else if (type == RW_LOCK_EX || type == RW_LOCK_SHARED) {
+
+		if (type == RW_LOCK_EX) {
+			str = "X-LOCK";
+		} else {
+			str = "S_LOCK";
+		}
+
+		rwlock = (rw_lock_t*)cell->wait_object;
+
+		printf("Rw-latch created in file %s line %lu",
+				rwlock->cfile_name, rwlock->cline);
+		if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
+			printf(" writer reserved with %lu", rwlock->writer);
+		}
+		
+		if (rwlock->writer == RW_LOCK_EX) {
+			printf(" reserv. thread id %lu",
+				(ulint)rwlock->writer_thread);
+		}
+
+		if (rwlock->reader_count > 0) {
+			printf(" readers %lu", rwlock->reader_count);
+		}	
 	} else {
 		ut_error;
 	}
 
-	printf("%lx waited for by thread %lu op. %s file %s line %lu ",
+	printf(" at addr %lx waited for by thread %lu op. %s file %s line %lu ",
 				(ulint)cell->wait_object,
 				(ulint)cell->thread,
 				str, cell->file, cell->line);
diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c
index 6b74c0d0d51..2adeb1cf57c 100644
--- a/innobase/trx/trx0roll.c
+++ b/innobase/trx/trx0roll.c
@@ -98,6 +98,8 @@ trx_rollback_for_mysql(
 
 		return(DB_SUCCESS);
 	}
+
+	trx->op_info = "rollback";
 	
 	/* Tell Innobase server that there might be work for
 	utility threads: */
@@ -111,6 +113,8 @@ trx_rollback_for_mysql(
 
 	srv_active_wake_master_thread();
 
+	trx->op_info = "";
+
 	return(err);
 }	
 
@@ -129,6 +133,8 @@ trx_rollback_last_sql_stat_for_mysql(
 
 		return(DB_SUCCESS);
 	}
+
+	trx->op_info = "rollback of SQL statement";
 	
 	/* Tell Innobase server that there might be work for
 	utility threads: */
@@ -144,6 +150,8 @@ trx_rollback_last_sql_stat_for_mysql(
 
 	srv_active_wake_master_thread();
 
+	trx->op_info = "";
+	
 	return(err);
 }
 
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
index b056975d28a..0b8664013d7 100644
--- a/innobase/trx/trx0sys.c
+++ b/innobase/trx/trx0sys.c
@@ -510,7 +510,8 @@ trx_sys_init_at_db_start(void)
 						MLOG_8BYTES, &mtr),
 					TRX_SYS_TRX_ID_WRITE_MARGIN),
 				2 * TRX_SYS_TRX_ID_WRITE_MARGIN);
-				
+
+	UT_LIST_INIT(trx_sys->mysql_trx_list);				
 	trx_lists_init_at_db_start();
 
 	if (UT_LIST_GET_LEN(trx_sys->trx_list) > 0) {
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 14108c677eb..5d8c57edf34 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -24,6 +24,12 @@ Created 3/26/1996 Heikki Tuuri
 #include "thr0loc.h"
 #include "btr0sea.h"
 
+
+/* Copy of the prototype for innobase_mysql_print_thd: this
+   copy must be equal to the one in mysql/sql/ha_innobase.cc ! */
+void innobase_mysql_print_thd(void* thd);
+
+
 /* Dummy session used currently in MySQL interface */
 sess_t*		trx_dummy_sess = NULL;
 
@@ -58,11 +64,15 @@ trx_create(
 
 	trx = mem_alloc(sizeof(trx_t));
 
+	trx->op_info = "";
+	
 	trx->type = TRX_USER;
 	trx->conc_state = TRX_NOT_STARTED;
 
 	trx->dict_operation = FALSE;
 
+	trx->mysql_thd = NULL;
+
 	trx->n_mysql_tables_in_use = 0;
 	trx->mysql_n_tables_locked = 0;
 
@@ -129,6 +139,8 @@ trx_allocate_for_mysql(void)
 
 	trx_n_mysql_transactions++;
 	
+	UT_LIST_ADD_FIRST(mysql_trx_list, trx_sys->mysql_trx_list, trx);
+	
 	mutex_exit(&kernel_mutex);
 
 	trx->mysql_thread_id = os_thread_get_curr_id();
@@ -144,11 +156,11 @@ trx_search_latch_release_if_reserved(
 /*=================================*/
         trx_t*     trx) /* in: transaction */
 {
-  if (trx->has_search_latch) {
-    rw_lock_s_unlock(&btr_search_latch);
+  	if (trx->has_search_latch) {
+    		rw_lock_s_unlock(&btr_search_latch);
 
-    trx->has_search_latch = FALSE;
-  }
+    		trx->has_search_latch = FALSE;
+  	}
 }
 
 /************************************************************************
@@ -209,6 +221,8 @@ trx_free_for_mysql(
 
 	mutex_enter(&kernel_mutex);
 	
+	UT_LIST_REMOVE(mysql_trx_list, trx_sys->mysql_trx_list, trx);
+
 	trx_free(trx);
 
 	ut_a(trx_n_mysql_transactions > 0);
@@ -641,7 +655,7 @@ shortcut:
 	ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0);
 	ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0);
 
-	UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);	
+	UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
 }
 
 /************************************************************************
@@ -1268,6 +1282,8 @@ trx_commit_for_mysql(
 	sig to the transaction, we must here make sure that trx has been
 	started. */
 
+	trx->op_info = "committing";
+	
 	trx_start_if_not_started(trx);
 
 	mutex_enter(&kernel_mutex);
@@ -1276,6 +1292,8 @@ trx_commit_for_mysql(
 
 	mutex_exit(&kernel_mutex);
 
+	trx->op_info = "";
+	
 	return(0);
 }
 
@@ -1295,3 +1313,78 @@ trx_mark_sql_stat_end(
 
 	mutex_exit(&kernel_mutex);
 }
+
+/**************************************************************************
+Marks the latest SQL statement ended but does not start a new transaction
+if the trx is not started. */
+
+void
+trx_mark_sql_stat_end_do_not_start_new(
+/*===================================*/
+	trx_t*	trx)	/* in: trx handle */
+{
+	mutex_enter(&kernel_mutex);
+
+	trx->last_sql_stat_start.least_undo_no = trx->undo_no;
+
+	mutex_exit(&kernel_mutex);
+}
+
+/**************************************************************************
+Prints info about a transaction to the standard output. The caller must
+own the kernel mutex. */
+
+void
+trx_print(
+/*======*/
+	trx_t*	trx)	/* in: transaction */
+{
+  	printf("TRANSACTION %lu %lu, OS thread id %lu",
+		ut_dulint_get_high(trx->id),
+	 	ut_dulint_get_low(trx->id),
+	 	(ulint)trx->mysql_thread_id);
+
+	if (ut_strlen(trx->op_info) > 0) {
+		printf(" %s", trx->op_info);
+	}
+	
+  	if (trx->type != TRX_USER) {
+    		printf(" purge trx");
+  	}
+  	
+  	switch (trx->conc_state) {
+  		case TRX_NOT_STARTED:         printf(", not started"); break;
+  		case TRX_ACTIVE:              printf(", active"); break;
+  		case TRX_COMMITTED_IN_MEMORY: printf(", committed in memory");
+									break;
+  		default: printf(" state %lu", trx->conc_state);
+  	}
+
+  	switch (trx->que_state) {
+  		case TRX_QUE_RUNNING:         printf(", runs or sleeps"); break;
+  		case TRX_QUE_LOCK_WAIT:       printf(", lock wait"); break;
+  		case TRX_QUE_ROLLING_BACK:    printf(", rolling back"); break;
+  		case TRX_QUE_COMMITTING:      printf(", committing"); break;
+  		default: printf(" que state %lu", trx->que_state);
+  	}
+
+  	if (0 < UT_LIST_GET_LEN(trx->trx_locks)) {
+  		printf(", has %lu lock struct(s)",
+				UT_LIST_GET_LEN(trx->trx_locks));
+	}
+
+  	if (trx->has_search_latch) {
+  		printf(", holds adaptive hash latch");
+  	}
+
+	if (ut_dulint_cmp(trx->undo_no, ut_dulint_zero) != 0) {
+		printf(", undo log entries %lu",
+			ut_dulint_get_low(trx->undo_no));
+	}
+	
+  	printf("\n");
+
+  	if (trx->mysql_thd != NULL) {
+    		innobase_mysql_print_thd(trx->mysql_thd);
+  	}  
+}
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 061371eb5d4..5f76ec39ce3 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -180,6 +180,47 @@ convert_error_code_to_mysql(
     	}
 }
 
+extern "C" {
+/*****************************************************************
+Prints info of a THD object (== user session thread) to the
+standatd output. NOTE that mysql/innobase/trx/trx0trx.c must contain
+the prototype for this function! */
+
+void
+innobase_mysql_print_thd(
+/*=====================*/
+        void* input_thd)/* in: pointer to a MySQL THD object */
+{
+  	THD*  thd;
+
+  	thd = (THD*) input_thd;
+
+  	printf("MySQL thread id %lu, query id %lu",
+	 			thd->thread_id, thd->query_id);
+    	if (thd->host) {
+    		printf(" %s", thd->host);
+  	}
+
+  	if (thd->ip) {
+    		printf(" %s", thd->ip);
+  	}
+
+  	if (thd->user) {
+    		printf(" %s", thd->user);
+  	}
+
+  	if (thd->proc_info) {
+    		printf(" %s", thd->proc_info);
+  	}
+
+  	if (thd->query) {
+    		printf(" %0.100s", thd->query);
+  	}  
+
+  	printf("\n");
+}
+}
+
 /*************************************************************************
 Gets the InnoDB transaction handle for a MySQL handler object, creates
 an InnoDB transaction struct if the corresponding MySQL thread struct still
@@ -199,6 +240,8 @@ check_trx_exists(
 	        dbug_assert(thd != NULL);
 		trx = trx_allocate_for_mysql();
 
+		trx->mysql_thd = thd;
+
 		thd->transaction.all.innobase_tid = trx;
 
 		/* The execution of a single SQL statement is denoted by
@@ -633,7 +676,7 @@ innobase_commit(
 
 	if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) {
 		trx_commit_for_mysql(trx);
-		trx_mark_sql_stat_end(trx);
+		trx_mark_sql_stat_end_do_not_start_new(trx);
 	} else {
 		trx_mark_sql_stat_end(trx);
 	}
@@ -672,6 +715,7 @@ innobase_rollback(
 
 	if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) {
 		error = trx_rollback_for_mysql(trx);
+		trx_mark_sql_stat_end_do_not_start_new(trx);
 	} else {
 		error = trx_rollback_last_sql_stat_for_mysql(trx);
 		trx_mark_sql_stat_end(trx);
@@ -1334,8 +1378,15 @@ ha_innobase::write_row(
 	        autoincrement field */
 	        
 	        auto_inc = table->next_number_field->val_int();
-		if (auto_inc == 0)
-		  auto_inc= user_thd->next_insert_id;
+
+		/* In replication and also otherwise the auto-inc column 
+		can be set with SET INSERT_ID. Then we must look at
+		user_thd->next_insert_id. If it is nonzero and the user
+		has not supplied a value, we must use it. */
+
+		if (auto_inc == 0 && user_thd->next_insert_id != 0) {
+		        auto_inc = user_thd->next_insert_id;
+		}
 
 		if (auto_inc != 0) {
 			/* This call will calculate the max of the
@@ -2221,29 +2272,29 @@ ha_innobase::external_lock(
 		if (trx->n_mysql_tables_in_use == 0) {
 			trx_mark_sql_stat_end(trx);
 		}
-		thd->transaction.all.innodb_active_trans=1;
+		thd->transaction.all.innodb_active_trans = 1;
 		trx->n_mysql_tables_in_use++;
 
 		if (prebuilt->select_lock_type != LOCK_NONE) {
 
-		  trx->mysql_n_tables_locked++;
+		  	trx->mysql_n_tables_locked++;
 		}
 	} else {
 		trx->n_mysql_tables_in_use--;
 
 		if (trx->n_mysql_tables_in_use == 0) {
 
-		  trx->mysql_n_tables_locked = 0;
+		  	trx->mysql_n_tables_locked = 0;
 
-		  if (trx->has_search_latch) {
+		  	if (trx->has_search_latch) {
 
-		    trx_search_latch_release_if_reserved(trx);
-		  }
+		    		trx_search_latch_release_if_reserved(trx);
+		  	}
 
-		  if (!(thd->options
-			& (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) {
-		    innobase_commit(thd, trx);
-		  }
+		  	if (!(thd->options
+				 & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) {
+		    		innobase_commit(thd, trx);
+		  	}
 		}
 	}
 
@@ -2639,6 +2690,10 @@ ha_innobase::records_in_range(
 
    	DBUG_ENTER("records_in_range");
 
+	if (prebuilt->trx) {
+		prebuilt->trx->op_info = "estimating range size";
+	}
+   	
 	active_index = keynr;
 
 	key = table->key_info + active_index;
@@ -2671,6 +2726,10 @@ ha_innobase::records_in_range(
 
     	my_free((char*) key_val_buff2, MYF(0));
 
+	if (prebuilt->trx) {
+		prebuilt->trx->op_info = "";
+	}
+   	
 	DBUG_RETURN((ha_rows) n_rows);
 }
 
@@ -2690,10 +2749,15 @@ ha_innobase::estimate_number_of_rows(void)
 	row_prebuilt_t* prebuilt	= (row_prebuilt_t*) innobase_prebuilt;
 	dict_table_t*	ib_table;
 
+	if (prebuilt->trx) {
+		prebuilt->trx->op_info =
+				"estimating upper bound of table size";
+	}   	
+
  	DBUG_ENTER("info");
 
  	ib_table = prebuilt->table;
-
+ 	
  	dict_update_statistics(ib_table);
 
 	data_file_length = ((ulonglong)
@@ -2702,6 +2766,10 @@ ha_innobase::estimate_number_of_rows(void)
 
 	/* The minimum clustered index record size is 20 bytes */
 
+	if (prebuilt->trx) {
+		prebuilt->trx->op_info = "";
+	}
+   	
 	return((ha_rows) (1000 + data_file_length / 20));
 }
 
@@ -2740,6 +2808,10 @@ ha_innobase::info(
 
  	DBUG_ENTER("info");
 
+	if (prebuilt->trx) {
+		prebuilt->trx->op_info = "calculating table stats";
+	}
+   	
  	ib_table = prebuilt->table;
 
  	if (flag & HA_STATUS_TIME) {
@@ -2802,6 +2874,10 @@ ha_innobase::info(
 				       trx_get_error_info(prebuilt->trx));
   	}
 
+	if (prebuilt->trx) {
+		prebuilt->trx->op_info = "";
+	}
+   	
   	DBUG_VOID_RETURN;
 }
 

From 79a356b0877aec81e85ddaa9b88530f6eaf4c90b Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Wed, 29 Aug 2001 19:59:01 +0300
Subject: [PATCH 34/51] buf0flu.c	Testing if the file is ok in Bitkeeper

innobase/buf/buf0flu.c:
  Testing if the file is ok in Bitkeeper
---
 innobase/buf/buf0flu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index c87c92ed7e3..25c74f21fd3 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -28,7 +28,7 @@ Created 11/11/1995 Heikki Tuuri
 flushed along with the original page. */
 
 #define BUF_FLUSH_AREA		ut_min(BUF_READ_AHEAD_AREA,\
-						buf_pool->curr_size / 16)
+					       buf_pool->curr_size / 16)
 
 /**********************************************************************
 Validates the flush list. */

From 9a4aac7e23446427ec705d3b65095b8a8f956aee Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 01:22:02 +0300
Subject: [PATCH 35/51] Fix for OS2

Docs/manual.texi:
  Cleanup
---
 Docs/manual.texi   | 2 +-
 include/errmsg.h   | 5 ++++-
 include/m_string.h | 4 ++--
 os2/MySQL-Sql.icc  | 2 +-
 sql/mini_client.cc | 5 +++++
 5 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index fd785d323b4..c4618c2ada7 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -34159,7 +34159,7 @@ if no @code{PRIMARY KEY} was specified explicitly.)
 @findex UNIQUE
 @findex PRIMARY KEY
 If you add a @code{UNIQUE INDEX} or @code{PRIMARY KEY} to a table, this
-is stored before any not @code[UNIQUE} index so that MySQL can detect
+is stored before any not @code{UNIQUE} index so that MySQL can detect
 duplicate keys as early as possible.
 
 @findex ORDER BY
diff --git a/include/errmsg.h b/include/errmsg.h
index 7a967954bab..8087c526937 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -29,8 +29,11 @@ extern const char *client_errors[];	/* Error messages */
 
 #define CR_MIN_ERROR		2000	/* For easier client code */
 #define CR_MAX_ERROR		2999
-#undef ER
+#if defined(OS2) && defined( MYSQL_SERVER)
+#define CER(X) client_errors[(X)-CR_MIN_ERROR]
+#else
 #define ER(X) client_errors[(X)-CR_MIN_ERROR]
+#endif
 #define CLIENT_ERRMAP		2	/* Errormap used by my_error() */
 
 #define CR_UNKNOWN_ERROR	2000
diff --git a/include/m_string.h b/include/m_string.h
index 84c42e0c8b9..7eb2f1fe690 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -82,7 +82,7 @@
 # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
 #endif
 
-#ifdef	__cplusplus
+#if defined(__cplusplus) && !defined(OS2)
 extern "C" {
 #endif
 
@@ -238,7 +238,7 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
 #endif
 #endif
 
-#ifdef	__cplusplus
+#if defined(__cplusplus) && !defined(OS2)
 }
 #endif
 #endif
diff --git a/os2/MySQL-Sql.icc b/os2/MySQL-Sql.icc
index 0c3fc69d68c..addb645e2db 100644
--- a/os2/MySQL-Sql.icc
+++ b/os2/MySQL-Sql.icc
@@ -81,7 +81,7 @@ option ProjectOptions = MySQLOptions
 
          // target source files
          source "rint.obj"
-         source zlib, ufc, regex
+         source zlib, ufc, regex, 'strings\bmove_upp.c'
          if debug_build  {
             source type('cpp') dbug
          }
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 3a2305aa69c..fe8a0a161b3 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -52,6 +52,11 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a
 #include "errmsg.h"
 #include <violite.h>
 
+#if defined( OS2) && defined( MYSQL_SERVER)
+#undef  ER
+#define ER CER
+#endif
+
 extern ulong net_read_timeout;
 
 extern "C" {					// Because of SCO 3.2V4.2

From 2fb1523917c04b5f198802e5918f1da61d69085f Mon Sep 17 00:00:00 2001
From: unknown <paul@central.snake.net>
Date: Wed, 29 Aug 2001 21:56:18 -0500
Subject: [PATCH 36/51] manual.texi	minor change log fixes manual.texi
 fix age calculations in the tutorial section to manual.texi	determine age
 in integer years and to account for manual.texi	relative order of
 dates within calendar year.

Docs/manual.texi:
  minor change log fixes
---
 Docs/manual.texi | 154 ++++++++++++++++++++++++++---------------------
 1 file changed, 85 insertions(+), 69 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index c4618c2ada7..286926e102e 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -13170,75 +13170,89 @@ MySQL provides several functions that you can use to perform
 calculations on dates, for example, to calculate ages or extract
 parts of dates.
 
-To determine how many years old each of your pets is, compute age as the
-difference between the birth date and the current date.  Do this by
-converting the two dates to days, take the difference, and divide by 365 (the
-number of days in a year):
+To determine how many years old each of your pets is, compute the
+difference in the year part of the current date and the birth date, then
+subtract one if the current date occurs earlier in the calendar year than
+the birth date.  The following query shows, for each pet, the birth date,
+the current date, and the age in years.
 
 @example
-mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 FROM pet;
-+----------+-------------------------------------+
-| name     | (TO_DAYS(NOW())-TO_DAYS(birth))/365 |
-+----------+-------------------------------------+
-| Fluffy   |                                6.15 |
-| Claws    |                                5.04 |
-| Buffy    |                                9.88 |
-| Fang     |                                8.59 |
-| Bowser   |                                9.58 |
-| Chirpy   |                                0.55 |
-| Whistler |                                1.30 |
-| Slim     |                                2.92 |
-| Puffball |                                0.00 |
-+----------+-------------------------------------+
+mysql> SELECT name, birth, CURRENT_DATE,
+    -> (YEAR(CURRENT_DATE)-YEAR(birth))
+    -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
+    -> AS age
+    -> FROM pet;
++----------+------------+--------------+------+
+| name     | birth      | CURRENT_DATE | age  |
++----------+------------+--------------+------+
+| Fluffy   | 1993-02-04 | 2001-08-29   |    8 |
+| Claws    | 1994-03-17 | 2001-08-29   |    7 |
+| Buffy    | 1989-05-13 | 2001-08-29   |   12 |
+| Fang     | 1990-08-27 | 2001-08-29   |   11 |
+| Bowser   | 1989-08-31 | 2001-08-29   |   11 |
+| Chirpy   | 1998-09-11 | 2001-08-29   |    2 |
+| Whistler | 1997-12-09 | 2001-08-29   |    3 |
+| Slim     | 1996-04-29 | 2001-08-29   |    5 |
+| Puffball | 1999-03-30 | 2001-08-29   |    2 |
++----------+------------+--------------+------+
 @end example
 
-Although the query works, there are some things about it that could be
-improved.  First, the result could be scanned more easily if the rows were
-presented in some order.  Second, the heading for the age column isn't very
+Here, @code{YEAR()} pulls out the year part of a date and @code{RIGHT()}
+pulls off the rightmost five characters that represent the @code{MM-DD}
+(calendar year) part of the date.  The part of the expression that
+compares the @code{MM-DD} values evaluates to 1 or 0, which adjusts the
+year difference down a year if @code{CURRENT_DATE} occurs earlier in
+the year than @code{birth}.  The full expression is somewhat ungainly,
+so an alias (@code{age}) is used to make the output column label more
 meaningful.
 
-The first problem can be handled by adding an @code{ORDER BY name} clause to
-sort the output by name.  To deal with the column heading, provide a name for
-the column so that a different label appears in the output (this is called a
-column alias):
+The query works, but the result could be scanned more easily if the rows
+were presented in some order.  This can be done by adding an @code{ORDER
+BY name} clause to sort the output by name:
 
 @example
-mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 AS age
+mysql> SELECT name, birth, CURRENT_DATE,
+    -> (YEAR(CURRENT_DATE)-YEAR(birth))
+    -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
+    -> AS age
     -> FROM pet ORDER BY name;
-+----------+------+
-| name     | age  |
-+----------+------+
-| Bowser   | 9.58 |
-| Buffy    | 9.88 |
-| Chirpy   | 0.55 |
-| Claws    | 5.04 |
-| Fang     | 8.59 |
-| Fluffy   | 6.15 |
-| Puffball | 0.00 |
-| Slim     | 2.92 |
-| Whistler | 1.30 |
-+----------+------+
++----------+------------+--------------+------+
+| name     | birth      | CURRENT_DATE | age  |
++----------+------------+--------------+------+
+| Bowser   | 1989-08-31 | 2001-08-29   |   11 |
+| Buffy    | 1989-05-13 | 2001-08-29   |   12 |
+| Chirpy   | 1998-09-11 | 2001-08-29   |    2 |
+| Claws    | 1994-03-17 | 2001-08-29   |    7 |
+| Fang     | 1990-08-27 | 2001-08-29   |   11 |
+| Fluffy   | 1993-02-04 | 2001-08-29   |    8 |
+| Puffball | 1999-03-30 | 2001-08-29   |    2 |
+| Slim     | 1996-04-29 | 2001-08-29   |    5 |
+| Whistler | 1997-12-09 | 2001-08-29   |    3 |
++----------+------------+--------------+------+
 @end example
 
 To sort the output by @code{age} rather than @code{name}, just use a
 different @code{ORDER BY} clause:
 
 @example
-mysql>  SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 AS age
-    ->  FROM pet ORDER BY age;
-+----------+------+
-| name     | age  |
-+----------+------+
-| Puffball | 0.00 |
-| Chirpy   | 0.55 |
-| Whistler | 1.30 |
-| Slim     | 2.92 |
-| Claws    | 5.04 |
-| Fluffy   | 6.15 |
-| Fang     | 8.59 |
-| Bowser   | 9.58 |
-| Buffy    | 9.88 |
-+----------+------+
+mysql> SELECT name, birth, CURRENT_DATE,
+    -> (YEAR(CURRENT_DATE)-YEAR(birth))
+    -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
+    -> AS age
+    -> FROM pet ORDER BY age;
++----------+------------+--------------+------+
+| name     | birth      | CURRENT_DATE | age  |
++----------+------------+--------------+------+
+| Chirpy   | 1998-09-11 | 2001-08-29   |    2 |
+| Puffball | 1999-03-30 | 2001-08-29   |    2 |
+| Whistler | 1997-12-09 | 2001-08-29   |    3 |
+| Slim     | 1996-04-29 | 2001-08-29   |    5 |
+| Claws    | 1994-03-17 | 2001-08-29   |    7 |
+| Fluffy   | 1993-02-04 | 2001-08-29   |    8 |
+| Fang     | 1990-08-27 | 2001-08-29   |   11 |
+| Bowser   | 1989-08-31 | 2001-08-29   |   11 |
+| Buffy    | 1989-05-13 | 2001-08-29   |   12 |
++----------+------------+--------------+------+
 @end example
 
 A similar query can be used to determine age at death for animals that have
@@ -13248,12 +13262,14 @@ values, compute the difference between the @code{death} and @code{birth}
 values:
 
 @example
-mysql>  SELECT name, birth, death, (TO_DAYS(death)-TO_DAYS(birth))/365 AS age
-    ->  FROM pet WHERE death IS NOT NULL ORDER BY age;
+mysql> SELECT name, birth, death,
+    -> (YEAR(death)-YEAR(birth)) - (RIGHT(death,5)<RIGHT(birth,5))
+    -> AS age
+    -> FROM pet WHERE death IS NOT NULL ORDER BY age;
 +--------+------------+------------+------+
 | name   | birth      | death      | age  |
 +--------+------------+------------+------+
-| Bowser | 1989-08-31 | 1995-07-29 | 5.91 |
+| Bowser | 1989-08-31 | 1995-07-29 |    5 |
 +--------+------------+------------+------+
 @end example
 
@@ -13328,7 +13344,7 @@ mysql> SELECT name, birth FROM pet
 
 Note that @code{MONTH} returns a number between 1 and 12. And
 @code{MOD(something,12)} returns a number between 0 and 11. So the
-addition has to be after the @code{MOD()} otherwise we would go from
+addition has to be after the @code{MOD()}, otherwise we would go from
 November (11) to January (1).
 
 
@@ -46696,35 +46712,35 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
-Enforce that all tables in a @code{MERGE} table comes from the same
+Enforce that all tables in a @code{MERGE} table come from the same
 database.
 @item
 Fixed bug with @code{LOAD DATA INFILE} and transactional tables.
 @item
 Fix bug when using @code{INSERT DELAYED} with wrong column definition.
 @item
-Fixed coredump during REPAIR of some particulary broken tables.
+Fixed coredump during @code{REPAIR} of some particularly broken tables.
 @item
 Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
 @item
-Fixed critical bug in @code{InnoDB} and @code{BLOB}'s.  If one has used
-@code{BLOB}'s larger than 8K in an @code{InnoDB} table one must dump
-the table with @code{mysqldump}, drop it and restore it from the dump.
+Fixed critical bug in @code{InnoDB} and @code{BLOB} columns.  If one has
+used @code{BLOB} columns larger than 8K in an @code{InnoDB} table, one must
+dump the table with @code{mysqldump}, drop it and restore it from the dump.
 @item
 Applied large patch for OS/2 from Yuri Dario.
 @item
-Fixed problem with InnoDB when one could get the error @code{Can't
+Fixed problem with @code{InnoDB} when one could get the error @code{Can't
 execute the given command...} even when one didn't have an active
 transaction.
 @item
-Applied some minor fixes that concerns Gemini.
+Applied some minor fixes that concern Gemini.
 @item
 Use real arithmetic operations even in integer context if not
 all arguments are integers. (Fixes uncommon bug in some integer
-context).
+contexts).
 @item
-Don't force everything to lower cases on windows. (To fix problem
-with windows and @code{ALTER TABLE}).  Now @code{--lower_case_names}
+Don't force everything to lower cases on Windows. (To fix problem
+with Windows and @code{ALTER TABLE}).  Now @code{--lower_case_names}
 also works on Unix.
 @item
 Fixed that automatic rollback that is done when thread end doesn't lock
@@ -46740,7 +46756,7 @@ Added option @code{--sql-mode=option[,option[,option]]}.
 @xref{Command-line options}.
 @item
 Fixed possible problem with @code{shutdown} on Solaris where the
-@code{.pid} file wasn't deleted.
+@file{.pid} file wasn't deleted.
 @item
 InnoDB now supports < 4 GB rows. The former limit was 8000 bytes.
 @item

From d66c0987621f14a98c1cd26d025ca1f8b0d1a0b4 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 10:51:36 +0300
Subject: [PATCH 37/51] Portability fixes

dbug/dbug.c:
  Portability fix
include/heap.h:
  Portability fix
strings/conf_to_src.c:
  Portability fix
---
 dbug/dbug.c           | 2 +-
 include/heap.h        | 4 ++--
 strings/conf_to_src.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/dbug/dbug.c b/dbug/dbug.c
index 1fb8755d605..cfe4ca161c6 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -1365,7 +1365,7 @@ uint _line_)
 #ifdef THREAD
     (void) fprintf (_db_fp_, "%-7s: ", my_thread_name());
 #else
-    (void) fprintf (_db_fp_, "%5d: ", getpid ());
+    (void) fprintf (_db_fp_, "%5d: ", (int) getpid ());
 #endif
   }
   if (stack -> flags & NUMBER_ON) {
diff --git a/include/heap.h b/include/heap.h
index 8cbb500fa86..14698810297 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -112,13 +112,13 @@ typedef struct st_heap_share
   LIST open_list;
 } HP_SHARE;
 
-struct st_hash_info;
+struct st_hp_hash_info;
 
 typedef struct st_heap_info
 {
   HP_SHARE *s;
   byte *current_ptr;
-  struct st_hash_info *current_hash_ptr;
+  struct st_hp_hash_info *current_hash_ptr;
   ulong current_record,next_block;
   int lastinx,errkey;
   int  mode;				/* Mode of file (READONLY..) */
diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c
index 76316638153..89415d31820 100644
--- a/strings/conf_to_src.c
+++ b/strings/conf_to_src.c
@@ -80,7 +80,7 @@ print_array(FILE *f, const char *set, const char *name, int n)
     endptr = p;
     for (;;)
     {
-      while (isspace(*endptr))
+      while (isspace((* (unsigned char*) endptr)))
         ++endptr;
       if (*endptr && *endptr != '#')    /* not comment */
         break;
@@ -90,7 +90,7 @@ print_array(FILE *f, const char *set, const char *name, int n)
     }
 
     p = val;
-    while (!isspace(*endptr))
+    while (!isspace((* (unsigned char*) endptr)))
       *p++ = *endptr++;
     *p = '\0';
     p = endptr;

From 0fbb50b597aaf19c68edb9357f58d7a074f036cc Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 11:20:28 +0300
Subject: [PATCH 38/51] Fix problem with comments/blank lines in MERGE files.

Docs/manual.texi:
  Changelog
---
 Docs/manual.texi      |  3 +++
 myisammrg/myrg_open.c | 15 +++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index 286926e102e..f23ef6cca94 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46712,6 +46712,9 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixes problem when one edited @code{.MRG} tables by hand.
+(Patch from Benjamin Pflugmann).
+@item
 Enforce that all tables in a @code{MERGE} table come from the same
 database.
 @item
diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c
index f70d33feb2b..df94fb680cb 100644
--- a/myisammrg/myrg_open.c
+++ b/myisammrg/myrg_open.c
@@ -65,7 +65,6 @@ int handle_locking)
       end[-1]='\0';
     if (buff[0] && buff[0] != '#')	/* Skipp empty lines and comments */
     {
-      last_isam=isam;
       if (!test_if_hard_path(buff))
       {
 	VOID(strmake(name_buff+dir_length,buff,
@@ -75,14 +74,14 @@ int handle_locking)
       if (!(isam=mi_open(buff,mode,test(handle_locking))))
 	goto err;
       files++;
+      last_isam=isam;
+      if (info.reclength && info.reclength != isam->s->base.reclength)
+      {
+	my_errno=HA_ERR_WRONG_IN_RECORD;
+	goto err;
+      }
+      info.reclength=isam->s->base.reclength;
     }
-    last_isam=isam;
-    if (info.reclength && info.reclength != isam->s->base.reclength)
-    {
-      my_errno=HA_ERR_WRONG_IN_RECORD;
-      goto err;
-    }
-    info.reclength=isam->s->base.reclength;
   }
   if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+
 				       files*sizeof(MYRG_TABLE),

From a054969476bfcb14f268110274d7dcf48314e8a7 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 12:51:58 +0300
Subject: [PATCH 39/51] Portability fix

---
 client/Makefile.am | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/client/Makefile.am b/client/Makefile.am
index c05f6a396dc..a91c7d05f77 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -40,20 +40,15 @@ mysqltest_DEPENDENCIES=   	$(LIBRARIES) $(pkglib_LTLIBRARIES)
 mysqlbinlog_SOURCES =   mysqlbinlog.cc 
 mysqlbinlog_DEPENDENCIES=   	$(LIBRARIES) $(pkglib_LTLIBRARIES)
 sql_src=log_event.h log_event.cc
-mysys_src=mysys_priv.h
 
 # Fix for mit-threads
 DEFS =			-DUNDEF_THREADS_HACK
 
 link_sources:
 	for f in $(sql_src) ; do \
-	rm -f $$f; \
-        @LN_CP_F@ ../sql/$$f $$f; \
-        done; \
-	for f in $(mysys_src); do \
-	rm -f $$f; \
-	@LN_CP_F@ ../mysys/$$f $$f; \
-	done;
+	  rm -f $(srcdir)/$$f; \
+	  @LN_CP_F@ $(top_srcdir)/sql/$$f $(srcdir)/$$f; \
+        done;
 
 thread_test.o:		thread_test.c
 			$(COMPILE) -c @MT_INCLUDES@ $(INCLUDES) $<

From 16a2502047f67e40598eb40173462c3003da6a5f Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 14:24:15 +0300
Subject: [PATCH 40/51] Fixed problem in myisampack with blobs

myisam/myisamchk.c:
  Fixes bug when not using --set-character-set
myisam/myisampack.c:
  Fixed problem with blobs
---
 myisam/myisamchk.c  | 5 +++--
 myisam/myisampack.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index 8ee92debf56..aa0713437f4 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -200,7 +200,7 @@ static struct option long_options[] =
 
 static void print_version(void)
 {
-  printf("%s  Ver 1.50 for %s at %s\n",my_progname,SYSTEM_TYPE,
+  printf("%s  Ver 1.51 for %s at %s\n",my_progname,SYSTEM_TYPE,
 	 MACHINE_TYPE);
 }
 
@@ -608,7 +608,8 @@ static int myisamchk(MI_CHECK *param, my_string filename)
        info->s->state.header.file_version[3] != myisam_file_magic[3] ||
        (set_charset && set_charset->number != share->state.header.language)))
   {
-    check_param.language=set_charset->number;
+    if (set_charset)
+      check_param.language=set_charset->number;
     if (recreate_table(&check_param, &info,filename))
     {
       VOID(fprintf(stderr,
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index 557b4887b82..c0c23f28d6c 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -251,7 +251,7 @@ static struct option long_options[] =
 
 static void print_version(void)
 {
-  printf("%s  Ver 1.9 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
+  printf("%s  Ver 1.10 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
 }
 
 static void usage(void)
@@ -1670,7 +1670,7 @@ static int compress_isam_file(MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
       max_calc_length+=huff_counts[i].tree->height;
     else if (huff_counts[i].field_type == FIELD_BLOB ||
 	     huff_counts[i].field_type == FIELD_VARCHAR)
-      max_calc_length=huff_counts[i].tree->height*huff_counts[i].max_length + huff_counts[i].length_bits +1;
+      max_calc_length+=huff_counts[i].tree->height*huff_counts[i].max_length + huff_counts[i].length_bits +1;
     else
       max_calc_length+=
 	(huff_counts[i].field_length - huff_counts[i].max_zero_fill)*

From 18cd5fe5e0dbb43367623a6e4a96d757edd0c78d Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 20:38:46 +0300
Subject: [PATCH 41/51] Increase version number

sql/ha_myisam.cc:
  Added comments
---
 configure.in     | 2 +-
 sql/ha_myisam.cc | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure.in b/configure.in
index f046251567a..5edfd4c99f3 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
 AC_INIT(sql/mysqld.cc)
 AC_CANONICAL_SYSTEM
 # The Docs Makefile.am parses this line!
-AM_INIT_AUTOMAKE(mysql, 3.23.41)
+AM_INIT_AUTOMAKE(mysql, 3.23.42)
 AM_CONFIG_HEADER(config.h)
 
 PROTOCOL_VERSION=10
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 8be62920308..a429d5308dd 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -231,8 +231,16 @@ int ha_myisam::close(void)
 int ha_myisam::write_row(byte * buf)
 {
   statistic_increment(ha_write_count,&LOCK_status);
+
+  /* If we have a timestamp column, update it to the current time */
+
   if (table->time_stamp)
     update_timestamp(buf+table->time_stamp-1);
+
+  /*
+    If we have an auto_increment column and we are writing a changed row
+    or a new row, then update the auto_increment value in the record.
+  */
   if (table->next_number_field && buf == table->record[0])
     update_auto_increment();
   return mi_write(file,buf);

From 83c86c854a1b40bfe46e0464de63e97a75a9b030 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Thu, 30 Aug 2001 21:16:39 +0300
Subject: [PATCH 42/51] Portability fixes

Docs/manual.texi:
  Changelog
client/mysqlbinlog.cc:
  Portability fix
myisam/ft_test1.c:
  Portability fix
sql/log_event.cc:
  Portability fix
---
 Docs/manual.texi      | 2 ++
 client/mysqlbinlog.cc | 5 ++---
 myisam/ft_test1.c     | 3 +--
 sql/log_event.cc      | 4 ++++
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index f23ef6cca94..cd3aaa48e2d 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46712,6 +46712,8 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixed problem with @code{myisampack} and @code{BLOB}.
+@item
 Fixes problem when one edited @code{.MRG} tables by hand.
 (Patch from Benjamin Pflugmann).
 @item
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index db28184f3e7..289f5aa517f 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -21,9 +21,8 @@
 #include <m_string.h>
 #include <my_sys.h>
 #include <getopt.h>
-#include <my_pthread.h>
-#include <thr_alarm.h>
 #include <mysql.h>
+#include <time.h>
 #include "log_event.h"
 
 #define CLIENT_CAPABILITIES	(CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
@@ -113,7 +112,7 @@ static void die(const char* fmt, ...)
 
 static void print_version()
 {
-  printf("%s  Ver 1.5 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE);
+  printf("%s  Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE);
 }
 
 
diff --git a/myisam/ft_test1.c b/myisam/ft_test1.c
index e986f686302..5093b591fb2 100644
--- a/myisam/ft_test1.c
+++ b/myisam/ft_test1.c
@@ -30,7 +30,6 @@ static int create_flag=0,error=0;
 #define MAX_REC_LENGTH 300
 static char record[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
 
-void get_options(int argc,char *argv[]);
 static int run_test(const char *filename);
 static void get_options(int argc, char *argv[]);
 static void create_record(char *, int);
@@ -235,7 +234,7 @@ void create_record(char *pos, int n)
 
 /* Read options */
 
-void get_options(int argc,char *argv[])
+static void get_options(int argc,char *argv[])
 {
   int c;
   const char *options="hVvsNSKFU#:";
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 41efa0f5658..6e99e031f4a 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -277,7 +277,11 @@ void Log_event::print_timestamp(FILE* file, time_t* ts)
   {
     ts = &when;
   }
+#ifdef MYSQL_SERVER
   localtime_r(ts,&tm_tmp);
+#else
+  localtime(ts);
+#endif
 
   fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
 	  tm_tmp.tm_year % 100,

From 308839fedd64bd79188a4d905912cd705944bb2a Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Fri, 31 Aug 2001 10:20:19 +0300
Subject: [PATCH 43/51] Portability fixes

---
 myisam/ft_eval.c | 4 ++--
 myisam/ft_eval.h | 5 +----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/myisam/ft_eval.c b/myisam/ft_eval.c
index 845b56a7fed..9466104100a 100644
--- a/myisam/ft_eval.c
+++ b/myisam/ft_eval.c
@@ -112,7 +112,7 @@ err:
 
 }
 
-void get_options(int argc,char *argv[])
+static void get_options(int argc,char *argv[])
 {
   int c;
   char *options=(char*) "Vh#:qSs:";
@@ -167,7 +167,7 @@ void get_options(int argc,char *argv[])
   return;
 } /* get options */
 
-int create_record(char *pos, FILE *file)
+static int create_record(char *pos, FILE *file)
 { uint tmp; char *ptr;
 
   bzero((char *)pos,MAX_REC_LENGTH);
diff --git a/myisam/ft_eval.h b/myisam/ft_eval.h
index 5d7f41ab04d..d87b6be9c7c 100644
--- a/myisam/ft_eval.h
+++ b/myisam/ft_eval.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000 MySQL AB & Sergei A. Golubchik
    
    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
@@ -35,9 +35,6 @@ MI_COLUMNDEF recinfo[3];
 MI_KEYDEF keyinfo[2];
 MI_KEYSEG keyseg[10];
 
-void get_options(int argc,char *argv[]);
-int create_record(char *, FILE *);
-
 #define SWL_INIT 500
 #define SWL_PLUS 50
 

From 421e64ae356a1633ea50294b48c5025ea387a64d Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Fri, 31 Aug 2001 10:30:38 +0300
Subject: [PATCH 44/51] ix compilition for computer in a previous timezone

Build-tools/Do-compile:
  Fix compilition for computer in a previous timezone
sql/net_serv.cc:
  Added comment
sql/sql_parse.cc:
  Cleanup
---
 Build-tools/Do-compile | 2 ++
 sql/net_serv.cc        | 2 +-
 sql/sql_parse.cc       | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 6f9854a0792..0bea693a441 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -111,6 +111,8 @@ safe_cd($ver);
 if ($opt_stage <= 1)
 {
   $opt_config_options.=" --with-low-memory" if ($opt_with_low_memory);
+  # Fix files if this is in another timezone than work.mysql.com
+  log_system("touch *");
   unlink("config.cache");
   log_system("$make clean") if ($opt_use_old_distribution);
   if ($opt_static_server)
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index ba0944a2516..c9bfd977e78 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -177,7 +177,7 @@ static my_bool net_realloc(NET *net, ulong length)
 void net_clear(NET *net)
 {
 #ifndef EXTRA_DEBUG
-  int count;
+  int count;					// One may get 'unused' warning
   bool is_blocking=vio_is_blocking(net->vio);
   if (is_blocking)
     vio_blocking(net->vio, FALSE);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 99fc0fc8fbf..816825c8cc1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -174,7 +174,6 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
 */
 
 static HASH hash_user_connections;
-static DYNAMIC_ARRAY  user_conn_array;
 extern  pthread_mutex_t LOCK_user_conn;
 
 struct  user_conn {

From e19a292c56c3c613a798f612a73ff4b9e62eb911 Mon Sep 17 00:00:00 2001
From: unknown <heikki@donna.mysql.fi>
Date: Fri, 31 Aug 2001 16:50:57 +0300
Subject: [PATCH 45/51] ha_innobase.cc	Add better error message if
 innodb_data_file_path is not set ha_innobase.h	Remove HA_NOT_READ_AFTER_KEY
 from table han ha_innobase.h	dler flags: it prevented the use of an index
 in MAX()

sql/ha_innobase.h:
  Remove HA_NOT_READ_AFTER_KEY from table han
  dler flags: it prevented the use of an index in MAX()
sql/ha_innobase.cc:
  Add better error message if innodb_data_file_path is not set
---
 sql/ha_innobase.cc | 10 +++++++++-
 sql/ha_innobase.h  |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 5f76ec39ce3..2eed5ada680 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -542,7 +542,15 @@ innobase_init(void)
 	if (!innobase_data_file_path)
 	{
 	  fprintf(stderr,
-       "Can't initialize InnoDB as 'innodb_data_file_path' is not set\n");
+       "Cannot initialize InnoDB as 'innodb_data_file_path' is not set.\n"
+       "If you do not want to use transactional InnoDB tables, add a line\n"
+       "skip-innodb\n"
+       "to the [mysqld] section of init parameters in your my.cnf\n"
+       "or my.ini. If you want to use InnoDB tables, add for example,\n"
+       "innodb_data_file_path = /mysql/data/ibdata1:20M\n"
+       "More information on setting the parameters you find in the\n"
+       "manual.\n");
+
 	  innodb_skip=1;
 	  DBUG_RETURN(FALSE);			// Continue without innobase
 	}
diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h
index d129e00ba6e..daa987dd757 100644
--- a/sql/ha_innobase.h
+++ b/sql/ha_innobase.h
@@ -83,7 +83,7 @@ class ha_innobase: public handler
 			  HA_NO_WRITE_DELAYED |
 			  HA_PRIMARY_KEY_IN_READ_INDEX |
 			  HA_DROP_BEFORE_CREATE |
-			  HA_NOT_READ_AFTER_KEY | HA_NO_PREFIX_CHAR_KEYS),
+			  HA_NO_PREFIX_CHAR_KEYS),
 	  last_dup_key((uint) -1),
 	  start_of_scan(0)
   	{

From 4295917682a23b6f8d493d9433b0b7c1f244c421 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Fri, 31 Aug 2001 23:02:09 +0300
Subject: [PATCH 46/51] Fixed problem with INSERT DELAYED Make killing threads
 safer

Docs/manual.texi:
  Portability fix
mysys/thr_lock.c:
  Fixed problem with INSERT DELAYED
sql/mysqld.cc:
  Make shutdown safer
sql/sql_class.cc:
  Make kill thread safer
sql/sql_insert.cc:
  Make kill thread safer
---
 Docs/manual.texi  | 15 +++++++++------
 mysys/thr_lock.c  | 23 ++++++++++++++++++-----
 sql/mysqld.cc     |  4 +++-
 sql/sql_class.cc  | 12 ++++++------
 sql/sql_insert.cc |  8 +++++---
 5 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index cd3aaa48e2d..ced2acd39d3 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -7252,7 +7252,7 @@ MySQL. How well a certain platform is suited for a high-load
 mission critical MySQL server is determined by the following
 factors:
 
-@itemize
+@itemize @bullet
 @item
 General stability of the thread library. A platform may have excellent
 reputation otherwise, but if the thread library is unstable in the code
@@ -7384,7 +7384,7 @@ If you want to configure @code{mysqld} with some extra features that are
 NOT in the standard binary distributions.  Here is a list of the most 
 common extra options that you may want to use:
 
-@itemize
+@itemize @bullet
 @item @code{--with-berkeley-db}
 @item @code{--with-innodb}
 @item @code{--with-raid}
@@ -23950,7 +23950,7 @@ to it clean up.
  You should start by creating a wrapper library
 /module with the following functions:
 
-@itemize
+@itemize @bullet
 @item
 @code{safe_writer_connect()}
 @item
@@ -26902,7 +26902,7 @@ flag again, the @code{SQL_MAX_JOIN_SIZE} variable will be ignored.
 You can set a default value for this variable by starting @code{mysqld} with
 @code{-O max_join_size=#}.
 
-@item SQL_SAFE_MODE = 0 | 1
+@item SQL_SAFE_UPDATES = 0 | 1
 If set to @code{1}, MySQL will abort if an @code{UPDATE} or
 @code{DELETE} is attempted that doesn't use a key or @code{LIMIT} in the
 @code{WHERE} clause. This makes it possible to catch wrong updates
@@ -34893,7 +34893,7 @@ effectiveness.  Modifying the default behavior will, in most cases,
 only make the search results worse.  Do not alter the MySQL sources
 unless you know what you are doing!
 
-@itemize
+@itemize @bullet
 
 @item
 Minimal length of word to be indexed is defined in
@@ -42849,7 +42849,7 @@ Unfortunately, we have not yet written full documentation for it - we plan to
 do this shortly.  You can, however, look at our current test cases and use 
 them as an example.  The following points should help you get started:
 
-@itemize
+@itemize @bullet
 @item
 The tests are located in @code{mysql-test/t/*.test}
 
@@ -46712,6 +46712,9 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixed problem with @code{INSERT DELAYED} where delay thread could be
+hanging on @code{upgrading locks} without any apparent reasons.
+@item
 Fixed problem with @code{myisampack} and @code{BLOB}.
 @item
 Fixes problem when one edited @code{.MRG} tables by hand.
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 7d86d0c9524..841c2f1bb91 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -115,7 +115,7 @@ my_bool init_thr_lock()
 static uint found_errors=0;
 
 static int check_lock(struct st_lock_list *list, const char* lock_type,
-		      const char *where, my_bool same_thread)
+		      const char *where, my_bool same_thread, bool no_cond)
 {
   THR_LOCK_DATA *data,**prev;
   uint count=0;
@@ -148,6 +148,13 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
 		lock_type,where);
 	return 1;
       }
+      if (no_cond && data->cond)
+      {
+	fprintf(stderr,
+		"Warning: Found active lock with not reset cond %s: %s\n",
+		lock_type,where);
+	return 1;
+      }
       prev= &data->next;
     }
     if (data)
@@ -172,10 +179,10 @@ static void check_locks(THR_LOCK *lock, const char *where,
   uint old_found_errors=found_errors;
   if (found_errors < MAX_FOUND_ERRORS)
   {
-    if (check_lock(&lock->write,"write",where,1) |
-	check_lock(&lock->write_wait,"write_wait",where,0) |
-	check_lock(&lock->read,"read",where,0) |
-	check_lock(&lock->read_wait,"read_wait",where,0))
+    if (check_lock(&lock->write,"write",where,1,1) |
+	check_lock(&lock->write_wait,"write_wait",where,0,0) |
+	check_lock(&lock->read,"read",where,0,1) |
+	check_lock(&lock->read_wait,"read_wait",where,0,0))
       found_errors++;
 
     if (found_errors < MAX_FOUND_ERRORS)
@@ -326,6 +333,7 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *param)
   data->thread=pthread_self();
   data->thread_id=my_thread_id();		/* for debugging */
   data->status_param=param;
+  data->cond=0;
 }
 
 
@@ -416,6 +424,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
   DBUG_ENTER("thr_lock");
 
   data->next=0;
+  data->cond=0;					/* safety */
   data->type=lock_type;
   data->thread=pthread_self();			/* Must be reset ! */
   data->thread_id=my_thread_id();		/* Must be reset ! */
@@ -977,6 +986,10 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
     lock->write_wait.data=data;
     check_locks(lock,"upgrading lock",0);
   }
+  else
+  {
+    check_locks(lock,"waiting for lock",0);
+  }
   DBUG_RETURN(wait_for_lock(&lock->write_wait,data,1));
 }
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index b484eee3480..1255b55a81c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -509,12 +509,14 @@ static void close_connections(void)
     if (tmp->mysys_var)
     {
       tmp->mysys_var->abort=1;
-      if (tmp->mysys_var->current_mutex)
+      pthread_mutex_lock(&tmp->mysys_var->mutex);
+      if (tmp->mysys_var->current_cond)
       {
 	pthread_mutex_lock(tmp->mysys_var->current_mutex);
 	pthread_cond_broadcast(tmp->mysys_var->current_cond);
 	pthread_mutex_unlock(tmp->mysys_var->current_mutex);
       }
+      pthread_mutex_unlock(&tmp->mysys_var->mutex);
     }
   }
   (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index c57b59f55a6..ace7c291ed3 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -226,12 +226,12 @@ void THD::prepare_to_die()
       pthread_mutex_lock(&mysys_var->mutex);
       if (!system_thread)		// Don't abort locks
 	mysys_var->abort=1;
-      if (mysys_var->current_mutex)
-	{
-	  pthread_mutex_lock(mysys_var->current_mutex);
-	  pthread_cond_broadcast(mysys_var->current_cond);
-	  pthread_mutex_unlock(mysys_var->current_mutex);
-	}
+      if (mysys_var->current_cond)
+      {
+	pthread_mutex_lock(mysys_var->current_mutex);
+	pthread_cond_broadcast(mysys_var->current_cond);
+	pthread_mutex_unlock(mysys_var->current_mutex);
+      }
       pthread_mutex_unlock(&mysys_var->mutex);
     }
 }
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index c14fbda3bc5..e6872fa1696 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -511,10 +511,12 @@ public:
     delayed_row *row;
     while ((row=rows.get()))
       delete row;
-    pthread_mutex_destroy(&mutex);
     if (table)
       close_thread_tables(&thd);
     VOID(pthread_mutex_lock(&LOCK_thread_count));
+    pthread_mutex_destroy(&mutex);
+    pthread_cond_destroy(&cond);
+    pthread_cond_destroy(&cond_client);
     thd.unlink();				// Must be unlinked under lock
     x_free(thd.query);
     thd.user=thd.host=0;
@@ -842,7 +844,7 @@ void kill_delayed_threads(void)
     if (tmp->thd.mysys_var)
     {
       pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
-      if (tmp->thd.mysys_var->current_mutex)
+      if (tmp->thd.mysys_var->current_cond)
       {
 	if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
 	  pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
@@ -970,7 +972,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
       di->thd.proc_info=0;
 
       DBUG_PRINT("info",("Waiting for someone to insert rows"));
-      for ( ; ;)
+      while (!thd->killed)
       {
 	int error;
 #if (defined(HAVE_BROKEN_COND_TIMEDWAIT) || defined(HAVE_LINUXTHREADS))

From d8f7e2a8ffea6e3dd1e0e25645975bdee8cc753a Mon Sep 17 00:00:00 2001
From: unknown <tim@white.box>
Date: Fri, 31 Aug 2001 16:30:20 -0400
Subject: [PATCH 47/51] configure.in         Add #undef inline to all C++
 tests.         This is needed to work with some C++ compilers....

configure.in:
  Add #undef inline to all C++ tests.
  This is needed to work with some C++ compilers....
---
 configure.in | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/configure.in b/configure.in
index 210082d7eee..79cd35b5678 100644
--- a/configure.in
+++ b/configure.in
@@ -1458,7 +1458,8 @@ then
   CXXFLAGS="$CXXFLAGS -Werror"
 fi
 AC_TRY_COMPILE(
-[#if !defined(SCO) && !defined(__osf__)
+[#undef inline
+#if !defined(SCO) && !defined(__osf__)
 #define _REENTRANT
 #endif
 #include <pthread.h>
@@ -1490,7 +1491,8 @@ then
   CXXFLAGS="$CXXFLAGS -Werror"
 fi
 AC_TRY_COMPILE(
-[#if !defined(SCO) && !defined(__osf__)
+[#undef inline
+#if !defined(SCO) && !defined(__osf__)
 #define _REENTRANT
 #endif
 #include <pthread.h>
@@ -1521,7 +1523,8 @@ then
   CXXFLAGS="$CXXFLAGS -Werror"
 fi
 AC_TRY_COMPILE(
-[#if !defined(SCO) && !defined(__osf__)
+[#undef inline
+#if !defined(SCO) && !defined(__osf__)
 #define _REENTRANT
 #endif
 #include <pthread.h>

From 09c35c69634c23765aee861639c111c34c1589e7 Mon Sep 17 00:00:00 2001
From: unknown <sasha@mysql.sashanet.com>
Date: Fri, 31 Aug 2001 15:55:58 -0600
Subject: [PATCH 48/51] replicated get_lock() properly

sql/item_func.cc:
  log all lock releases to binary log for safe handling of get_lock()
  in updates
---
 mysql-test/r/rpl_get_lock.result |  4 ++++
 mysql-test/t/rpl_get_lock.test   | 16 ++++++++++++++++
 sql/item_func.cc                 | 17 +++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 mysql-test/r/rpl_get_lock.result
 create mode 100644 mysql-test/t/rpl_get_lock.test

diff --git a/mysql-test/r/rpl_get_lock.result b/mysql-test/r/rpl_get_lock.result
new file mode 100644
index 00000000000..c261ee2861b
--- /dev/null
+++ b/mysql-test/r/rpl_get_lock.result
@@ -0,0 +1,4 @@
+get_lock("lock",3)
+1
+n
+1
diff --git a/mysql-test/t/rpl_get_lock.test b/mysql-test/t/rpl_get_lock.test
new file mode 100644
index 00000000000..45adf99ed21
--- /dev/null
+++ b/mysql-test/t/rpl_get_lock.test
@@ -0,0 +1,16 @@
+source include/master-slave.inc;
+connection master;
+create table t1(n int);
+insert into t1 values(get_lock("lock",2));
+dirty_close master;
+connection master1;
+save_master_pos;
+connection slave;
+sync_with_master;
+select get_lock("lock",3);
+select * from t1;
+connection master1;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 989d7709513..47adb902107 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1399,6 +1399,23 @@ void item_user_lock_free(void)
 void item_user_lock_release(ULL *ull)
 {
   ull->locked=0;
+  if (mysql_bin_log.is_open())
+  {
+    THD *thd = current_thd;
+    int save_errno;
+    char buf[256];
+    String tmp(buf,sizeof(buf));
+    tmp.length(0);
+    tmp.append("SELECT release_lock(\"");
+    tmp.append(ull->key,ull->key_length);
+    tmp.append("\")");
+    save_errno=thd->net.last_errno;
+    thd->net.last_errno=0;
+    thd->query_length=tmp.length();
+    Query_log_event qev(thd,tmp.ptr());
+    mysql_bin_log.write(&qev);
+    thd->net.last_errno=save_errno;
+  }
   if (--ull->count)
     pthread_cond_signal(&ull->cond);
   else

From 9591abbd399bb4b85db9da458fba5ed972c97afa Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Sat, 1 Sep 2001 10:38:16 +0300
Subject: [PATCH 49/51] Make killing of threads safer

Docs/manual.texi:
  Changelog
sql/sql_insert.cc:
  Fix problem with INSERT DELAYED during shutdown
---
 Docs/manual.texi     |  3 +++
 include/my_pthread.h |  8 +++++---
 mysys/thr_lock.c     |  8 ++++----
 sql/item_func.cc     | 16 +++++-----------
 sql/lock.cc          |  2 --
 sql/sql_base.cc      |  9 +++------
 sql/sql_class.h      |  2 --
 sql/sql_insert.cc    | 22 ++++++++++++----------
 sql/sql_repl.cc      |  9 ++++-----
 sql/sql_table.cc     |  2 --
 10 files changed, 36 insertions(+), 45 deletions(-)

diff --git a/Docs/manual.texi b/Docs/manual.texi
index ced2acd39d3..47e2f79887a 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -46712,6 +46712,9 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.42
 @itemize @bullet
 @item
+Fixed rare hang when doing @code{mysqladmin shutdown} when there was
+a lot of activity in other threads.
+@item
 Fixed problem with @code{INSERT DELAYED} where delay thread could be
 hanging on @code{upgrading locks} without any apparent reasons.
 @item
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 79baa7a53e3..33ad9ec0401 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -575,12 +575,14 @@ extern int pthread_dummy(int);
 struct st_my_thread_var
 {
   int thr_errno;
-  pthread_cond_t suspend, *current_cond;
-  pthread_mutex_t mutex,  *current_mutex;
+  pthread_cond_t suspend;
+  pthread_mutex_t mutex;
+  pthread_mutex_t * volatile current_mutex;
+  pthread_cond_t * volatile current_cond;
   pthread_t pthread_self;
   long id;
   int cmp_length;
-  volatile int abort;
+  int volatile abort;
 #ifndef DBUG_OFF
   gptr dbug;
   char name[THREAD_NAME_SIZE+1];
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 841c2f1bb91..d2b3960d6b5 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -374,16 +374,16 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
   }
 
   /* Set up control struct to allow others to abort locks */
-  pthread_mutex_lock(&thread_var->mutex);
   thread_var->current_mutex= &data->lock->mutex;
   thread_var->current_cond=  cond;
-  pthread_mutex_unlock(&thread_var->mutex);
 
   data->cond=cond;
-  do
+  while (!thread_var->abort || in_wait_list)
   {
     pthread_cond_wait(cond,&data->lock->mutex);
-  } while (data->cond == cond && (!thread_var->abort || in_wait_list));
+    if (data->cond != cond)
+      break;
+  }
 
   if (data->cond || data->type == TL_UNLOCK)
   {
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 989d7709513..308597c5247 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1483,11 +1483,9 @@ longlong Item_func_get_lock::val_int()
 
   /* structure is now initialized.  Try to get the lock */
   /* Set up control struct to allow others to abort locks */
-  pthread_mutex_lock(&thd->mysys_var->mutex);
   thd->proc_info="User lock";
   thd->mysys_var->current_mutex= &LOCK_user_locks;
   thd->mysys_var->current_cond=  &ull->cond;
-  pthread_mutex_unlock(&thd->mysys_var->mutex);
 
 #ifdef HAVE_TIMESPEC_TS_SEC
   abstime.ts_sec=time((time_t*) 0)+(time_t) timeout;
@@ -1497,15 +1495,11 @@ longlong Item_func_get_lock::val_int()
   abstime.tv_nsec=0;
 #endif
 
-  while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
-	 != ETIME && error != ETIMEDOUT && ull->locked)
-  {
-    if (thd->killed || abort_loop)
-    {
-      error=EINTR;				// Return NULL
-      break;
-    }
-  }
+  while (!thd->killed &&
+	 (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
+	 != ETIME && error != ETIMEDOUT && ull->locked) ;
+  if (thd->killed)
+    error=EINTR;				// Return NULL
   if (ull->locked)
   {
     if (!--ull->count)
diff --git a/sql/lock.cc b/sql/lock.cc
index 1d9aca66e74..a8b26c3b17d 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -65,11 +65,9 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
       }	
 
       pthread_mutex_lock(&LOCK_open);
-      pthread_mutex_lock(&thd->mysys_var->mutex);
       thd->mysys_var->current_mutex= &LOCK_open;
       thd->mysys_var->current_cond= &COND_refresh;
       thd->proc_info="Waiting for table";
-      pthread_mutex_unlock(&thd->mysys_var->mutex);
 
       while (global_read_lock && ! thd->killed &&
 	     thd->version == refresh_version)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index d885d308770..16495ab03b0 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -358,11 +358,9 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
     */
     if (!tables)
       kill_delayed_threads();
-    pthread_mutex_lock(&thd->mysys_var->mutex);
     thd->mysys_var->current_mutex= &LOCK_open;
     thd->mysys_var->current_cond= &COND_refresh;
     thd->proc_info="Flushing tables";
-    pthread_mutex_unlock(&thd->mysys_var->mutex);
 
     close_old_data_files(thd,thd->open_tables,1,1);
     bool found=1;
@@ -667,13 +665,12 @@ void wait_for_refresh(THD *thd)
 {
   /* Wait until the current table is up to date */
   const char *proc_info;
-  pthread_mutex_lock(&thd->mysys_var->mutex);
   thd->mysys_var->current_mutex= &LOCK_open;
   thd->mysys_var->current_cond= &COND_refresh;
   proc_info=thd->proc_info;
   thd->proc_info="Waiting for table";
-  pthread_mutex_unlock(&thd->mysys_var->mutex);
-  (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
+  if (!thd->killed)
+    (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
 
   pthread_mutex_unlock(&LOCK_open);	// Must be unlocked first
   pthread_mutex_lock(&thd->mysys_var->mutex);
@@ -2182,7 +2179,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
       {
 	in_use->killed=1;
 	pthread_mutex_lock(&in_use->mysys_var->mutex);
-	if (in_use->mysys_var->current_mutex)
+	if (in_use->mysys_var->current_cond)
 	{
 	  pthread_mutex_lock(in_use->mysys_var->current_mutex);
 	  pthread_cond_broadcast(in_use->mysys_var->current_cond);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index bbf6fe08d88..3d218a06d0c 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -326,11 +326,9 @@ public:
 			  const char* msg)
   {
     const char* old_msg = proc_info;
-    pthread_mutex_lock(&mysys_var->mutex);
     mysys_var->current_mutex = mutex;
     mysys_var->current_cond = cond;
     proc_info = msg;
-    pthread_mutex_unlock(&mysys_var->mutex);
     return old_msg;
   }
   inline void exit_cond(const char* old_msg)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e6872fa1696..cd738999383 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -482,7 +482,7 @@ public:
   COPY_INFO info;
   I_List<delayed_row> rows;
   uint group_count;
-  TABLE_LIST *table_list;			// Argument
+  TABLE_LIST table_list;			// Argument
 
   delayed_insert()
     :locks_in_memory(0),
@@ -611,7 +611,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
 	pthread_mutex_unlock(&LOCK_delayed_create);
 	DBUG_RETURN(0);
       }
-      tmp->table_list=table_list;			// Needed to open table
+      tmp->table_list= *table_list;			// Needed to open table
+      tmp->table_list.db= tmp->thd.db;
+      tmp->table_list.name= tmp->table_list.real_name=tmp->thd.query;
       tmp->lock();
       pthread_mutex_lock(&tmp->mutex);
       if ((error=pthread_create(&tmp->thd.real_id,&connection_attrib,
@@ -846,11 +848,9 @@ void kill_delayed_threads(void)
       pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
       if (tmp->thd.mysys_var->current_cond)
       {
-	if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
-	  pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
+	pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
 	pthread_cond_broadcast(tmp->thd.mysys_var->current_cond);
-	if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
-	  pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
+	pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
       }
       pthread_mutex_unlock(&tmp->thd.mysys_var->mutex);
     }
@@ -875,6 +875,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
   thd->thread_id=thread_id++;
   thd->end_time();
   threads.append(thd);
+  thd->killed=abort_loop;
   pthread_mutex_unlock(&LOCK_thread_count);
 
   pthread_mutex_lock(&di->mutex);
@@ -905,7 +906,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
 
   /* open table */
 
-  if (!(di->table=open_ltable(thd,di->table_list,TL_WRITE_DELAYED)))
+  if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED)))
   {
     thd->fatal_error=1;				// Abort waiting inserts
     goto end;
@@ -913,7 +914,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
   if (di->table->file->has_transactions())
   {
     thd->fatal_error=1;
-    my_error(ER_ILLEGAL_HA, MYF(0), di->table_list->real_name);
+    my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name);
     goto end;
   }
   di->table->copy_blobs=1;
@@ -965,10 +966,8 @@ static pthread_handler_decl(handle_delayed_insert,arg)
 #endif
 
       /* Information for pthread_kill */
-      pthread_mutex_lock(&di->thd.mysys_var->mutex);
       di->thd.mysys_var->current_mutex= &di->mutex;
       di->thd.mysys_var->current_cond= &di->cond;
-      pthread_mutex_unlock(&di->thd.mysys_var->mutex);
       di->thd.proc_info=0;
 
       DBUG_PRINT("info",("Waiting for someone to insert rows"));
@@ -996,10 +995,13 @@ static pthread_handler_decl(handle_delayed_insert,arg)
 	  break;
 	}
       }
+      /* We can't lock di->mutex and mysys_var->mutex at the same time */
+      pthread_mutex_unlock(&di->mutex);
       pthread_mutex_lock(&di->thd.mysys_var->mutex);
       di->thd.mysys_var->current_mutex= 0;
       di->thd.mysys_var->current_cond= 0;
       pthread_mutex_unlock(&di->thd.mysys_var->mutex);
+      pthread_mutex_lock(&di->mutex);
     }
 
     if (di->tables_in_use && ! thd->lock)
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index b9ba284ab27..7d4a7847eb1 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -414,12 +414,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
 	log.error=0;
 
 	// tell the kill thread how to wake us up
-	pthread_mutex_lock(&thd->mysys_var->mutex);
 	thd->mysys_var->current_mutex = log_lock;
 	thd->mysys_var->current_cond = &COND_binlog_update;
 	const char* proc_info = thd->proc_info;
 	thd->proc_info = "Slave connection: waiting for binlog update";
-	pthread_mutex_unlock(&thd->mysys_var->mutex);
 
 	bool read_packet = 0, fatal_error = 0;
 
@@ -444,7 +442,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
 	  break;
 	case LOG_READ_EOF:
 	  DBUG_PRINT("wait",("waiting for data on binary log"));
-	  pthread_cond_wait(&COND_binlog_update, log_lock);
+	  if (!thd->killed)
+	    pthread_cond_wait(&COND_binlog_update, log_lock);
 	  break;
 
 	default:
@@ -694,9 +693,9 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
 	  
 	  thr_alarm_kill(tmp->real_id);
 	  tmp->killed = 1;
-	  pthread_mutex_lock(&tmp->mysys_var->mutex);
           tmp->mysys_var->abort = 1;
-	  if(tmp->mysys_var->current_mutex)
+	  pthread_mutex_lock(&tmp->mysys_var->mutex);
+	  if(tmp->mysys_var->current_cond)
 	    {
 	      pthread_mutex_lock(tmp->mysys_var->current_mutex);
 	      pthread_cond_broadcast(tmp->mysys_var->current_cond);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 5c3d8def542..8f4082c6688 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -53,11 +53,9 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
 
   /* mark for close and remove all cached entries */
 
-  pthread_mutex_lock(&thd->mysys_var->mutex);
   thd->mysys_var->current_mutex= &LOCK_open;
   thd->mysys_var->current_cond= &COND_refresh;
   VOID(pthread_mutex_lock(&LOCK_open));
-  pthread_mutex_unlock(&thd->mysys_var->mutex);
 
   if (global_read_lock)
   {

From 992e7da03a64a12ed4bcd180dda45cb91e94a4ee Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Sun, 2 Sep 2001 16:03:37 +0300
Subject: [PATCH 50/51] Added testing of IN(value-list) Portability fixes

Build-tools/Do-compile:
  Fix for Linux ia64
sql-bench/bench-init.pl.sh:
  Added help function time_fetch_all_rows
sql-bench/test-insert.sh:
  Added testing of IN(value-list)
sql/item_func.cc:
  Cleanup
sql/mysqld.cc:
  Portability fix
sql/stacktrace.c:
  Portability fix
---
 Build-tools/Do-compile     | 16 +++++---
 sql-bench/bench-init.pl.sh | 31 ++++++++++++++-
 sql-bench/test-insert.sh   | 77 +++++++++++++++++++++++++++++++++++++-
 sql/item_func.cc           |  2 +-
 sql/mysqld.cc              |  6 +++
 sql/stacktrace.c           |  1 +
 6 files changed, 125 insertions(+), 8 deletions(-)

diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 0bea693a441..4cf2477f5bd 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -4,10 +4,10 @@ use Getopt::Long;
 $opt_distribution=$opt_user=$opt_result=$opt_config_options=$opt_config_env="";
 $opt_dbd_options=$opt_perl_options=$opt_suffix="";
 $opt_tmp=$version_suffix="";
-$opt_help=$opt_Information=$opt_no_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
+$opt_help=$opt_Information=$opt_no_delete=$opt_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
 $opt_innodb=$opt_bdb=0;
 
-GetOptions("Information","help","distribution=s","user=s","result=s","no-delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
+GetOptions("Information","help","distribution=s","user=s","result=s","no-delete","delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
 
 usage() if ($opt_help || $opt_Information);
 usage() if (!$opt_distribution);
@@ -112,7 +112,6 @@ if ($opt_stage <= 1)
 {
   $opt_config_options.=" --with-low-memory" if ($opt_with_low_memory);
   # Fix files if this is in another timezone than work.mysql.com
-  log_system("touch *");
   unlink("config.cache");
   log_system("$make clean") if ($opt_use_old_distribution);
   if ($opt_static_server)
@@ -144,7 +143,7 @@ if ($opt_stage <= 1)
 
 if ($opt_stage <= 2)
 {
-  unlink($opt_distribution) if (!$opt_no_delete && !$opt_use_old_distribution);
+  unlink($opt_distribution) if (!$opt_delete && !$opt_use_old_distribution);
   safe_system("$make");
 }
 
@@ -161,7 +160,14 @@ if ($opt_stage <= 3)
   $flags.="--no-strip" if ($opt_no_strip);
   check_system("scripts/make_binary_distribution --tmp=$opt_tmp --suffix=$opt_suffix $flags",".tar.gz created");
   safe_system("mv mysql*.tar.gz $pwd/$host");
-  safe_system("cp client/mysqladmin $pwd/$host/bin");
+  if (-f "client/.libs/mysqladmin")
+  {
+    safe_system("cp client/.libs/mysqladmin $pwd/$host/bin");
+  }
+  else
+  {
+    safe_system("cp client/mysqladmin $pwd/$host/bin");
+  }  
   safe_system("$make clean") if ($opt_with_small_disk);
 }
 
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
index 2e0b3a9a51d..204d15d7ab3 100644
--- a/sql-bench/bench-init.pl.sh
+++ b/sql-bench/bench-init.pl.sh
@@ -31,7 +31,7 @@
 # $server	Object for current server
 # $limits	Hash reference to limits for benchmark
 
-$benchmark_version="2.13";
+$benchmark_version="2.14";
 use Getopt::Long;
 
 require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n";
@@ -294,6 +294,35 @@ sub do_query
     die "\nError executing '$query':\n$DBI::errstr\n";
 }
 
+#
+# Run a query X times
+#
+
+sub time_fetch_all_rows
+{
+  my($test_text,$result_text,$query,$dbh,$test_count)=@_;
+  my($i,$loop_time,$end_time,$count,$rows,$estimated);
+
+  print $test_text . "\n"   if (defined($test_text));
+  $count=$rows=0;
+  $loop_time=new Benchmark;
+  for ($i=1 ; $i <= $test_count ; $i++)
+  {
+    $count++;
+    $rows+=fetch_all_rows($dbh,$query) or die $DBI::errstr;
+    $end_time=new Benchmark;
+    last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i,
+					   $test_count));
+  }
+  $end_time=new Benchmark;
+  if ($estimated)
+  { print "Estimated time"; }
+  else
+  { print "Time"; }
+  print " for $result_text ($count:$rows) " .
+    timestr(timediff($end_time, $loop_time),"all") . "\n\n";
+}
+
 
 #
 # Handle estimated time of the server is too slow
diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh
index 9d1adda1fc3..a5d0633dbfe 100644
--- a/sql-bench/test-insert.sh
+++ b/sql-bench/test-insert.sh
@@ -1007,6 +1007,47 @@ if ($server->small_rollback_segment())
   $dbh = $server->connect();
 }
 
+###
+### Test speed of IN( value list)
+###
+
+if ($limits->{'functions'})
+{
+  if ($opt_lock_tables)
+  {
+    $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
+  }
+  do_many($dbh,$server->create("bench2",
+			       ["id int NOT NULL"],
+			       ["primary key (id)"]));
+
+  $max_tests=min(($limits->{'query_size'}-50)/6, $opt_loop_count);
+
+  if ($opt_lock_tables)
+  {
+    $sth = $dbh->do("LOCK TABLES bench1 READ, bench2 WRITE") ||
+      die $DBI::errstr;
+  }
+  test_where_in("bench1","bench2","id",1,10);
+  test_where_in("bench1","bench2","id",11,100);
+  test_where_in("bench1","bench2","id",101,min(1000,$max_tests));
+  test_where_in("bench1","bench2","id",1000,$max_tests/2);
+  if ($max_tests > 1000)
+  {
+    test_where_in("bench1","bench2","id",$max_tests/2+1,$max_tests);
+  }
+  if ($opt_lock_tables)
+  {
+    $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
+  }
+  $sth = $dbh->do("DROP TABLE bench2" . $server->{'drop_attr'}) ||
+    die $DBI::errstr;
+  if ($opt_lock_tables)
+  {
+    $sth = $dbh->do("LOCK TABLES bench1 WRITE") || die $DBI::errstr;
+  }
+}
+
 ####
 #### Test INSERT INTO ... SELECT
 ####
@@ -1067,7 +1108,6 @@ if ($limits->{'insert_select'})
   }
 }
 
-
 ####
 #### Do some deletes on the table
 ####
@@ -1605,3 +1645,38 @@ sub check_or_range
   print " for $check ($count:$found): " .
     timestr(timediff($end_time, $loop_time),"all") . "\n";
 }
+
+#
+# Test if SELECT ... WHERE id in(value-list)
+#
+
+sub test_where_in
+{
+  my ($t1,$t2,$id,$from,$to)= @_;
+
+  return if ($from >= $to);
+
+  $query="SELECT $t1.* FROM $t1 WHERE $id IN (";
+  for ($i=1 ; $i <= $to ; $i++)
+  {
+    $query.="$i,";
+  }
+  $query=substr($query,0,length($query)-1) . ")";
+
+  # Fill join table to have the same id's as 'query'
+  for ($i= $from ; $i <= $to ; $i++)
+  {
+    $dbh->do("insert into $t2 values($i)") or die $DBI::errstr;
+  }
+  if ($opt_fast && defined($server->{vacuum}))
+  {
+    $server->vacuum(1,\$dbh,"bench1");
+  }
+
+  time_fetch_all_rows("\nTesting SELECT ... WHERE id in ($to values)",
+		      "select_in", $query, $dbh,
+		      $range_loop_count);
+  time_fetch_all_rows(undef, "select_join_in",
+		      "SELECT $t1.* FROM $t1,$t2 WHERE $t1.$id=$t2.$id",
+		       $dbh, $range_loop_count);
+}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ac12adb50e0..56e3d562ee8 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1462,7 +1462,7 @@ longlong Item_func_get_lock::val_int()
   struct timespec abstime;
   THD *thd=current_thd;
   ULL *ull;
-  int error;
+  int error=0;
 
   pthread_mutex_lock(&LOCK_user_locks);
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1255b55a81c..7d6863cb6eb 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1241,6 +1241,12 @@ information that should help you find out what is causing the crash\n");
  exit(1);
 }
 
+#ifndef SA_RESETHAND
+#define SA_RESETHAND 0
+#endif
+#ifndef SA_NODEFER
+#define SA_NODEFER 0
+#endif
 
 static void init_signals(void)
 {
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index 408006dac93..81d8debc27a 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -17,6 +17,7 @@
 #include <global.h>
 #include "stacktrace.h"
 #include <signal.h>
+#include <my_pthread.h>
 
 #ifdef HAVE_STACKTRACE
 #include <unistd.h>

From 1e97b27ee2b908a17c12962778b82237934a6b73 Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Sun, 2 Sep 2001 16:56:51 +0300
Subject: [PATCH 51/51] Small changes in benchmark suite

sql-bench/test-insert.sh:
  Change IN() test to use LEFT JOIN to be comparable to IN()
---
 sql-bench/test-insert.sh | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh
index a5d0633dbfe..655e38b1b0e 100644
--- a/sql-bench/test-insert.sh
+++ b/sql-bench/test-insert.sh
@@ -1011,12 +1011,13 @@ if ($server->small_rollback_segment())
 ### Test speed of IN( value list)
 ###
 
-if ($limits->{'functions'})
+if ($limits->{'left_outer_join'})
 {
   if ($opt_lock_tables)
   {
     $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
   }
+  print "\n";
   do_many($dbh,$server->create("bench2",
 			       ["id int NOT NULL"],
 			       ["primary key (id)"]));
@@ -1029,13 +1030,8 @@ if ($limits->{'functions'})
       die $DBI::errstr;
   }
   test_where_in("bench1","bench2","id",1,10);
-  test_where_in("bench1","bench2","id",11,100);
+  test_where_in("bench1","bench2","id",11,min(100,$max_tests));
   test_where_in("bench1","bench2","id",101,min(1000,$max_tests));
-  test_where_in("bench1","bench2","id",1000,$max_tests/2);
-  if ($max_tests > 1000)
-  {
-    test_where_in("bench1","bench2","id",$max_tests/2+1,$max_tests);
-  }
   if ($opt_lock_tables)
   {
     $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
@@ -1647,7 +1643,7 @@ sub check_or_range
 }
 
 #
-# Test if SELECT ... WHERE id in(value-list)
+# General test of SELECT ... WHERE id in(value-list)
 #
 
 sub test_where_in
@@ -1673,10 +1669,10 @@ sub test_where_in
     $server->vacuum(1,\$dbh,"bench1");
   }
 
-  time_fetch_all_rows("\nTesting SELECT ... WHERE id in ($to values)",
+  time_fetch_all_rows("Testing SELECT ... WHERE id in ($to values)",
 		      "select_in", $query, $dbh,
 		      $range_loop_count);
   time_fetch_all_rows(undef, "select_join_in",
-		      "SELECT $t1.* FROM $t1,$t2 WHERE $t1.$id=$t2.$id",
+		      "SELECT $t1.* FROM $t2 left outer join $t1 on ($t1.$id=$t2.$id)",
 		       $dbh, $range_loop_count);
 }