diff --git a/Docs/manual.texi b/Docs/manual.texi
index 6910e273440e398adbb4c24c9e9069102e40a4b3..f42e6362d5d5385e2bb6340579c169064d7482a0 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -533,18 +533,18 @@ InnoDB Tables
 
 * InnoDB overview::             InnoDB tables overview
 * InnoDB start::                InnoDB startup options
-* Creating an InnoDB database:: Creating an InnoDB database.  Creating an InnoDB database
+* Creating an InnoDB database:: Creating an InnoDB database.
 * Using InnoDB tables::         Creating InnoDB tables
 * Adding and removing::         Adding and removing InnoDB data and log files
 * Backing up::                  Backing up and recovering an InnoDB database
 * Moving::                      Moving an InnoDB database to another machine
-* InnoDB transaction model:: InnoDB transaction model.  InnoDB transaction model
+* InnoDB transaction model::    InnoDB transaction model.
 * Implementation::              Implementation of multiversioning
 * Table and index::             Table and index structures
 * File space management::       File space management and disk i/o
 * Error handling::              Error handling
 * InnoDB restrictions::         Some restrictions on InnoDB tables
-* InnoDB contact information:: InnoDB contact information.  InnoDB contact information
+* InnoDB contact information::  InnoDB contact information.
 
 MySQL Tutorial
 
@@ -666,7 +666,7 @@ Speed of Queries that Access or Update Data
 MySQL Utilites
 
 * Programs::                    What do the executables do?
-* mysqld-max::                  
+* mysqld-max::                  mysqld-max, An extended mysqld server
 * safe_mysqld::                 safe_mysqld, the wrapper around mysqld
 * mysqld_multi::                Program for managing multiple @strong{MySQL} servers
 * mysql::                       The command line tool
@@ -759,6 +759,7 @@ Problems and Common Errors
 * 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::    
 
 Some Common Errors When Using MySQL
 
@@ -926,7 +927,7 @@ Changes in release 4.0.x (Development; Alpha)
 
 Changes in release 3.23.x  (Stable)
 
-* News-3.23.38::                
+* News-3.23.38::                Changes in release 3.23.38
 * News-3.23.37::                Changes in release 3.23.37
 * News-3.23.36::                Changes in release 3.23.36
 * News-3.23.35::                Changes in release 3.23.35
@@ -2442,7 +2443,7 @@ New Client libraries for the Mac OS Classic (Macintosh).
 @item @uref{http://www.lilback.com/macsql/}
 Client libraries for Mac OS Classic (Macintosh).
 
-@item @uref{http://mapage.noos.fr/vpenvern01/index_en.html}
+@item @uref{http://sixk.maniasys.com/index_en.html}
 MySQL for Amiga
 @end table
 
@@ -3104,8 +3105,23 @@ unsubscribe from the @code{myodbc} list, send a message to
 @email{myodbc-subscribe@@lists.mysql.com} or
 @email{myodbc-unsubscribe@@lists.mysql.com}.
 
-There is also a german mailing list.  You can find information about this
-at: @uref{http://www.4t2.com/mysql}.
+The following table shows some @strong{MySQL} mailing in other languages than
+English.  Note that these are not operated by @strong{MySQL AB}, so we can't
+guarantee the quality on these.
+
+@table @code
+@item @email{mysql-france-subscribe@@yahoogroups.com, A French mailing list}
+@item @email{list@@tinc.net, A Korean mailing list}
+Email @code{subscribe mysql your@@email.address} to this list.
+@item @email{mysql-de-request@@lists.4t2.com, A German mailing list}
+Email @code{subscribe mysql-de your@@email.address} to this list.
+You can find information about this mailing list at
+@uref{http://www.4t2.com/mysql}.
+@item @email{mysql-br-request@@listas.linkway.com.br, A Portugese mailing list}
+Email @code{subscribe mysql-br your@@email.address} to this list.
+@item @email{mysql-alta@@elistas.net, A Spanish mailing list}
+Email @code{subscribe mysql your@@email.address} to this list.
+@end table
 
 @cindex net etiquette
 @cindex mailing lists, archive location
@@ -8680,6 +8696,16 @@ The optimization flags used by @strong{MySQL} (-O3) are not recognized by HP's
 compilers.  I did not change the flags.
 @end itemize
 
+If you get the following error from @code{configure}
+
+@example
+checking for cc option to accept ANSI C... no
+configure: error: MySQL requires a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.
+@end example
+
+Check that you don't have the path to the K&R compiler before the path
+to the HP-UX C and C++ compiler.
+
 @node Mac OS X, BEOS, HP-UX 11.x, Source install system issues
 @subsection Mac OS X Notes
 
@@ -18181,6 +18207,11 @@ per-connection basis.  It will not be changed by another client. It will not
 even be changed if you update another @code{AUTO_INCREMENT} column with a
 non-magic value (that is, a value that is not @code{NULL} and not @code{0}).
 
+If you insert many rows at the same time with an insert statement,
+@code{LAST_INSERT_ID()} returns the value for the first inserted row.
+The reason for this is so that you it makes it possible to easily reproduce
+the same @code{INSERT} statement against some other server.
+
 @cindex sequence emulation
 If @code{expr} is given as an argument to @code{LAST_INSERT_ID()} in an
 @code{UPDATE} clause, then the value of the argument is returned as a
@@ -24378,18 +24409,18 @@ NuSphere is working on removing these limitations.
 @menu
 * InnoDB overview::             InnoDB tables overview
 * InnoDB start::                InnoDB startup options
-* Creating an InnoDB database:: Creating an InnoDB database.  Creating an InnoDB database
+* Creating an InnoDB database:: Creating an InnoDB database.
 * Using InnoDB tables::         Creating InnoDB tables
 * Adding and removing::         Adding and removing InnoDB data and log files
 * Backing up::                  Backing up and recovering an InnoDB database
 * Moving::                      Moving an InnoDB database to another machine
-* InnoDB transaction model:: InnoDB transaction model.  InnoDB transaction model
+* InnoDB transaction model::    InnoDB transaction model.
 * Implementation::              Implementation of multiversioning
 * Table and index::             Table and index structures
 * File space management::       File space management and disk i/o
 * Error handling::              Error handling
 * InnoDB restrictions::         Some restrictions on InnoDB tables
-* InnoDB contact information:: InnoDB contact information.  InnoDB contact information
+* InnoDB contact information::  InnoDB contact information. 
 @end menu
 
 @node InnoDB overview, InnoDB start, InnoDB, InnoDB
@@ -24399,55 +24430,56 @@ InnoDB tables are included in the @strong{MySQL} source distribution
 starting from 3.23.34a and are activated in the @strong{MySQL -max}
 binary.
 
-If you have downloaded a binary version of MySQL that includes
-support for InnoDB, simply follow the instructions for
-installing a binary version of MySQL.
-See section 4.6 'Installing a MySQL Binary Distribution'.
+If you have downloaded a binary version of @strong{MySQL} that includes
+support for InnoDB (mysqld-max), simply follow the instructions for
+installing a binary version of @strong{MySQL}. @xref{Installing binary}.
+@xref{mysqld-max}.
 
-To compile MySQL with InnoDB support, download MySQL-3.23.34a or newer
-and configure @code{MySQL} with the
-@code{--with-innobase} option. Starting from MySQL-3.23.37 the option
-is @code{--with-innodb}. See section
-4.7 'Installing a MySQL Source Distribution'.
+To compile @strong{MySQL} with InnoDB support, download MySQL-3.23.37 or newer
+and configure @code{MySQL} with the @code{--with-innodb} option.
+@xref{Installing source}.
 
 @example
 cd /path/to/source/of/mysql-3.23.37
 ./configure --with-innodb
 @end example
 
-InnoDB provides MySQL with a transaction safe table handler with
+InnoDB provides @strong{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
 non-locking read in @code{SELECTS}, which increases transaction
 concurrency. There is not need for lock escalation in InnoDB,
 because row level locks in InnoDB fit in very small space.
 
-Technically, InnoDB is a database backend placed under MySQL. InnoDB
+Technically, InnoDB is a database backend placed under @strong{MySQL}. InnoDB
 has its own buffer pool for caching data and indexes in main
 memory. InnoDB stores its tables and indexes in a tablespace, which
 may consist of several files. This is different from, for example,
 @code{MyISAM} tables where each table is stored as a separate file.
 
 InnoDB is distributed under the GNU GPL License Version 2 (of June 1991).
-In the source distribution of MySQL, InnoDB appears as a subdirectory.
+In the source distribution of @strong{MySQL}, InnoDB appears as a subdirectory.
 
 @node InnoDB start, Creating an InnoDB database, InnoDB overview, InnoDB
 @subsection InnoDB startup options
 
-Beginning from MySQL-3.23.37 the prefix of the options is changed
+Beginning from @strong{MySQL}-3.23.37 the prefix of the options is changed
 from @code{innobase_...} to @code{innodb_...}.
 
-To use InnoDB tables you must specify configuration parameters
-in the MySQL configuration file in the @code{[mysqld]} section of
-the configuration file @file{my.cnf}.
-Suppose you have a Windows NT machine with 128 MB RAM and a
-single 10 GB hard disk.
-Below is an example of possible configuration parameters in @file{my.cnf} for
-InnoDB:
+To use InnoDB tables you @strong{MUST} specify configuration parameters
+in the @strong{MySQL} configuration file in the @code{[mysqld]} section of
+the configuration file @file{my.cnf}. @xref{Option files}.
+
+The only required parameter to use InnoDB is @code{innodb_data_file_path},
+but you should set others if you want to get a better performance.
+
+Suppose you have a Windows NT machine with 128 MB RAM and a single 10 GB
+hard disk.  Below is an example of possible configuration parameters in
+@file{my.cnf} for InnoDB:
 
 @example
-innodb_data_home_dir = c:\ibdata
 innodb_data_file_path = ibdata1:2000M;ibdata2:2000M
+innodb_data_home_dir = c:\ibdata
 set-variable = innodb_mirrored_log_groups=1
 innodb_log_group_home_dir = c:\iblogs
 set-variable = innodb_log_files_in_group=3
@@ -24469,8 +24501,8 @@ Below is an example of possible configuration parameters in @file{my.cnf} for
 InnoDB:
 
 @example
-innodb_data_home_dir = /
 innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M
+innodb_data_home_dir = /
 set-variable = innodb_mirrored_log_groups=1
 innodb_log_group_home_dir = /dr3
 set-variable = innodb_log_files_in_group=3
@@ -24540,7 +24572,7 @@ log archiving.  The value of this parameter should currently be set the
 same as @code{innodb_log_group_home_dir}.
 @item @code{innodb_log_archive} @tab 
 This value should currently be set to 0.  As recovery from a backup is
-done by MySQL using its own log files, there is currently no need to
+done by @strong{MySQL} using its own log files, there is currently no need to
 archive InnoDB log files.
 @item @code{innodb_buffer_pool_size} @tab 
 The size of the memory buffer InnoDB uses to cache data and indexes of
@@ -24555,7 +24587,7 @@ and other internal data structures. A sensible value for this might be
 2M, but the more tables you have in your application the more you will
 need to allocate here. If InnoDB runs out of memory in this pool, it
 will start to allocate memory from the operating system, and write
-warning messages to the MySQL error log.
+warning messages to the @strong{MySQL} error log.
 @item @code{innodb_file_io_threads} @tab 
 Number of file i/o threads in InnoDB. Normally, this should be 4, but
 on Windows NT disk i/o may benefit from a larger number.
@@ -24572,15 +24604,15 @@ resolve the situation.
 @node Creating an InnoDB database, Using InnoDB tables, InnoDB start, InnoDB
 @subsection Creating an InnoDB database
 
-Suppose you have installed MySQL and have edited @file{my.cnf} so that
+Suppose you have installed @strong{MySQL} and have edited @file{my.cnf} so that
 it contains the necessary InnoDB configuration parameters.
-Before starting MySQL you should check that the directories you have
+Before starting @strong{MySQL} you should check that the directories you have
 specified for InnoDB data files and log files exist and that you have
 access rights to those directories. InnoDB
 cannot create directories, only files. Check also you have enough disk space
 for the data and log files.
 
-When you now start MySQL, InnoDB will start creating your data files
+When you now start @strong{MySQL}, InnoDB will start creating your data files
 and log files. InnoDB will print something like the following:
 
 @example
@@ -24605,9 +24637,9 @@ InnoDB: Started
 mysqld: ready for connections
 @end example
 
-A new InnoDB database has now been created. You can connect to the MySQL
-server with the usual MySQL client programs like @code{mysql}.
-When you shut down the MySQL server with @file{mysqladmin shutdown},
+A new InnoDB database has now been created. You can connect to the @strong{MySQL}
+server with the usual @strong{MySQL} client programs like @code{mysql}.
+When you shut down the @strong{MySQL} server with @file{mysqladmin shutdown},
 InnoDB output will be like the following:
 
 @example
@@ -24622,7 +24654,7 @@ will see the files created. The log directory will also contain
 a small file named @file{ib_arch_log_0000000000}. That file
 resulted from the database creation, after which InnoDB switched off
 log archiving.
-When MySQL is again started, the output will be like the following:
+When @strong{MySQL} is again started, the output will be like the following:
 
 @example
 ~/mysqlm/sql > mysqld
@@ -24632,17 +24664,17 @@ mysqld: ready for connections
 
 @subsubsection If something goes wrong in database creation
 
-If something goes wrong in an InnoDB database creation, you should delete
-all files created by InnoDB. This means all data files, all log files,
-the small archived log file, and in the case you already did create
-some InnoDB tables, delete also the corresponding @file{.frm}
-files for these tables from the MySQL database directories. Then you can
-try the InnoDB database creation again.
+If something goes wrong in an InnoDB database creation, you should
+delete all files created by InnoDB. This means all data files, all log
+files, the small archived log file, and in the case you already did
+create some InnoDB tables, delete also the corresponding @file{.frm}
+files for these tables from the @strong{MySQL} database
+directories. Then you can try the InnoDB database creation again.
 
 @node Using InnoDB tables, Adding and removing, Creating an InnoDB database, InnoDB
 @subsection Creating InnoDB tables
 
-Suppose you have started the MySQL client with the command
+Suppose you have started the @strong{MySQL} client with the command
 @code{mysql test}.
 To create a table in the InnoDB format you must specify
 @code{TYPE = InnoDB} in the table creation SQL command:
@@ -24653,15 +24685,15 @@ CREATE TABLE CUSTOMER (A INT, B CHAR (20), INDEX (A)) TYPE = InnoDB;
 
 This SQL command will create a table and an index on column @code{A}
 into the InnoDB tablespace consisting of the data files you specified
-in @file{my.cnf}. In addition MySQL will create a file
-@file{CUSTOMER.frm} to the MySQL database directory @file{test}.
+in @file{my.cnf}. In addition @strong{MySQL} will create a file
+@file{CUSTOMER.frm} to the @strong{MySQL} database directory @file{test}.
 Internally, InnoDB will add to its own data dictionary an entry
 for table @code{'test/CUSTOMER'}. Thus you can create a table
-of the same name @code{CUSTOMER} in another database of MySQL, and
+of the same name @code{CUSTOMER} in another database of @strong{MySQL}, and
 the table names will not collide inside InnoDB.
 
 You can query the amount of free space in the InnoDB tablespace
-by issuing the table status command of MySQL for any table you have
+by issuing the table status command of @strong{MySQL} for any table you have
 created with @code{TYPE = InnoDB}. Then the amount of free
 space in the tablespace appears in the table comment section in the
 output of @code{SHOW}. An example:
@@ -24679,7 +24711,7 @@ You must drop the tables individually. Also take care not to delete or
 add @file{.frm} files to your InnoDB database manually: use
 @code{CREATE TABLE} and @code{DROP TABLE} commands.
 InnoDB has its own internal data dictionary, and you will get problems
-if the MySQL @file{.frm} files are out of 'sync' with the InnoDB
+if the @strong{MySQL} @file{.frm} files are out of 'sync' with the InnoDB
 internal data dictionary.
 
 @node Adding and removing, Backing up, Using InnoDB tables, InnoDB
@@ -24687,8 +24719,8 @@ internal data dictionary.
 
 You cannot increase the size of an InnoDB data file. To add more into
 your tablespace you have to add a new data file. To do this you have to
-shut down your MySQL database, edit the @file{my.cnf} file, adding a
-new file to @code{innodb_data_file_path}, and then start MySQL
+shut down your @strong{MySQL} database, edit the @file{my.cnf} file, adding a
+new file to @code{innodb_data_file_path}, and then start @strong{MySQL}
 again.
 
 Currently you cannot remove a data file from InnoDB. To decrease the
@@ -24697,11 +24729,11 @@ all your tables, create a new database, and import your tables to the
 new database.
 
 If you want to change the number or the size of your InnoDB log files,
-you have to shut down MySQL and make sure that it shuts down without errors.
+you have to shut down @strong{MySQL} and make sure that it shuts down without errors.
 Then copy the old log files into a safe place just in case something
 went wrong in the shutdown and you will need them to recover the
 database. Delete then the old log files from the log file directory,
-edit @file{my.cnf}, and start MySQL again. InnoDB will tell
+edit @file{my.cnf}, and start @strong{MySQL} again. InnoDB will tell
 you at the startup that it is creating new log files.
 
 @node Backing up, Moving, Adding and removing, InnoDB
@@ -24712,7 +24744,7 @@ To take a 'binary' backup of your database you have to do the following:
 
 @itemize @bullet
 @item
-Shut down your MySQL database and make sure it shuts down without errors.
+Shut down your @strong{MySQL} database and make sure it shuts down without errors.
 @item
 Copy all your data files into a safe place.
 @item
@@ -24743,12 +24775,12 @@ dumps. Then you can take the binary backup, and you will then have
 a consistent snapshot of your database in two formats. 
 
 To be able to recover your InnoDB database to the present from the
-binary backup described above, you have to run your MySQL database
-with the general logging and log archiving of MySQL switched on. Here
-by the general logging we mean the logging mechanism of the MySQL server
+binary backup described above, you have to run your @strong{MySQL} database
+with the general logging and log archiving of @strong{MySQL} switched on. Here
+by the general logging we mean the logging mechanism of the @strong{MySQL} server
 which is independent of InnoDB logs.
 
-To recover from a crash of your MySQL server process, the only thing
+To recover from a crash of your @strong{MySQL} server process, the only thing
 you have to do is to restart it. InnoDB will automatically check the
 logs and perform a roll-forward of the database to the present.
 InnoDB will automatically roll back uncommitted transactions which were
@@ -24783,7 +24815,7 @@ mysqld: ready for connections
 If your database gets corrupted or your disk fails, you have
 to do the recovery from a backup. In the case of corruption, you should
 first find a backup which is not corrupted. From a backup do the recovery
-from the general log files of MySQL according to instructions in the
+from the general log files of @strong{MySQL} according to instructions in the
 MySQL manual.
 
 @subsubsection Checkpoints
@@ -24849,7 +24881,7 @@ to lock every row in the database, or any random subset of the rows,
 without InnoDB running out of memory.
 
 In InnoDB all user activity happens inside transactions. If the
-auto commit mode is used in MySQL, then each SQL statement
+auto commit mode is used in @strong{MySQL}, then each SQL statement
 will form a single transaction. If the auto commit mode is
 switched off, then we can think that a user always has a transaction
 open. If he issues
@@ -25017,7 +25049,7 @@ on the duplicate index record.
 @code{INSERT INTO T SELECT ... FROM S WHERE ...} sets an exclusive
 (non-next-key) lock on each row inserted into @code{T}. Does
 the search on @code{S} as a consistent read, but sets shared next-key
-locks on @code{S} if the MySQL logging is on. InnoDB has to set
+locks on @code{S} if the @strong{MySQL} logging is on. InnoDB has to set
 locks in the latter case because in roll-forward recovery from a
 backup every SQL statement has to be executed in exactly the same
 way as it was done originally.
@@ -25037,10 +25069,10 @@ lock on every record the search encounters.
 lock on every record the search encounters.
 @item
 @code{LOCK TABLES ... } : sets table locks. In the implementation
-the MySQL layer of code sets these locks. The automatic deadlock detection
+the @strong{MySQL} layer of code sets these locks. The automatic deadlock detection
 of InnoDB cannot detect deadlocks where such table locks are involved:
 see the next section below. See also section 13 'InnoDB restrictions'
-about the following: since MySQL does know about row level locks,
+about the following: since @strong{MySQL} does know about row level locks,
 it is possible that you
 get a table lock on a table where another user currently has row level
 locks. But that does not put transaction integerity into danger.
@@ -25051,7 +25083,7 @@ locks. But that does not put transaction integerity into danger.
 InnoDB automatically detects a deadlock of transactions and rolls
 back the transaction whose lock request was the last one to build
 a deadlock, that is, a cycle in the waits-for graph of transactions.
-InnoDB cannot detect deadlocks where a lock set by a MySQL
+InnoDB cannot detect deadlocks where a lock set by a @strong{MySQL}
 @code{LOCK TABLES} statement is involved, or if a lock set
 in another table handler than InnoDB is involved. You have to resolve
 these situations using @code{innodb_lock_wait_timeout} set in
@@ -25318,7 +25350,7 @@ The following list specifies the error handling of InnoDB.
 @itemize @bullet
 @item
 If you run out of file space in the tablespace,
-you will get the MySQL @code{'Table is full'} error
+you will get the @strong{MySQL} @code{'Table is full'} error
 and InnoDB rolls back the SQL statement.
 @item
 A transaction deadlock or a timeout in a lock wait will give
@@ -25333,7 +25365,7 @@ statement.
 @item
 A 'row too long' error rolls back the SQL statement.
 @item
-Other errors are mostly detected by the MySQL layer of code, and
+Other errors are mostly detected by the @strong{MySQL} layer of code, and
 they roll back the corresponding SQL statement.
 @end itemize
 
@@ -25353,7 +25385,7 @@ where only the first 5 characters from column @code{A} are stored.
 @item
 @code{INSERT DELAYED} is not supported for InnoDB tables.
 @item
-The MySQL @code{LOCK TABLES} operation does not know of InnoDB
+The @strong{MySQL} @code{LOCK TABLES} operation does not know of InnoDB
 row level locks set in already completed SQL statements: this means that
 you can get a table lock on a table even if there still exist transactions
 of other users which have row level locks on the same table. Thus
@@ -25370,7 +25402,7 @@ A table cannot contain more than 1000 columns.
 @item
 @code{DELETE FROM TABLE} does not regenerate the table but instead
 deletes all rows, one by one, which is not that fast. In future versions
-of MySQL you can use @code{TRUNCATE} which is fast.
+of @strong{MySQL} you can use @code{TRUNCATE} which is fast.
 @item
 Before dropping a database with InnoDB tables one has to drop
 the individual InnoDB tables first.
@@ -31454,7 +31486,7 @@ We can find the result from crash-me on a lot of different databases at
 
 @menu
 * Programs::                    What do the executables do?
-* mysqld-max::                  
+* mysqld-max::                  mysqld-max, An extended mysqld server
 * safe_mysqld::                 safe_mysqld, the wrapper around mysqld
 * mysqld_multi::                Program for managing multiple @strong{MySQL} servers
 * mysql::                       The command line tool
@@ -31639,6 +31671,13 @@ The meaning of the values are:
 @item DISABLED @tab The xxxx option is disabled because one started @code{mysqld} with @code{--skip-xxxx} or because one didn't start @code{mysqld} with all needed options to enable the option.  In this case the @code{hostname.err} file should contain a reason for why the option is disabled.
 @end multitable
 
+@strong{NOTE}:  To be able to create InnoDB tables you @strong{MUST} edit
+your startup options to include at least the @code{innodb_data_file_path}
+option. @xref{InnoDB start}.
+
+To get better performance for BDB tables, you should add some configuration
+options for these too. @xref{BDB start}.
+
 @code{safe_mysqld} will automaticly try to start any @code{mysqld} binary
 with the @code{-max} prefix. This makes it very easy to test out a
 another @code{mysqld} binary in an existing installation.  Just
@@ -31660,6 +31699,7 @@ binaries includes:
 @item HPUX 11.0 @tab N @tab Y
 @item Linux-Alpha @tab N	@tab Y
 @item Linux-Intel @tab Y @tab Y
+@item Linux-Ia64 @tab N @tab Y
 @item Solaris-intel @tab N @tab Y
 @item Solaris-sparc @tab Y @tab Y
 @item SCO OSR5 @tab Y @tab Y
@@ -35609,6 +35649,8 @@ INSERT INTO foo (auto,text) VALUES(NULL,'text');
 INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text');
 @end example
 
+@xref{Getting unique ID}.
+
 For the benefit of some ODBC applications (at least Delphi and Access),
 the following query can be used to find a newly inserted row:
 @example
@@ -35769,6 +35811,7 @@ pre-allocated MYSQL struct.
 * 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::    
 @end menu
 
 This chapter lists some common problems and error messages that users have
@@ -37315,7 +37358,7 @@ simple rename should get your data back.
 @cindex columns, changing
 @cindex changing, column order
 @cindex tables, changing column order
-@node Change column order,  , ALTER TABLE problems, Problems
+@node Change column order, Temporary table problems, ALTER TABLE problems, Problems
 @section How To Change the Order of Columns in a Table
 
 The whole point of SQL is to abstract the application from the data
@@ -37354,6 +37397,32 @@ Drop or rename @code{old_table}.
 @code{ALTER TABLE new_table RENAME old_table}.
 @end enumerate
 
+@cindex temporary tables, problems
+@node Temporary table problems,  , Change column order, Problems
+@section TEMPORARY TABLE problems
+
+The following are a list of the limitations with @code{TEMPORARY TABLES}.
+
+@itemize @bullet
+@item
+A temporary table can only be of type @code{HEAP}, @code{ISAM} or
+@code{MyISAM}.
+@item
+You can't use temporary tables more than once in the same query.
+For example, the following doesn't work.
+
+@example
+select * from temporary_table, temporary_table as t2;
+@end example
+
+We plan to fix the above in 4.0.
+@item
+You can't use @code{RENAME} on a @code{TEMPORARY} table.
+Note that @code{ALTER TABLE org_name RENAME new_name} works!
+
+We plan to fix the above in 4.0.
+@end itemize
+
 @cindex problems, solving
 @cindex solving, problems
 @cindex databases, replicating
@@ -43981,6 +44050,10 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.38
 @itemize @bullet
 @item
+@code{SHOW CREATE TABLE} now returns @code{TEMPORARY} for temporary tables.
+@item
+Added @code{Rows_examined} to slow query log.
+@item
 Fixed problems with function returning empty string when using
 together with a group functions and a @code{WHERE} that didn't match any rows.
 @item
@@ -49028,11 +49101,15 @@ mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1;
 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.
 
 @example
 select * from temporary_table, temporary_table as t2;
 @end example
 
+@item
+@code{RENAME} doesn't work with @code{TEMPORARY} tables.
+
 @item
 The optimizer may handle @code{DISTINCT} differently if you are using
 'hidden' columns in a join or not.  In a join, hidden columns are
diff --git a/acinclude.m4 b/acinclude.m4
index f6e880c7c08f30f98d40def9d24284a358651d62..ab2ea5cddd1f00dc425bfb944db045799e47c8d8 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -199,7 +199,7 @@ fi
 
 AC_DEFUN(MYSQL_PTHREAD_YIELD,
 [AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg,
-[AC_TRY_COMPILE([#define _GNU_SOURCE
+[AC_TRY_LINK([#define _GNU_SOURCE
 #include <pthread.h>
 #ifdef __cplusplus
 extern "C"
@@ -214,7 +214,7 @@ then
 fi
 ]
 [AC_CACHE_CHECK([if pthread_yield takes 1 argument], ac_cv_pthread_yield_one_arg,
-[AC_TRY_COMPILE([#define _GNU_SOURCE
+[AC_TRY_LINK([#define _GNU_SOURCE
 #include <pthread.h>
 #ifdef __cplusplus
 extern "C"
@@ -550,7 +550,8 @@ AC_DEFUN(MYSQL_STACK_DIRECTION,
 
 AC_DEFUN(MYSQL_FUNC_ALLOCA,
 [
-# Since we have heard that alloca fails on IRIX never define it on a SGI machine
+# Since we have heard that alloca fails on IRIX never define it on a
+# SGI machine
 if test ! "$host_vendor" = "sgi"
 then
  AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally.
diff --git a/client/errmsg.c b/client/errmsg.c
index a31386e70b4725db5f276c19bf0a7a74e8dd4829..711228e459d1b1dad281e0d8272ad3ddbdca2e74 100644
--- a/client/errmsg.c
+++ b/client/errmsg.c
@@ -36,14 +36,16 @@ const char *client_errors[]=
   "MySQL client got out of memory",
   "Wrong host info",
   "Localhost via UNIX socket",
-  "%s via TCP/IP",
+  "%-.64s via TCP/IP",
   "Error in server handshake",
   "Lost connection to MySQL server during query",
   "Commands out of sync; You can't run this command now",
   "Verbindung ueber Named Pipe; Host: %-.64s",
   "Kann nicht auf Named Pipe warten. Host: %-.64s  pipe: %-.32s (%lu)",
   "Kann Named Pipe nicht oeffnen. Host: %-.64s  pipe: %-.32s (%lu)",
-  "Kann den Status der Named Pipe nicht setzen.  Host: %-.64s  pipe: %-.32s (%lu)"
+  "Kann den Status der Named Pipe nicht setzen.  Host: %-.64s  pipe: %-.32s (%lu)",
+  "Can't initialize character set %-.64s (path: %-.64s)",
+  "Got packet bigger than 'max_allowed_packet'"
 };
 
 #else /* ENGLISH */
@@ -60,19 +62,21 @@ const char *client_errors[]=
   "MySQL client run out of memory",
   "Wrong host info",
   "Localhost via UNIX socket",
-  "%s via TCP/IP",
+  "%-.64s via TCP/IP",
   "Error in server handshake",
   "Lost connection to MySQL server during query",
   "Commands out of sync;  You can't run this command now",
-  "%s via named pipe",
+  "%-.64s via named pipe",
   "Can't wait for named pipe to host: %-.64s  pipe: %-.32s (%lu)",
   "Can't open named pipe to host: %-.64s  pipe: %-.32s (%lu)",
   "Can't set state of named pipe to host: %-.64s  pipe: %-.32s (%lu)",
+  "Can't initialize character set %-.64s (path: %-.64s)",
+  "Got packet bigger than 'max_allowed_packet'"
 };
 #endif
 
 
 void init_client_errs(void)
 {
-  errmsg[CLIENT_ERRMAP] = &client_errors[0];
+  my_errmsg[CLIENT_ERRMAP] = &client_errors[0];
 }
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index bda86c881e3dfeace79783e56ea7766933237a57..007be803cfcf95df7142edf8c6c52069b523d4f1 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -28,7 +28,7 @@
 #include <my_pthread.h>				/* because of signal()	*/
 #endif
 
-#define ADMIN_VERSION "8.19"
+#define ADMIN_VERSION "8.20"
 #define MAX_MYSQL_VAR 64
 #define SHUTDOWN_DEF_TIMEOUT 3600		/* Wait for shutdown */
 #define MAX_TRUNC_LENGTH 3
@@ -423,13 +423,8 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
 	my_printf_error(0,"Too few arguments to drop",MYF(ME_BELL));
 	return 1;
       }
-      sprintf(buff,"drop database `%.*s`",FN_REFLEN,argv[1]);
-      if (mysql_query(mysql,buff))
-      {
-	my_printf_error(0,"DROP DATABASE failed; error: '%-.200s'",
-			MYF(ME_BELL), mysql_error(mysql));
+      if (drop_db(mysql,argv[1]))
 	return 1;
-      }
       argc--; argv++;
       break;
     }
@@ -867,7 +862,8 @@ static int drop_db(MYSQL *mysql, const char *db)
   {
     puts("Dropping the database is potentially a very bad thing to do.");
     puts("Any data stored in the database will be destroyed.\n");
-    printf("Do you really want to drop the '%s' database [y/N]\n",db);
+    printf("Do you really want to drop the '%s' database [y/N] ",db);
+    fflush(stdout);
     VOID(fgets(buf,sizeof(buf)-1,stdin));
     if ((*buf != 'y') && (*buf != 'Y'))
     {
@@ -878,7 +874,7 @@ static int drop_db(MYSQL *mysql, const char *db)
   sprintf(name_buff,"drop database %.*s",FN_REFLEN,db);
   if (mysql_query(mysql,name_buff))
   {
-    my_printf_error(0,"drop of '%s' failed;\nerror: '%s'",MYF(ME_BELL),
+    my_printf_error(0,"DROP DATABASE %s failed;\nerror: '%s'",MYF(ME_BELL),
 		    db,mysql_error(mysql));
     return 1;
   }
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 8714b3c382a8e3bc2db7518a7bd844ae4d1687b1..5eaefe165d7f335f72bd59e67da6e053ce0e918a 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -569,7 +569,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
   else
     {
       v->str_val = (char*)p;
-      v->str_val_len = (p_end && *p_end) ? *p_end - p : strlen(p);
+      v->str_val_len = (p_end && *p_end) ? (int) (*p_end - p) : (int) strlen(p);
       v->int_val=atoi(p);
       v->int_dirty=0;
       return 0;
diff --git a/configure.in b/configure.in
index c22014eaa19ed8bbd6131c2edbcb899d62646834..021f25308d8b23640b6cf76e604a2670a00fa56e 100644
--- a/configure.in
+++ b/configure.in
@@ -119,6 +119,17 @@ AC_PROG_AWK
 AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_CPP
+
+# Fix for sgi gcc / sgiCC which tries to emulate gcc
+if test "$CC" = "sgicc"
+then
+  ac_cv_prog_gcc="no"
+fi
+if test "$CXX" = "sgi++"
+then
+  GXX="no"
+fi
+
 if test "$ac_cv_prog_gcc" = "yes"
 then
   AS="$CC -c"
@@ -390,7 +401,7 @@ AM_PROG_CC_STDC
 
 if test "$am_cv_prog_cc_stdc" = "no"
 then
-  AC_MSG_ERROR([MySQL requiers a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.])
+  AC_MSG_ERROR([MySQL requires a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.])
 fi
 
 NOINST_LDFLAGS=
@@ -1215,7 +1226,7 @@ fi
 AC_SUBST(COMPILATION_COMMENT)
 
 AC_MSG_CHECKING("need of special linking flags")
-if test "$IS_LINUX" = "true" -a "$all_is_static" != "yes"
+if test "$IS_LINUX" = "true" -a "$ac_cv_prog_gcc" = "yes" -a "$all_is_static" != "yes"
 then
   LDFLAGS="$LDFLAGS -rdynamic"
   AC_MSG_RESULT("-rdynamic")
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index 8976a7698b8fdadca097dc9f5f689d1aba86d7dc..bda23a41efd7d63bae98ea9810d611b40555deb1 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -303,7 +303,7 @@ static void do_resolve()
 	  uchar* addr = (uchar*)read_addr(&p);
 	  if(resolve_addr(addr, &se))
 	    fprintf(fp_out, "%p %s + %d\n", addr, se.symbol,
-		    addr - se.addr);
+		    (int) (addr - se.addr));
 	  else
 	    fprintf(fp_out, "%p (?)\n", addr);
 	    
diff --git a/include/global.h b/include/global.h
index 2c9157630f40b399a4a59c6405ef0c95a4178293..a11600a96fc8bd662e59e158cd242148c1e623eb 100644
--- a/include/global.h
+++ b/include/global.h
@@ -332,7 +332,8 @@ typedef int	File;		/* File descriptor */
 typedef int	my_socket;	/* File descriptor for sockets */
 #define INVALID_SOCKET -1
 #endif
-typedef RETSIGTYPE sig_handler; /* Function to handle signals */
+/* Type for fuctions that handles signals */
+#define sig_handler RETSIGTYPE
 typedef void	(*sig_return)();/* Returns type from signal */
 #if defined(__GNUC__) && !defined(_lint)
 typedef char	pchar;		/* Mixed prototypes can take char */
diff --git a/isam/_dbug.c b/isam/_dbug.c
index fd0a0b46562ba511e8ca9d0b48542da001dc89a2..d632d5931a58e7117101b1bbaeaabc25c554dbbd 100644
--- a/isam/_dbug.c
+++ b/isam/_dbug.c
@@ -85,7 +85,7 @@ void _nisam_print_key(FILE *stream, register N_KEYSEG *keyseg, const uchar *key)
       key=end;
       break;
     case HA_KEYTYPE_INT24:
-      VOID(fprintf(stream,"%ld",sint3korr(key)));
+      VOID(fprintf(stream,"%ld",(long) sint3korr(key)));
       key=end;
       break;
     case HA_KEYTYPE_UINT24:
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 008889ff521304bffb0a4d39980bd4f89da009a5..ece2e42f40b70bc48c79976f9a24102bfe09725a 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -369,6 +369,8 @@ mysql_install_db () {
 	error "Could not install slave test DBs"
 	exit 1
     fi
+    # Give mysqld some time to die.
+    sleep $SLEEP_TIME
     return 0
 }
 
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 8c50570a31d50b06cd4a39bae6dd15ead5de28a8..ce2e5d4f58d3b3c3325396bab143a6619000d911 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -67,3 +67,16 @@ t1	0	PRIMARY	1	f1	A	1	NULL	NULL
 t1	0	PRIMARY	2	f2	A	3	NULL	NULL	
 t1	0	PRIMARY	3	f3	A	9	NULL	NULL	
 t1	0	PRIMARY	4	f4	A	18	NULL	NULL	
+Table	Create Table
+t1	CREATE TEMPORARY TABLE `t1` (
+  `a` int(11) NOT NULL default '0'
+) TYPE=MyISAM
+Table	Create Table
+t2	CREATE TEMPORARY TABLE `t2` (
+  `a` int(11) NOT NULL default '0'
+) TYPE=MyISAM
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `test_set` set('val1','val2','val3') NOT NULL default '',
+  `name` char(20) default 'O''Brien'
+) TYPE=MyISAM COMMENT='it''s a table'
diff --git a/mysql-test/r/shw000001.result b/mysql-test/r/shw000001.result
deleted file mode 100644
index c8056c74f0b9b3ee063a65305ea94ac015374274..0000000000000000000000000000000000000000
--- a/mysql-test/r/shw000001.result
+++ /dev/null
@@ -1,5 +0,0 @@
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `test_set` set('val1','val2','val3') NOT NULL default '',
-  `name` char(20) default 'O''Brien'
-) TYPE=MyISAM COMMENT='it''s a table'
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index d4be1a6d25a97d1fec7d59956ec2e68b415c2e6c..f4f58c8c885279a2fc9a8e2ba664ee179887ee61 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -48,3 +48,20 @@ show index from t1;
 repair table t1;
 show index from t1;
 drop table t1;
+
+#
+# Test of SHOW CREATE
+#
+
+create temporary table t1 (a int not null);
+show create table t1;
+alter table t1 rename t2;
+show create table t2;
+drop table t2;
+
+create table t1 (
+  test_set set( 'val1', 'val2', 'val3' ) not null default '',
+  name char(20) default 'O''Brien'
+  ) comment = 'it\'s a table' ;
+show create table t1 ;
+drop table t1;
diff --git a/mysql-test/t/shw000001.test b/mysql-test/t/shw000001.test
deleted file mode 100644
index 6b24d8a44c7380b40c8d0df1cdc89f07ff0b8aff..0000000000000000000000000000000000000000
--- a/mysql-test/t/shw000001.test
+++ /dev/null
@@ -1,8 +0,0 @@
-use test;
-drop table if exists t1;
-create table t1 (
-  test_set set( 'val1', 'val2', 'val3' ) not null default '',
-  name char(20) default 'O''Brien'
-  ) comment = 'it\'s a table' ;
-show create table t1 ;
-drop table t1;
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 1216b231d6bf958eb1a3a9a0f4247c70fbf9ec3b..84dac59018b85f9c691edd59d5e313c57ae81446 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -62,9 +62,10 @@ do
 done
 
 for i in extra/comp_err extra/replace extra/perror extra/resolveip \
-  extra/my_print_defaults isam/isamchk isam/pack_isam myisam/myisamchk \
+  extra/my_print_defaults extra/resolve_stack_dump \
+  isam/isamchk isam/pack_isam myisam/myisamchk \
   myisam/myisampack sql/mysqld sql/mysqlbinlog \
-  client/mysql sql/mysqld client/mysqlshow \
+  client/mysql sql/mysqld client/mysqlshow client/mysqlcheck \
   client/mysqladmin client/mysqldump client/mysqlimport client/mysqltest \
   client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
   client/.libs/mysqldump client/.libs/mysqlimport client/.libs/mysqltest
diff --git a/sql/filesort.cc b/sql/filesort.cc
index e116e2b68e6b4a4c0f5b8979c74ca36915acd210..610fe2e966fccb61d1124d257ee1bc668f0d1d5c 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -49,7 +49,7 @@ typedef struct st_sort_param {
   uint sort_length;			/* Length of sortarg */
   uint keys;				/* Max antal nycklar / buffert */
   uint ref_length;			/* Length of record ref. */
-  ha_rows max_rows;
+  ha_rows max_rows,examined_rows;
   TABLE *sort_form;			/* For quicker make_sortkey */
   SORT_FIELD *local_sortorder;
   SORT_FIELD *end;
@@ -91,7 +91,8 @@ static uint sortlength(SORT_FIELD *sortorder,uint length);
 	 open a new file is opened */
 
 ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
-		 SQL_SELECT *select, ha_rows special, ha_rows max_rows)
+		 SQL_SELECT *select, ha_rows special, ha_rows max_rows,
+		 ha_rows *examined_rows)
 {
   int error;
   uint memavl,old_memavl,maxbuffer,skr;
@@ -113,6 +114,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
   param.ref_length= table[0]->file->ref_length;
   param.sort_length=sortlength(sortorder,s_length)+ param.ref_length;
   param.max_rows= max_rows;
+  param.examined_rows=0;
 
   if (select && select->quick)
   {
@@ -259,7 +261,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
     my_error(ER_FILSORT_ABORT,MYF(ME_ERROR+ME_WAITTANG));
   else
     statistic_add(filesort_rows, records, &LOCK_status);
-
+  *examined_rows= param.examined_rows;
 #ifdef SKIPP_DBUG_IN_FILESORT
   DBUG_POP();			/* Ok to DBUG */
 #endif
@@ -367,6 +369,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
       file->rnd_end();
       DBUG_RETURN(HA_POS_ERROR);		/* purecov: inspected */
     }
+    if (error == 0)
+      param->examined_rows++;
     if (error == 0 && (!select || select->skipp_record() == 0))
     {
       if (idx == param->keys)
diff --git a/sql/log.cc b/sql/log.cc
index 3e8be76aacb423fbdaacf677c6839ff57f4f272d..4cd932619732ef1177f2cd15f6dd9f4d0d062acd 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -841,11 +841,12 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
       {
 	/* For slow query log */
 	if (my_b_printf(&log_file,
-			"# Time: %lu  Lock_time: %lu  Rows_sent: %lu\n",
+			"# Time: %lu  Lock_time: %lu  Rows_sent: %lu  Rows_examined: %lu\n",
 			(ulong) (current_time - query_start),
 			(ulong) (thd->time_after_lock - query_start),
-			(ulong) thd->sent_row_count) == (uint) -1)
-	    tmp_errno=errno;
+			(ulong) thd->sent_row_count,
+			(ulong) thd->examined_row_count) == (uint) -1)
+	  tmp_errno=errno;
       }
       if (thd->db && strcmp(thd->db,db))
       {						// Database changed
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 78e9db5652f935652dfb6d1b35673836df0358ab..9c134183fdd7a811d7127929d95d917689e40890 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -602,7 +602,8 @@ void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
 		      int use_record_cache, bool print_errors);
 void end_read_record(READ_RECORD *info);
 ha_rows filesort(TABLE **form,struct st_sort_field *sortorder, uint s_length,
-		 SQL_SELECT *select, ha_rows special,ha_rows max_rows);
+		 SQL_SELECT *select, ha_rows special,ha_rows max_rows,
+		 ha_rows *examined_rows);
 void change_double_for_sort(double nr,byte *to);
 int get_quick_record(SQL_SELECT *select);
 int calc_weekday(long daynr,bool sunday_first_day_of_week);
diff --git a/sql/mysqlbinlog.cc b/sql/mysqlbinlog.cc
index 1ad6a4307103d30f1c0b120f36e1a1d44809c541..05ff166cd49be4df6e34e1f41693fbdeef305c97 100644
--- a/sql/mysqlbinlog.cc
+++ b/sql/mysqlbinlog.cc
@@ -58,6 +58,7 @@ static struct option long_options[] =
   {"table", 	required_argument, 	0, 't'},
   {"user",	required_argument,	0, 'u'},
   {"version",	 no_argument, 		0, 'V'},
+  {0, 0, 0, 0}
 };
 
 void sql_print_error(const char *format,...);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 48484aa168cdd707923e3b11663f187ee5a302e2..931a21c91918f18049a51172058e44a603f6d2bc 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1388,7 +1388,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
 	if (!(opt_specialflag & SPECIAL_NO_PRIOR))
 	  my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR);
 	if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
-			   (void*) sig))
+			   (void*) 0))
 	  sql_print_error("Error: Can't create thread to kill server");
 #else
 	  kill_server((void*) sig);		// MIT THREAD has a alarm thread
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 134449fd20a9fb6c4be8c038608d58731fe165cb..afff01e9a163eaf9855e7d867ac506437e9b2b55 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1508,8 +1508,9 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
   tmp_table->reginfo.lock_type=TL_WRITE;	// Simulate locked
   tmp_table->tmp_table = 1;
   tmp_table->table_cache_key=(char*) (tmp_table+1);
-  tmp_table->key_length= (uint) (strmov(strmov(tmp_table->table_cache_key,db)
-					+1, table_name)
+  tmp_table->key_length= (uint) (strmov((tmp_table->real_name=
+					 strmov(tmp_table->table_cache_key,db)
+					 +1), table_name)
 				 - tmp_table->table_cache_key)+1;
   int4store(tmp_table->table_cache_key + tmp_table->key_length,
 	    thd->slave_proxy_id);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index f7dc799113e16bca9eefa288dd50f1b73cc0b951..438898ca2945d3b3cc15b20bc712cace8cb4a967 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -268,7 +268,7 @@ class THD :public ilink {
 #endif  
   ulonglong  next_insert_id,last_insert_id,current_insert_id;
   ha_rows select_limit,offset_limit,default_select_limit,cuted_fields,
-          max_join_size,sent_row_count;
+          max_join_size, sent_row_count, examined_row_count;
   table_map	used_tables;
   ulong query_id,version, inactive_timeout,options,thread_id;
   ulong      gemini_spin_retries;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index f0cc3f9c42a306f832ee62064f23f79e9cacf499..7a94dc32997bbe117c0c0a2c06a75e6fe6635766 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2266,7 +2266,7 @@ mysql_init_query(THD *thd)
   thd->lex.table_list.next= (byte**) &thd->lex.table_list.first;
   thd->fatal_error=0;				// Safety
   thd->last_insert_id_used=thd->query_start_used=thd->insert_id_used=0;
-  thd->sent_row_count=0;
+  thd->sent_row_count=thd->examined_row_count=0;
   DBUG_VOID_RETURN;
 }
 
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a418af81187306f4987fda05ea00642c98d4885a..be1444c52e415d324bbb551db05cef378a5d0453 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -265,7 +265,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
   join.join_tab=0;
   join.tmp_table_param.copy_field=0;
   join.sum_funcs=0;
-  join.send_records=join.found_records=0;
+  join.send_records=join.found_records=join.examined_rows=0;
   join.tmp_table_param.end_write_records= HA_POS_ERROR;
   join.first_record=join.sort_and_group=0;
   join.select_options=select_options;
@@ -784,6 +784,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
   error=do_select(&join,&fields,NULL,procedure);
 
 err:
+  thd->examined_row_count=join.examined_rows;
   thd->proc_info="end";
   join.lock=0;					// It's faster to unlock later
   join_free(&join);
@@ -867,6 +868,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
     table->reginfo.not_exists_optimize=0;
     bzero((char*) table->const_key_parts, sizeof(key_part_map)*table->keys);
     all_table_map|= table->map;
+    s->join=join;
     if ((s->on_expr=tables->on_expr))
     {
       // table->maybe_null=table->outer_join=1;	// Mark for send fields
@@ -2219,6 +2221,7 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
   join_tab->ref.key = -1;
   join_tab->not_used_in_distinct=0;
   join_tab->read_first_record= join_init_read_record;
+  join_tab->join=join;
   bzero((char*) &join_tab->read_record,sizeof(join_tab->read_record));
   tmp_table->status=0;
   tmp_table->null_row=0;
@@ -3915,8 +3918,8 @@ bool create_myisam_from_heap(TABLE *table, TMP_TABLE_PARAM *param, int error,
   table->file=0;
   *table =new_table;
   table->file->change_table_ptr(table);
-
-  thd->proc_info=save_proc_info;
+  thd->proc_info= (!strcmp(save_proc_info,"Copying to tmp table") ?
+		   "Copying to tmp table on disk" : save_proc_info);
   DBUG_RETURN(0);
 
  err:
@@ -4096,6 +4099,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
     bool not_used_in_distinct=join_tab->not_used_in_distinct;
     ha_rows found_records=join->found_records;
     READ_RECORD *info= &join_tab->read_record;
+    join->examined_rows++;
 
     do
     {
@@ -4483,6 +4487,7 @@ join_init_read_next_with_key(READ_RECORD *info)
   return 0;
 }
 
+
 static int
 join_init_read_last_with_key(JOIN_TAB *tab)
 {
@@ -5204,6 +5209,7 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
 {
   SORT_FIELD *sortorder;
   uint length;
+  ha_rows examined_rows;
   TABLE *table=tab->table;
   SQL_SELECT *select=tab->select;
   DBUG_ENTER("create_sort_index");
@@ -5242,12 +5248,13 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
     }
   }
   table->found_records=filesort(&table,sortorder,length,
-				select, 0L, select_limit);
+				select, 0L, select_limit, &examined_rows);
   delete select;				// filesort did select
   tab->select=0;
   tab->select_cond=0;
   tab->type=JT_ALL;				// Read with normal read_record
   tab->read_first_record= join_init_read_record;
+  tab->join->examined_rows+=examined_rows;
   if (table->key_read)				// Restore if we used indexes
   {
     table->key_read=0;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 2f7454e40595f2bdd19ba79f9a6d1d3cc6b64e18..bb97a10128f340779bf0228ac70cecb9896efe1e 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -102,6 +102,7 @@ typedef struct st_join_table {
   bool		cached_eq_ref_table,eq_ref_table,not_used_in_distinct;
   TABLE_REF	ref;
   JOIN_CACHE	cache;
+  JOIN		*join;
 } JOIN_TAB;
 
 
@@ -151,7 +152,7 @@ class JOIN {
   uint	   send_group_parts;
   bool	   sort_and_group,first_record,full_join,group, no_field_update;
   table_map const_table_map,outer_join;
-  ha_rows  send_records,found_records;
+  ha_rows  send_records,found_records,examined_rows,row_limit;
   POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1];
   double   best_read;
   List<Item> *fields;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 38c068d35c3cdc9057459065e1b2dca87bb33885..39ddb79e9dee0b27425b752bff3f4d20c93b7bf2 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -781,7 +781,10 @@ store_create_info(THD *thd, TABLE *table, String *packet)
   List<Item> field_list;
   char tmp[MAX_FIELD_WIDTH];
   String type(tmp, sizeof(tmp));
-  packet->append("CREATE TABLE ", 13);
+  if (table->tmp_table)
+    packet->append("CREATE TEMPORARY TABLE ", 23);
+  else
+    packet->append("CREATE TABLE ", 13);
   append_identifier(thd,packet,table->real_name);
   packet->append(" (\n", 3);
 
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 77aaf1edae4ec3d9c76c52b72dcdaa49c3141af3..78721c3e8f9c83499ef3c5a9b9a74f3a0989b366 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1633,6 +1633,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
   TABLE_LIST   tables;
   List<Item>   fields;
   List<Item>   all_fields;
+  ha_rows examined_rows;
   DBUG_ENTER("copy_data_between_tables");
 
   if (!(copy= new Copy_field[to->fields]))
@@ -1668,7 +1669,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
     if (setup_order(thd, &tables, fields, all_fields, order) ||
         !(sortorder=make_unireg_sortorder(order, &length)) ||
         (from->found_records = filesort(&from, sortorder, length, 
-                                         (SQL_SELECT *) 0, 0L, HA_POS_ERROR))
+                                         (SQL_SELECT *) 0, 0L, HA_POS_ERROR,
+					&examined_rows))
         == HA_POS_ERROR)
       goto err;
   };