List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:October 23 2008 3:13pm
Subject:bzr commit into mysql-6.0-opt-subqueries branch (sergefp:2708)
View as plain text  
#At file:///home/spetrunia/dev/mysql-6.0-subq-r17/

 2708 Sergey Petrunia	2008-10-23 [merge]
      Merge mysql-6.0 -> mysql-6.0-opt-subqueries
modified:
  .bzrignore
  include/errmsg.h
  libmysql/Makefile.am
  libmysql/Makefile.shared
  libmysql/errmsg.c
  libmysql/libmysql.c
  libmysqld/libmysqld.c
  mysql-test/r/binlog_format_basic.result
  mysql-test/r/create.result
  mysql-test/r/log_tables.result
  mysql-test/r/mysql.result
  mysql-test/r/partition.result
  mysql-test/r/partition_innodb.result
  mysql-test/r/plugin.result
  mysql-test/r/sp.result
  mysql-test/r/storage_engine_basic.result
  mysql-test/r/variables.result
  mysql-test/suite/falcon/r/falcon_bugs.result
  mysql-test/suite/falcon/t/falcon_bugs.test
  mysql-test/t/binlog_format_basic.test
  mysql-test/t/sp.test
  mysys/my_largepage.c
  scripts/make_win_bin_dist
  sql-common/client.c
  sql/Makefile.am
  sql/backup/backup_info.cc
  sql/backup/backup_info.h
  sql/backup/backup_kernel.h
  sql/backup/backup_test.cc
  sql/backup/error.h
  sql/backup/kernel.cc
  sql/backup/logger.cc
  sql/backup/logger.h
  sql/filesort.cc
  sql/handler.cc
  sql/log.cc
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/net_serv.cc
  sql/probes.d
  sql/probes.h
  sql/scheduler.cc
  sql/share/errmsg.txt
  sql/si_objects.cc
  sql/si_objects.h
  sql/sp_head.cc
  sql/sql_cache.cc
  sql/sql_class.cc
  sql/sql_connect.cc
  sql/sql_cursor.cc
  sql/sql_delete.cc
  sql/sql_insert.cc
  sql/sql_parse.cc
  sql/sql_prepare.cc
  sql/sql_select.cc
  sql/sql_table.cc
  sql/sql_update.cc
  storage/falcon/NNode.h
  storage/falcon/Types.h
  storage/falcon/ha_falcon.cpp
  storage/falcon/plug.in
  support-files/my-huge.cnf.sh
  support-files/my-large.cnf.sh
  support-files/my-medium.cnf.sh
  support-files/my-small.cnf.sh
  support-files/mysql.spec.sh
  tests/mysql_client_test.c

=== modified file '.bzrignore'
--- a/.bzrignore	2008-10-01 12:02:28 +0000
+++ b/.bzrignore	2008-10-16 12:39:30 +0000
@@ -1898,3 +1898,4 @@ mysql-test/tps.log
 libmysqld/event_parse_data.cc
 client/transaction.h
 libmysqld/transaction.cc
+libmysqld/rpl_handler.cc

=== modified file 'include/errmsg.h'
--- a/include/errmsg.h	2008-05-20 16:36:26 +0000
+++ b/include/errmsg.h	2008-10-17 12:39:34 +0000
@@ -97,6 +97,7 @@ extern const char *client_errors[];	/* E
 #define CR_SERVER_LOST_EXTENDED			2055
 #define CR_STMT_CLOSED				2056
 #define CR_NEW_STMT_METADATA                    2057
-#define CR_ERROR_LAST  /*Copy last error nr:*/  2057
+#define CR_ALREADY_CONNECTED                    2058
+#define CR_ERROR_LAST  /*Copy last error nr:*/  2058
 /* Add error numbers before CR_ERROR_LAST and change it accordingly. */
 

=== modified file 'libmysql/Makefile.am'
--- a/libmysql/Makefile.am	2008-09-29 17:47:27 +0000
+++ b/libmysql/Makefile.am	2008-10-10 16:23:30 +0000
@@ -67,6 +67,8 @@ link_sources:
 	  done; \
 	  rm -f net.c; \
 	  @LN_CP_F@ $(top_srcdir)/sql/net_serv.cc net.c ; \
+	  rm -f probes.h; \
+	  @LN_CP_F@ $(top_srcdir)/sql/probes.h probes.h
 	  rm -f password.c; \
 	  @LN_CP_F@ $(top_srcdir)/sql/password.c password.c
 	  echo timestamp > link_sources

=== modified file 'libmysql/Makefile.shared'
--- a/libmysql/Makefile.shared	2008-05-29 15:44:11 +0000
+++ b/libmysql/Makefile.shared	2008-10-02 12:08:09 +0000
@@ -107,7 +107,7 @@ clean-local:
 	      `echo $(sql_cmn_objects) | sed "s;\.lo;.c;g"` \
 	       $(CHARSET_SRCS) $(CHARSET_OBJS) \
 	       $(mystringsextra) $(mysysheaders) $(vioheaders) \
-               net.c
+               net.c probes.h
 
 conf_to_src_SOURCES = conf_to_src.c
 conf_to_src_LDADD=

=== modified file 'libmysql/errmsg.c'
--- a/libmysql/errmsg.c	2008-05-20 16:36:26 +0000
+++ b/libmysql/errmsg.c	2008-10-17 12:39:34 +0000
@@ -85,6 +85,7 @@ const char *client_errors[]=
   "Lost connection to MySQL server at '%s', system error: %d",
   "Statement closed indirectly because of a preceeding %s() call",
   "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 
@@ -151,6 +152,7 @@ const char *client_errors[]=
   "Lost connection to MySQL server at '%s', system error: %d",
   "Statement closed indirectly because of a preceeding %s() call",
   "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 
@@ -215,6 +217,7 @@ const char *client_errors[]=
   "Lost connection to MySQL server at '%s', system error: %d",
   "Statement closed indirectly because of a preceeding %s() call",
   "The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
+  "This handle is already connected. Use a separate handle for each connection."
   ""
 };
 #endif

=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c	2008-08-07 17:52:43 +0000
+++ b/libmysql/libmysql.c	2008-10-17 11:03:46 +0000
@@ -1748,19 +1748,21 @@ static void alloc_stmt_fields(MYSQL_STMT
 	 field= stmt->fields;
        field && fields < end; fields++, field++)
   {
-    field->catalog  = strdup_root(alloc,fields->catalog);

-    field->db       = strdup_root(alloc,fields->db);
-    field->table    = strdup_root(alloc,fields->table);
-    field->org_table= strdup_root(alloc,fields->org_table);
-    field->name     = strdup_root(alloc,fields->name);
-    field->org_name = strdup_root(alloc,fields->org_name);
-    field->charsetnr= fields->charsetnr;
-    field->length   = fields->length;
-    field->type     = fields->type;
-    field->flags    = fields->flags;
-    field->decimals = fields->decimals;
-    field->def      = fields->def ? strdup_root(alloc,fields->def): 0;
-    field->max_length= 0;
+    *field= *fields; /* To copy all numeric parts. */
+    field->catalog=   strmake_root(alloc, fields->catalog,
+                                   fields->catalog_length);
+    field->db=        strmake_root(alloc, fields->db, fields->db_length);
+    field->table=     strmake_root(alloc, fields->table, fields->table_length);
+    field->org_table= strmake_root(alloc, fields->org_table,
+                                   fields->org_table_length);
+    field->name=      strmake_root(alloc, fields->name, fields->name_length);
+    field->org_name=  strmake_root(alloc, fields->org_name,
+                                   fields->org_name_length);
+    field->def      = fields->def ? strmake_root(alloc, fields->def,
+                                                 fields->def_length) : 0;
+    field->def_length= field->def ? fields->def_length : 0;
+    field->extension= 0; /* Avoid dangling links. */
+    field->max_length= 0; /* max_length is set in mysql_stmt_store_result() */
   }
 }
 

=== modified file 'libmysqld/libmysqld.c'
--- a/libmysqld/libmysqld.c	2008-03-27 18:40:00 +0000
+++ b/libmysqld/libmysqld.c	2008-10-17 15:11:28 +0000
@@ -28,6 +28,7 @@
 #include <sys/stat.h>
 #include <signal.h>
 #include <time.h>
+#include <sql_common.h>
 #include "client_settings.h"
 #ifdef	 HAVE_PWD_H
 #include <pwd.h>
@@ -81,14 +82,6 @@ static my_bool is_NT(void)
 ** Shut down connection
 **************************************************************************/
 
-static void end_server(MYSQL *mysql)
-{
-  DBUG_ENTER("end_server");
-  free_old_query(mysql);
-  DBUG_VOID_RETURN;
-}
-
-
 int mysql_init_character_set(MYSQL *mysql);
 
 MYSQL * STDCALL
@@ -104,6 +97,13 @@ mysql_real_connect(MYSQL *mysql,const ch
 		      db ? db : "(Null)",
 		      user ? user : "(Null)"));
 
+  /* Test whether we're already connected */
+  if (mysql->server_version)
+  {
+    set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+    DBUG_RETURN(0);
+  }
+
   if (!host || !host[0])
     host= mysql->options.host;
 
@@ -215,7 +215,7 @@ error:
   {
     /* Free alloced memory */
     my_bool free_me=mysql->free_me;
-    end_server(mysql);
+    free_old_query(mysql);
     mysql->free_me=0;
     mysql_close(mysql);
     mysql->free_me=free_me;

=== modified file 'mysql-test/r/binlog_format_basic.result'
--- a/mysql-test/r/binlog_format_basic.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/binlog_format_basic.result	2008-10-22 14:08:10 +0000
@@ -1,3 +1,6 @@
+SELECT @@GLOBAL.binlog_format;
+@@GLOBAL.binlog_format
+MIXED
 '#---------------------BS_STVARS_002_01----------------------#'
 SELECT COUNT(@@GLOBAL.binlog_format);
 COUNT(@@GLOBAL.binlog_format)

=== modified file 'mysql-test/r/create.result'
--- a/mysql-test/r/create.result	2008-10-02 14:03:57 +0000
+++ b/mysql-test/r/create.result	2008-10-17 14:13:24 +0000
@@ -228,7 +228,7 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MEMORY DEFAULT CHARSET=latin1
 drop table t1;
 SET SESSION storage_engine="gemini";
-ERROR 42000: Unknown table engine 'gemini'
+ERROR 42000: Unknown storage engine 'gemini'
 SELECT @@storage_engine;
 @@storage_engine
 MEMORY
@@ -389,7 +389,7 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MEMORY DEFAULT CHARSET=latin1
 drop table t1;
 SET SESSION storage_engine="gemini";
-ERROR 42000: Unknown table engine 'gemini'
+ERROR 42000: Unknown storage engine 'gemini'
 SELECT @@storage_engine;
 @@storage_engine
 MEMORY

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2008-09-29 18:20:59 +0000
+++ b/mysql-test/r/log_tables.result	2008-10-17 14:13:24 +0000
@@ -235,7 +235,7 @@ set @save_storage_engine= @@session.stor
 set storage_engine= MEMORY;
 alter table mysql.slow_log engine=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 alter table mysql.slow_log engine=memory;
 ERROR HY000: This storage engine cannot be used for log tables"
 set storage_engine= @save_storage_engine;

=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result	2008-07-23 11:28:20 +0000
+++ b/mysql-test/r/mysql.result	2008-10-17 14:13:24 +0000
@@ -378,9 +378,9 @@ WARNING: --server-arg option not support
 +---+
 | 1 | 
 +---+
-Warning (Code 1286): Unknown table engine 'nonexistent'
+Warning (Code 1286): Unknown storage engine 'nonexistent'
 Warning (Code 1266): Using storage engine MyISAM for table 't2'
-Warning (Code 1286): Unknown table engine 'nonexistent2'
+Warning (Code 1286): Unknown storage engine 'nonexistent2'
 Warning (Code 1266): Using storage engine MyISAM for table 't2'
 Error (Code 1050): Table 't2' already exists
 drop tables t1, t2;

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2008-10-07 15:40:12 +0000
+++ b/mysql-test/r/partition.result	2008-10-17 14:13:24 +0000
@@ -2,30 +2,30 @@ drop table if exists t1, t2;
 CREATE TABLE t1 (a INT)
 ENGINE=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 Warning	1266	Using storage engine MyISAM for table 't1'
 DROP TABLE t1;
 CREATE TABLE t1 (a INT)
 ENGINE=NonExistentEngine
 PARTITION BY HASH (a);
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 Warning	1266	Using storage engine MyISAM for table 't1'
 DROP TABLE t1;
 CREATE TABLE t1 (a INT)
 ENGINE=Memory;
 ALTER TABLE t1 ENGINE=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 ALTER TABLE t1
 PARTITION BY HASH (a)
 (PARTITION p0 ENGINE=Memory,
 PARTITION p1 ENGINE=NonExistentEngine);
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 ALTER TABLE t1 ENGINE=NonExistentEngine;
 Warnings:
-Warning	1286	Unknown table engine 'NonExistentEngine'
+Warning	1286	Unknown storage engine 'NonExistentEngine'
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2008-07-07 17:54:50 +0000
+++ b/mysql-test/r/partition_innodb.result	2008-10-17 14:13:24 +0000
@@ -66,7 +66,7 @@ create table t1 (a int)
 engine = x
 partition by key (a);
 Warnings:
-Warning	1286	Unknown table engine 'x'
+Warning	1286	Unknown storage engine 'x'
 Warning	1266	Using storage engine MyISAM for table 't1'
 show create table t1;
 Table	Create Table
@@ -80,7 +80,7 @@ partition by list (a)
 (partition p0 values in (0));
 alter table t1 engine = x;
 Warnings:
-Warning	1286	Unknown table engine 'x'
+Warning	1286	Unknown storage engine 'x'
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (

=== modified file 'mysql-test/r/plugin.result'
--- a/mysql-test/r/plugin.result	2008-02-24 13:12:17 +0000
+++ b/mysql-test/r/plugin.result	2008-10-17 14:13:24 +0000
@@ -1,6 +1,6 @@
 CREATE TABLE t1(a int) ENGINE=EXAMPLE;
 Warnings:
-Warning	1286	Unknown table engine 'EXAMPLE'
+Warning	1286	Unknown storage engine 'EXAMPLE'
 Warning	1266	Using storage engine MyISAM for table 't1'
 DROP TABLE t1;
 INSTALL PLUGIN example SONAME 'ha_example.so';

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2008-09-25 11:46:17 +0000
+++ b/mysql-test/r/sp.result	2008-10-16 12:39:30 +0000
@@ -6948,3 +6948,21 @@ drop procedure p;
 # ------------------------------------------------------------------
 # -- End of 5.1 tests
 # ------------------------------------------------------------------
+DROP FUNCTION IF EXISTS f1;
+DROP TABLE IF EXISTS t_non_existing;
+DROP TABLE IF EXISTS t1;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+DECLARE v INT;
+SELECT a INTO v FROM t_non_existing;
+RETURN 1;
+END|
+CREATE TABLE t1 (a INT) ENGINE = myisam;
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE a = f1();
+ERROR 42S02: Table 'test.t_non_existing' doesn't exist
+DROP FUNCTION f1;
+DROP TABLE t1;
+# ------------------------------------------------------------------
+# -- End of 6.0 tests
+# ------------------------------------------------------------------

=== modified file 'mysql-test/r/storage_engine_basic.result'
--- a/mysql-test/r/storage_engine_basic.result	2008-04-10 13:14:28 +0000
+++ b/mysql-test/r/storage_engine_basic.result	2008-10-17 14:13:24 +0000
@@ -60,13 +60,13 @@ ERROR 42000: Incorrect argument type to 
 SET @@global.storage_engine = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
 SET @@global.storage_engine = FILE;
-ERROR 42000: Unknown table engine 'FILE'
+ERROR 42000: Unknown storage engine 'FILE'
 SET @@session.storage_engine = 8199;
 ERROR 42000: Incorrect argument type to variable 'storage_engine'
 SET @@session.storage_engine = 65530.34.;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.' at line 1
 SET @@session.storage_engine = RECORD;
-ERROR 42000: Unknown table engine 'RECORD'
+ERROR 42000: Unknown storage engine 'RECORD'
 '#------------------FN_DYNVARS_005_05-----------------------#'
 SELECT @@global.storage_engine =
 VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES

=== modified file 'mysql-test/r/variables.result'
--- a/mysql-test/r/variables.result	2008-05-29 12:56:51 +0000
+++ b/mysql-test/r/variables.result	2008-10-17 14:13:24 +0000
@@ -378,7 +378,7 @@ ERROR HY000: Unknown system variable 'un
 set max_join_size="hello";
 ERROR 42000: Incorrect argument type to variable 'max_join_size'
 set storage_engine=UNKNOWN_TABLE_TYPE;
-ERROR 42000: Unknown table engine 'UNKNOWN_TABLE_TYPE'
+ERROR 42000: Unknown storage engine 'UNKNOWN_TABLE_TYPE'
 set storage_engine=MERGE, big_tables=2;
 ERROR 42000: Variable 'big_tables' can't be set to the value of '2'
 show local variables like 'storage_engine';

=== modified file 'mysql-test/suite/falcon/r/falcon_bugs.result'
--- a/mysql-test/suite/falcon/r/falcon_bugs.result	2007-11-26 15:50:23 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bugs.result	2008-10-02 21:05:39 +0000
@@ -3263,4 +3263,20 @@ count(*)
 select count(*) from t2 where b = 150;
 count(*)
 1
+#
+# Bug #36473 Assertion "! is_set()" fails in
+# Diagnostics_area::set_ok_status with Falcon
+# Ensure that we check the return value of update_auto_increment().
+#
+set @@storage_engine = falcon;
+drop table if exists t1;
+create table t1 (a tinyint(4) NOT NULL auto_increment, primary key (a));
+set @@sql_mode='strict_all_tables';
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values (null);
+ERROR 22003: Out of range value for column 'a' at row 1
+set @@sql_mode=default;
+set auto_increment_offset=default;
+set auto_increment_increment=default;
 DROP TABLE t1, t2;

=== modified file 'mysql-test/suite/falcon/t/falcon_bugs.test'
--- a/mysql-test/suite/falcon/t/falcon_bugs.test	2007-12-19 18:55:35 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bugs.test	2008-10-02 21:05:39 +0000
@@ -1772,5 +1772,26 @@ update t1, t2 set t1.b = 150, t2.b = t1.
 select count(*) from t1 where b = 150;
 select count(*) from t2 where b = 150;
 
+
+--echo #
+--echo # Bug #36473 Assertion "! is_set()" fails in
+--echo # Diagnostics_area::set_ok_status with Falcon
+--echo # Ensure that we check the return value of update_auto_increment().
+--echo #
+set @@storage_engine = falcon;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a tinyint(4) NOT NULL auto_increment, primary key (a));
+set @@sql_mode='strict_all_tables';
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+--error ER_WARN_DATA_OUT_OF_RANGE
+insert into t1 values (null);
+set @@sql_mode=default;
+set auto_increment_offset=default;
+set auto_increment_increment=default;
+
 # Final cleanup.
 DROP TABLE t1, t2;

=== modified file 'mysql-test/t/binlog_format_basic.test'
--- a/mysql-test/t/binlog_format_basic.test	2008-04-10 13:14:28 +0000
+++ b/mysql-test/t/binlog_format_basic.test	2008-10-22 14:00:45 +0000
@@ -22,6 +22,13 @@
 #                                                                             #
 ###############################################################################
 
+###################################################################
+# BUG#39812: Make statement replication default for 5.1 (to match 5.0)
+# We just verify that the default binlog_format is STATEMENT in 5.1.
+# In 6.0, it should be MIXED.
+###################################################################
+SELECT @@GLOBAL.binlog_format;
+
 --echo '#---------------------BS_STVARS_002_01----------------------#'
 ####################################################################
 #   Displaying default value                                       #

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2008-09-25 11:46:17 +0000
+++ b/mysql-test/t/sp.test	2008-10-16 12:39:30 +0000
@@ -8220,3 +8220,35 @@ drop procedure p;
 --echo # ------------------------------------------------------------------
 --echo # -- End of 5.1 tests
 --echo # ------------------------------------------------------------------
+
+#
+# Bug#39255: Stored procedures: crash if function references nonexistent table
+#
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP TABLE IF EXISTS t_non_existing;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+   DECLARE v INT;
+   SELECT a INTO v FROM t_non_existing;
+   RETURN 1;
+END|
+delimiter ;|
+
+CREATE TABLE t1 (a INT) ENGINE = myisam;
+INSERT INTO t1 VALUES (1);
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t1 WHERE a = f1();
+
+DROP FUNCTION f1;
+DROP TABLE t1;
+
+--echo # ------------------------------------------------------------------
+--echo # -- End of 6.0 tests
+--echo # ------------------------------------------------------------------

=== modified file 'mysys/my_largepage.c'
--- a/mysys/my_largepage.c	2007-10-02 07:32:33 +0000
+++ b/mysys/my_largepage.c	2008-10-08 19:44:34 +0000
@@ -128,7 +128,7 @@ uchar* my_large_malloc_int(size_t size, 
   {
     if (my_flags & MY_WME)
       fprintf(stderr,
-              "Warning: Failed to allocate %lu bytesx from HugeTLB memory."
+              "Warning: Failed to allocate %lu bytes from HugeTLB memory."
               " errno %d\n", (ulong) size, errno);
 
     DBUG_RETURN(NULL);

=== modified file 'scripts/make_win_bin_dist'
--- a/scripts/make_win_bin_dist	2008-08-25 17:29:53 +0000
+++ b/scripts/make_win_bin_dist	2008-10-21 15:45:46 +0000
@@ -145,6 +145,7 @@ mkdir $DESTDIR
 mkdir $DESTDIR/bin
 cp client/$TARGET/*.exe                                  $DESTDIR/bin/
 cp extra/$TARGET/*.exe                                   $DESTDIR/bin/
+cp storage/maria/$TARGET/*.exe                           $DESTDIR/bin/ || true
 cp storage/myisam/$TARGET/*.exe                          $DESTDIR/bin/
 # Maria engine is optional, so clients might not exist
 if ls storage/maria/$TARGET/*.exe > /dev/null 2>&1; then

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2008-05-08 16:01:15 +0000
+++ b/sql-common/client.c	2008-10-17 12:39:34 +0000
@@ -1836,6 +1836,13 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
 		      db ? db : "(Null)",
 		      user ? user : "(Null)"));
 
+  /* Test whether we're already connected */
+  if (net->vio)
+  {
+    set_mysql_error(mysql, CR_ALREADY_CONNECTED, unknown_sqlstate);
+    DBUG_RETURN(0);
+  }
+
   /* Don't give sigpipe errors if the client doesn't want them */
   set_sigpipe(mysql);
   mysql->methods= &client_methods;

=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am	2008-10-01 12:09:26 +0000
+++ b/sql/Makefile.am	2008-10-10 16:23:30 +0000
@@ -31,10 +31,19 @@ EXTRA_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
 DTRACE =                @DTRACE@
 DTRACEFLAGS =           @DTRACEFLAGS@
-DTRACEFILES =           handler.o \
-			filesort.o \
-			sql_insert.o \
+DTRACEFILES =           filesort.o \
+			handler.o \
+			mysqld.o \
+			net_serv.o \
+			scheduler.o \
+			sp_head.o \
+			sql_cache.o \
+			sql_connect.o \
+			sql_cursor.o \
 			sql_delete.o \
+			sql_insert.o \
+			sql_parse.o \
+			sql_prepare.o \
 			sql_select.o \
 			sql_update.o
 
@@ -218,8 +227,10 @@ install-exec-hook:
 
 SUFFIXES : .d
 
-.d.o : $(DTRACEFILES)
+.d.o :
 	$(DTRACE) $(DTRACEFLAGS) -G -s $< $(DTRACEFILES)
 
+probes.o : $(DTRACEFILES)
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%

=== modified file 'sql/backup/backup_info.cc'
--- a/sql/backup/backup_info.cc	2008-09-16 16:09:18 +0000
+++ b/sql/backup/backup_info.cc	2008-10-21 15:45:46 +0000
@@ -593,7 +593,7 @@ int Backup_info::add_all_dbs()
   using namespace obs;
 
   int res= 0;
-  ObjIterator *dbit= get_databases(m_ctx.m_thd);
+  Obj_iterator *dbit= get_databases(m_ctx.m_thd);
   
   if (!dbit)
   {
@@ -655,7 +655,7 @@ int Backup_info::add_all_dbs()
 
   @returns 0 on success, error code otherwise.
  */
-int Backup_info::add_objects(Db &db, const obj_type type, obs::ObjIterator &it)
+int Backup_info::add_objects(Db &db, const obj_type type, obs::Obj_iterator &it)
 {
   obs::Obj *obj;
   
@@ -680,7 +680,7 @@ int Backup_info::add_db_items(Db &db)
 
   // Add tables.
 
-  ObjIterator *it= get_db_tables(m_ctx.m_thd, &db.name()); 
+  Obj_iterator *it= get_db_tables(m_ctx.m_thd, &db.name());
 
   if (!it)
   {
@@ -922,7 +922,7 @@ int Backup_info::add_view_deps(obs::Obj 
   
   // Get an iterator to iterate over base views of the given one.
 
-  obs::ObjIterator *it= obs::get_view_base_views(m_ctx.m_thd, db_name, name);
+  obs::Obj_iterator *it= obs::get_view_base_views(m_ctx.m_thd, db_name, name);
 
   if (!it)
     return ERROR;

=== modified file 'sql/backup/backup_info.h'
--- a/sql/backup/backup_info.h	2008-08-20 13:23:10 +0000
+++ b/sql/backup/backup_info.h	2008-10-17 11:28:25 +0000
@@ -64,7 +64,7 @@ class Backup_info: public backup::Image_
   Table* add_table(Db&, obs::Obj*);
 
   int add_db_items(Db&);
-  int add_objects(Db&, const obj_type, obs::ObjIterator&);
+  int add_objects(Db&, const obj_type, obs::Obj_iterator&);
   int add_view_deps(obs::Obj&);
 
   struct Dep_node;

=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h	2008-09-02 09:04:39 +0000
+++ b/sql/backup/backup_kernel.h	2008-10-08 10:54:19 +0000
@@ -87,6 +87,11 @@ class Backup_restore_ctx: public backup:
       ongoing backup/restore operation.  If pointer is null, no
       operation is currently running. */
   static Backup_restore_ctx *current_op;
+  /**
+     Indicates if @c run_lock mutex was initialized and thus it should
+     be properly destroyed during shutdown. @sa backup_shutdown().
+   */
+  static bool run_lock_initialized;
   static pthread_mutex_t  run_lock; ///< To guard @c current_op.
 
   /** 

=== modified file 'sql/backup/backup_test.cc'
--- a/sql/backup/backup_test.cc	2008-09-05 14:16:07 +0000
+++ b/sql/backup/backup_test.cc	2008-10-17 11:28:25 +0000
@@ -44,7 +44,7 @@ int execute_backup_test_command(THD *thd
   field_list.push_back(new Item_empty_string("serialization", 13));
   protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
 
-  //obs::ObjIterator *it= obs::get_databases(thd);
+  //obs::Obj_iterator *it= obs::get_databases(thd);
   List_iterator<LEX_STRING> it(*db_list);
   
   //if (it)
@@ -68,7 +68,7 @@ int execute_backup_test_command(THD *thd
       // List tables..
       //
 
-      obs::ObjIterator *tit= obs::get_db_tables(thd, db->get_name());
+      obs::Obj_iterator *tit= obs::get_db_tables(thd, db->get_name());
 
       if (tit)
       {
@@ -250,7 +250,7 @@ int execute_backup_test_command(THD *thd
           String user;
           String host;
           String *user_host= (String *)grant->get_name();
-          user_exists(thd, user_host);
+          check_user_existence(thd, user_host);
           protocol->store(C_STRING_WITH_LEN("GRANT"),
                           system_charset_info);
           grant->serialize(thd, &serial);

=== modified file 'sql/backup/error.h'
--- a/sql/backup/error.h	2008-04-08 15:32:47 +0000
+++ b/sql/backup/error.h	2008-10-03 14:15:40 +0000
@@ -3,6 +3,14 @@
 
 namespace util {
 
+/// Used to save messages pushed into the stack
+struct SAVED_MYSQL_ERROR {
+  uint code;
+  MYSQL_ERROR::enum_warning_level level;
+  char *msg;
+};
+
+
 /**
   Report error stored in MYSQL_ERROR structure to a client.
 
@@ -11,7 +19,7 @@ namespace util {
   @returns 0 if error was reported, non-zero otherwise.
  */
 inline
-int report_mysql_error(THD* thd, MYSQL_ERROR *err, int code= 0)
+int report_mysql_error(THD* thd, SAVED_MYSQL_ERROR *err, int code= 0)
 {
   DBUG_ASSERT(err);
 

=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc	2008-10-09 13:07:54 +0000
+++ b/sql/backup/kernel.cc	2008-10-18 07:57:38 +0000
@@ -95,6 +95,7 @@
 int backup_init()
 {
   pthread_mutex_init(&Backup_restore_ctx::run_lock, MY_MUTEX_INIT_FAST);
+  Backup_restore_ctx::run_lock_initialized= TRUE;
   return 0;
 }
 
@@ -103,10 +104,18 @@ int backup_init()
   
   @note This function is called in the server shut-down sequences, just before
   it shuts-down all its plugins.
+
+  @note Due to way in which server's code is organized this function might be
+  called and should work normally even in situation when backup_init() was not
+  called at all.
  */
 void backup_shutdown()
 {
-  pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+  if (Backup_restore_ctx::run_lock_initialized)
+  {
+    pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+    Backup_restore_ctx::run_lock_initialized= FALSE;
+  }
 }
 
 /*
@@ -258,7 +267,7 @@ execute_backup_command(THD *thd, LEX *le
  */
 int send_error(Backup_restore_ctx &log, int error_code, ...)
 {
-  MYSQL_ERROR *error= log.last_saved_error();
+  util::SAVED_MYSQL_ERROR *error= log.last_saved_error();
 
   if (error && !util::report_mysql_error(log.thd(), error, error_code))
   {
@@ -366,6 +375,7 @@ class Mem_allocator
 // static members
 
 Backup_restore_ctx *Backup_restore_ctx::current_op= NULL;
+bool Backup_restore_ctx::run_lock_initialized= FALSE;
 pthread_mutex_t Backup_restore_ctx::run_lock;
 
 
@@ -1824,8 +1834,8 @@ int bcat_create_item(st_bstream_image_he
     {
       DBUG_PRINT("restore",(" tablespace has changed on the server - aborting"));
       info->m_ctx.fatal_error(ER_BACKUP_TS_CHANGE, desc,
-                              obs::describe_tablespace(sobj)->ptr(),
-                              obs::describe_tablespace(ts)->ptr());
+                              obs::get_tablespace_description(sobj)->ptr(),
+                              obs::get_tablespace_description(ts)->ptr());
       return BSTREAM_ERROR;
     }
   }
@@ -1845,7 +1855,7 @@ int bcat_create_item(st_bstream_image_he
             error handling work in WL#4384 with possible implementation
             via a related bug report.
     */
-    if (!obs::user_exists(thd, sobj->get_name()))
+    if (!obs::check_user_existence(thd, sobj->get_name()))
     {
       info->m_ctx.write_message(log_level::WARNING, 
                                 ER(ER_BACKUP_GRANT_SKIPPED),

=== modified file 'sql/backup/logger.cc'
--- a/sql/backup/logger.cc	2008-09-08 11:05:26 +0000
+++ b/sql/backup/logger.cc	2008-10-08 10:54:19 +0000
@@ -46,8 +46,12 @@ int Logger::write_message(log_level::val
    switch (level) {
    case log_level::ERROR:
      if (m_save_errors)
-       errors.push_front(new MYSQL_ERROR(::current_thd, error_code,
-                                         MYSQL_ERROR::WARN_LEVEL_ERROR, msg));
+     {
+       error.code= error_code;
+       error.level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+       error.msg= sql_strdup(msg);
+     }
+
      sql_print_error(out);
      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                          error_code, msg);

=== modified file 'sql/backup/logger.h'
--- a/sql/backup/logger.h	2008-09-30 07:51:48 +0000
+++ b/sql/backup/logger.h	2008-10-18 07:57:38 +0000
@@ -69,7 +69,7 @@ class Logger
    void save_errors();
    void stop_save_errors();
    void clear_saved_errors();
-   MYSQL_ERROR *last_saved_error();
+   util::SAVED_MYSQL_ERROR *last_saved_error();
 
  protected:
 
@@ -81,8 +81,7 @@ class Logger
   int write_message(log_level::value level , int error_code, const char *msg);
 
  private:
-
-  List<MYSQL_ERROR> errors;  ///< Used to store saved errors.
+  util::SAVED_MYSQL_ERROR error;   ///< Used to store saved errors.
   bool m_save_errors;        ///< Flag telling if errors should be saved.
   Backup_log *backup_log;    ///< Backup log interface class.
 };
@@ -172,15 +171,15 @@ void Logger::stop_save_errors()
 /// Delete all saved errors to free resources.
 inline
 void Logger::clear_saved_errors()
-{ 
-  errors.delete_elements();
+{
+  memset(&error, 0, sizeof(error));
 }
 
 /// Return a pointer to most recent saved error.
 inline
-MYSQL_ERROR *Logger::last_saved_error()
+util::SAVED_MYSQL_ERROR *Logger::last_saved_error()
 { 
-  return errors.is_empty() ? NULL : errors.head();
+  return error.code ? &error : NULL;
 }
 
 /// Report start of an operation.

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2008-07-23 09:43:50 +0000
+++ b/sql/filesort.cc	2008-10-10 16:23:30 +0000
@@ -121,7 +121,7 @@ ha_rows filesort(THD *thd, TABLE *table,
   TABLE_LIST *tab= table->pos_in_table_list;
   Item_subselect *subselect= tab ? tab->containing_subselect() : 0;
 
-  MYSQL_FILESORT_START();
+  MYSQL_FILESORT_START(table->s->db.str, table->s->table_name.str);
 
   /*
    Release InnoDB's adaptive hash index latch (if holding) before
@@ -333,8 +333,10 @@ ha_rows filesort(THD *thd, TABLE *table,
 #endif
   memcpy(&table->sort, &table_sort, sizeof(FILESORT_INFO));
   DBUG_PRINT("exit",("records: %ld", (long) records));
-  MYSQL_FILESORT_END();
-  DBUG_RETURN(error ? HA_POS_ERROR : records);
+  if (error)
+    records= HA_POS_ERROR;
+  MYSQL_FILESORT_DONE(error, records);
+  DBUG_RETURN(records);
 } /* filesort */
 
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2008-10-15 23:14:03 +0000
+++ b/sql/handler.cc	2008-10-23 15:13:34 +0000
@@ -5270,13 +5270,51 @@ int handler::ha_external_lock(THD *thd, 
   */
   DBUG_ASSERT(next_insert_id == 0);
 
+  if (MYSQL_HANDLER_RDLOCK_START_ENABLED() ||
+      MYSQL_HANDLER_WRLOCK_START_ENABLED() ||
+      MYSQL_HANDLER_UNLOCK_START_ENABLED())
+  {
+    if (lock_type == F_RDLCK)
+    {
+      MYSQL_HANDLER_RDLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    }
+    else if (lock_type == F_WRLCK)
+    {
+      MYSQL_HANDLER_WRLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    }
+    else if (lock_type == F_UNLCK)
+    {
+      MYSQL_HANDLER_UNLOCK_START(table_share->db.str,
+                                 table_share->table_name.str);
+    }
+  }
+
   /*
     We cache the table flags if the locking succeeded. Otherwise, we
     keep them as they were when they were fetched in ha_open().
   */
-  MYSQL_EXTERNAL_LOCK(lock_type);
-
   int error= external_lock(thd, lock_type);
+
+  if (MYSQL_HANDLER_RDLOCK_DONE_ENABLED() ||
+      MYSQL_HANDLER_WRLOCK_DONE_ENABLED() ||
+      MYSQL_HANDLER_UNLOCK_DONE_ENABLED())
+  {
+    if (lock_type == F_RDLCK)
+    {
+      MYSQL_HANDLER_RDLOCK_DONE(error);
+    }
+    else if (lock_type == F_WRLCK)
+    {
+      MYSQL_HANDLER_WRLOCK_DONE(error);
+    }
+    else if (lock_type == F_UNLCK)
+    {
+      MYSQL_HANDLER_UNLOCK_DONE(error);
+    }
+  }
+  
   if (error == 0)
     cached_table_flags= table_flags();
   DBUG_RETURN(error);
@@ -5310,15 +5348,16 @@ int handler::ha_write_row(uchar *buf)
   int error;
   Log_func *log_func= Write_rows_log_event::binlog_row_logging_function;
   DBUG_ENTER("handler::ha_write_row");
-  MYSQL_INSERT_ROW_START();
 
+  MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
-
-  if (unlikely(error= write_row(buf)))
+  error= write_row(buf);
+  MYSQL_INSERT_ROW_DONE(error);
+  
+  if (unlikely(error != 0))
     DBUG_RETURN(error);
   if (unlikely(error= binlog_log_row(table, 0, buf, log_func)))
     DBUG_RETURN(error); /* purecov: inspected */
-  MYSQL_INSERT_ROW_END();
   DBUG_RETURN(0);
 }
 
@@ -5334,9 +5373,12 @@ int handler::ha_update_row(const uchar *
    */
   DBUG_ASSERT(new_data == table->record[0]);
 
+  MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
+  error= update_row(old_data, new_data);
+  MYSQL_UPDATE_ROW_DONE(error);
 
-  if (unlikely(error= update_row(old_data, new_data)))
+  if (unlikely(error != 0))
     return error;
   if (unlikely(error= binlog_log_row(table, old_data, new_data, log_func)))
     return error;
@@ -5348,9 +5390,12 @@ int handler::ha_delete_row(const uchar *
   int error;
   Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
 
+  MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
   mark_trx_read_write();
+  error= delete_row(buf);
+  MYSQL_DELETE_ROW_DONE(error);
 
-  if (unlikely(error= delete_row(buf)))
+  if (unlikely(error != 0))
     return error;
   if (unlikely(error= binlog_log_row(table, buf, 0, log_func)))
     return error;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2008-10-16 14:30:35 +0000
+++ b/sql/log.cc	2008-10-21 12:38:13 +0000
@@ -5131,7 +5131,7 @@ THD::binlog_set_pending_rows_event(Rows_
 int
 MYSQL_BIN_LOG::remove_pending_rows_event(THD *thd)
 {
-  DBUG_ENTER(__FUNCTION__);
+  DBUG_ENTER("MYSQL_BIN_LOG::remove_pending_rows_event");
 
   binlog_trx_data *const trx_data=
     (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-10-15 23:14:03 +0000
+++ b/sql/mysql_priv.h	2008-10-23 15:13:34 +0000
@@ -46,6 +46,11 @@
 
 #ifdef HAVE_DTRACE
 #define _DTRACE_VERSION 1
+#else
+#undef _DTRACE_VERSION
+#endif
+#ifdef EMBEDDED_LIBRARY
+#undef _DTRACE_VERSION
 #endif
 #include "probes.h"
 
@@ -521,7 +526,7 @@ enum open_table_mode
   Dont report errors for individual rows,
   But just report error on commit (or read ofcourse)
 */
-#define OPTION_ALLOW_BATCH              (ULL(1) << 33) // THD, intern (slave)
+#define OPTION_ALLOW_BATCH              (ULL(1) << 34) // THD, intern (slave)
 
 /**
   Maximum length of time zone name that we support

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-10-15 23:14:03 +0000
+++ b/sql/mysqld.cc	2008-10-23 15:13:34 +0000
@@ -1915,6 +1915,7 @@ void close_connection(THD *thd, uint err
   }
   if (lock)
     (void) pthread_mutex_unlock(&LOCK_thread_count);
+  MYSQL_CONNECTION_DONE((int) errcode, thd->thread_id);
   DBUG_VOID_RETURN;
 }
 #endif /* EMBEDDED_LIBRARY */
@@ -4020,12 +4021,12 @@ with --log-bin instead.");
     }
     else
     {
-      global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
+      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
     }
   }
   else
     if (opt_binlog_format_id == BINLOG_FORMAT_UNSPEC)
-      global_system_variables.binlog_format= BINLOG_FORMAT_STMT;
+      global_system_variables.binlog_format= BINLOG_FORMAT_MIXED;
     else
     {
       DBUG_ASSERT(global_system_variables.binlog_format != BINLOG_FORMAT_UNSPEC);
@@ -5990,10 +5991,6 @@ struct my_option my_long_options[] =
    "Set the default storage engine (table type) for tables.",
    (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"default-table-type", OPT_STORAGE_ENGINE,
-   "(deprecated) Use --default-storage-engine.",
-   (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str,
-   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.",
    (uchar**) &default_tz_name, (uchar**) &default_tz_name,
    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2008-08-23 23:32:16 +0000
+++ b/sql/net_serv.cc	2008-10-23 15:13:34 +0000
@@ -58,6 +58,13 @@
 #define MYSQL_CLIENT
 #endif /*EMBEDDED_LIBRARY */
 
+#ifdef HAVE_DTRACE
+/* Limit DTrace probes to server code for now */
+#ifndef MYSQL_SERVER
+#undef _DTRACE_VERSION
+#endif
+#endif
+#include "probes.h"
 
 /*
   The following handles the differences when this is linked between the
@@ -363,8 +370,12 @@ my_bool
 my_net_write(NET *net,const uchar *packet,size_t len)
 {
   uchar buff[NET_HEADER_SIZE];
+  my_bool rc;
   if (unlikely(!net->vio)) /* nowhere to write */
     return 0;
+
+  MYSQL_NET_WRITE_START(len);
+
   /*
     Big packets are handled by splitting them in packets of MAX_PACKET_LENGTH
     length. The last packet is always a packet that is < MAX_PACKET_LENGTH.
@@ -377,7 +388,10 @@ my_net_write(NET *net,const uchar *packe
     buff[3]= (uchar) net->pkt_nr++;
     if (net_write_buff(net, buff, NET_HEADER_SIZE) ||
 	net_write_buff(net, packet, z_size))
+    {
+      MYSQL_NET_WRITE_DONE(1);
       return 1;
+    }
     packet += z_size;
     len-=     z_size;
   }
@@ -385,11 +399,16 @@ my_net_write(NET *net,const uchar *packe
   int3store(buff,len);
   buff[3]= (uchar) net->pkt_nr++;
   if (net_write_buff(net, buff, NET_HEADER_SIZE))
+  {
+    MYSQL_NET_WRITE_DONE(1);
     return 1;
+  }
 #ifndef DEBUG_DATA_PACKETS
   DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE);
 #endif
-  return test(net_write_buff(net,packet,len));
+  rc= test(net_write_buff(net,packet,len));
+  MYSQL_NET_WRITE_DONE(rc);
+  return rc;
 }
 
 /**
@@ -427,9 +446,12 @@ net_write_command(NET *net,uchar command
   ulong length=len+1+head_len;			/* 1 extra byte for command */
   uchar buff[NET_HEADER_SIZE+1];
   uint header_size=NET_HEADER_SIZE+1;
+  my_bool rc;
   DBUG_ENTER("net_write_command");
   DBUG_PRINT("enter",("length: %lu", (ulong) len));
 
+  MYSQL_NET_WRITE_START(length);
+  
   buff[4]=command;				/* For first packet */
 
   if (length >= MAX_PACKET_LENGTH)
@@ -443,7 +465,10 @@ net_write_command(NET *net,uchar command
       if (net_write_buff(net, buff, header_size) ||
 	  net_write_buff(net, header, head_len) ||
 	  net_write_buff(net, packet, len))
-	DBUG_RETURN(1);
+      {
+        MYSQL_NET_WRITE_DONE(1);
+        DBUG_RETURN(1);
+      }
       packet+= len;
       length-= MAX_PACKET_LENGTH;
       len= MAX_PACKET_LENGTH;
@@ -454,9 +479,11 @@ net_write_command(NET *net,uchar command
   }
   int3store(buff,length);
   buff[3]= (uchar) net->pkt_nr++;
-  DBUG_RETURN(test(net_write_buff(net, buff, header_size) ||
-                   (head_len && net_write_buff(net, header, head_len)) ||
-                   net_write_buff(net, packet, len) || net_flush(net)));
+  rc= test(net_write_buff(net, buff, header_size) ||
+           (head_len && net_write_buff(net, header, head_len)) ||
+           net_write_buff(net, packet, len) || net_flush(net));
+  MYSQL_NET_WRITE_DONE(rc);
+  DBUG_RETURN(rc);
 }
 
 /**
@@ -984,6 +1011,8 @@ my_net_read(NET *net)
 {
   size_t len, complen;
 
+  MYSQL_NET_READ_START();
+  
 #ifdef HAVE_COMPRESS
   if (!net->compress)
   {
@@ -1007,6 +1036,7 @@ my_net_read(NET *net)
     net->read_pos = net->buff + net->where_b;
     if (len != packet_error)
       net->read_pos[len]=0;		/* Safeguard for mysql_use_result */
+    MYSQL_NET_READ_DONE(0, len);
     return len;
 #ifdef HAVE_COMPRESS
   }
@@ -1090,7 +1120,10 @@ my_net_read(NET *net)
 
       net->where_b=buf_length;
       if ((packet_len = my_real_read(net,&complen)) == packet_error)
+      {
+        MYSQL_NET_READ_DONE(1, 0);
 	return packet_error;
+      }
       if (my_uncompress(net->buff + net->where_b, packet_len,
 			&complen))
       {
@@ -1099,6 +1132,7 @@ my_net_read(NET *net)
 #ifdef MYSQL_SERVER
 	my_error(ER_NET_UNCOMPRESS_ERROR, MYF(0));
 #endif
+        MYSQL_NET_READ_DONE(1, 0);
 	return packet_error;
       }
       buf_length+= complen;
@@ -1113,6 +1147,7 @@ my_net_read(NET *net)
     net->read_pos[len]=0;		/* Safeguard for mysql_use_result */
   }
 #endif /* HAVE_COMPRESS */
+  MYSQL_NET_READ_DONE(0, len);
   return len;
 }
 

=== modified file 'sql/probes.d'
--- a/sql/probes.d	2007-09-21 07:09:31 +0000
+++ b/sql/probes.d	2008-10-02 12:08:09 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2005 MySQL AB
+/* Copyright (C) 2008 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -13,18 +13,142 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
 
+/*
+  The actual probe names in DTrace scripts will replace '__' by '-'. Thus
+  insert__row__start will be insert-row-start.
+
+  Recommendations for adding new probes:
+
+  - each probe should have the minimal set of arguments required to
+  unambiguously identify the context in which the probe fires. Redundant
+  probes (i.e. the ones that can be obtained in user scripts from previous
+  probes' arguments or otherwise) may be added for convenience.
+
+  - try to avoid computationally expensive probe arguments. If impossible,
+  use *_ENABLED() macros to check if the probe is activated before
+  performing expensive calculations for a probe argument.
+
+  - all *-done probes should have a status argument wherever applicable to make
+  it possible for user scripts to figure out whether the completed operation
+  was successful or not.
+  
+  - for all status arguments, a non-zero value should be returned on error or
+  failure, 0 should be returned on success.
+*/
+
 provider mysql {
-probe external_lock(int);
-probe insert_row_start();
-probe insert_row_end();
-probe filesort_start();
-probe filesort_end();
-probe delete_start();
-probe delete_end();
-probe insert_start();
-probe insert_end();
-probe select_start();
-probe select_end();
-probe update_start();
-probe update_end();
+  
+  /* The following ones fire when creating or closing a client connection */
+  probe connection__start(unsigned long conn_id, char *user, char *host);
+  probe connection__done(int status, unsigned long conn_id);
+
+  /*
+    Fire at the start/end of any client command processing (including SQL
+    queries).
+  */
+  probe command__start(unsigned long conn_id, int command,
+                       char *user, char *host);
+  probe command__done(int status);
+  
+  /*
+    The following probes fire at the start/end of any SQL query processing,
+    respectively.
+
+    query_start() has a lot of parameters that can be used to pick up
+    parameters for a lot of other probes here.  For simplicity reasons we also
+    add the query string to most other DTrace probes as well. Hostname is
+    either the hostname or the IP address of the MySQL Client.
+  */
+  probe query__start(char *query,
+                     unsigned long conn_id,
+                     char *db_name,
+                     char *user,
+                     char *host);
+  probe query__done(int status); 
+
+  /* Fire at the start/end of SQL query parsing */
+  probe query__parse__start(char *query);
+  probe query__parse__done(int status);
+
+  /* Track whether the query hits the query cache or not */
+  probe query__cache__hit(char *query, unsigned long rows);
+  probe query__cache__miss(char *query);
+
+  /*
+    This probe fires when the actual query execution starts, i.e. after
+    parsing and checking the query cache, but before privilege checks,
+    optimizing, etc.
+
+    Query means also all independent queries of a stored procedure and prepared
+    statements. Also the stored procedure itself is a query.
+
+    exec_type is:
+    0:           Executed query from sql_parse, top-level query (sql_parse.cc)
+    1:           Executed prepared statement (sql_prepare.cc)
+    2:           Executed cursor statement (sql_cursor.cc)
+    3:           Executed query in stored procedure (sp_head.cc)
+  */
+  probe query__exec__start(char *query,
+                           unsigned long connid,
+                           char *db_name,
+                           char *user,
+                           char *host,
+                           int exec_type);
+  probe query__exec__done(int status);
+
+  /* These probes fire when performing write operations towards any handler */
+  probe insert__row__start(char *db, char *table);
+  probe insert__row__done(int status);
+  probe update__row__start(char *db, char *table);
+  probe update__row__done(int status);
+  probe delete__row__start(char *db, char *table);
+  probe delete__row__done(int status);
+
+  /*
+    These probes fire when calling external_lock for any handler
+    depending on the lock type being acquired or released.
+  */
+  probe handler__rdlock__start(char *db, char *table);
+  probe handler__wrlock__start(char *db, char *table);
+  probe handler__unlock__start(char *db, char *table);
+  probe handler__rdlock__done(int status);
+  probe handler__wrlock__done(int status);
+  probe handler__unlock__done(int status);
+  
+  /*
+    These probes fire when a filesort activity happens in a query.
+  */
+  probe filesort__start(char *db, char *table);
+  probe filesort__done(int status, unsigned long rows);
+  /*
+    The query types SELECT, INSERT, INSERT AS SELECT, UPDATE, UPDATE with
+    multiple tables, DELETE, DELETE with multiple tables are all probed.
+    The start probe always contains the query text.
+  */
+  probe select__start(char *query);
+  probe select__done(int status, unsigned long rows);
+  probe insert__start(char *query);
+  probe insert__done(int status, unsigned long rows);
+  probe insert__select__start(char *query);
+  probe insert__select__done(int status, unsigned long rows);
+  probe update__start(char *query);
+  probe update__done(int status,
+                     unsigned long rowsmatches, unsigned long rowschanged);
+  probe multi__update__start(char *query);
+  probe multi__update__done(int status,
+                            unsigned long rowsmatches, unsigned long rowschanged);
+  probe delete__start(char *query);
+  probe delete__done(int status, unsigned long rows);
+  probe multi__delete__start(char *query);
+  probe multi__delete__done(int status, unsigned long rows);
+
+  /*
+    These probes can be used to measure the time waiting for network traffic
+    or identify network-related problems.
+  */
+  probe net__read__start();
+  probe net__read__done(int status, unsigned long bytes);
+  probe net__write__start(unsigned long bytes);
+  probe net__write__done(int status);
+
 };

=== modified file 'sql/probes.h'
--- a/sql/probes.h	2008-07-08 13:49:57 +0000
+++ b/sql/probes.h	2008-10-10 16:23:30 +0000
@@ -13,114 +13,362 @@ extern "C" {
 
 #if _DTRACE_VERSION && defined(HAVE_DTRACE)
 
-#define	MYSQL_DELETE_END() \
-	__dtrace_mysql___delete_end()
-#define	MYSQL_DELETE_END_ENABLED() \
-	__dtraceenabled_mysql___delete_end()
-#define	MYSQL_DELETE_START() \
-	__dtrace_mysql___delete_start()
+#define	MYSQL_COMMAND_DONE(arg0) \
+	__dtrace_mysql___command__done(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() \
+	__dtraceenabled_mysql___command__done()
+#define	MYSQL_COMMAND_START(arg0, arg1, arg2, arg3) \
+	__dtrace_mysql___command__start(arg0, arg1, arg2, arg3)
+#define	MYSQL_COMMAND_START_ENABLED() \
+	__dtraceenabled_mysql___command__start()
+#define	MYSQL_CONNECTION_DONE(arg0, arg1) \
+	__dtrace_mysql___connection__done(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() \
+	__dtraceenabled_mysql___connection__done()
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2) \
+	__dtrace_mysql___connection__start(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() \
+	__dtraceenabled_mysql___connection__start()
+#define	MYSQL_DELETE_DONE(arg0, arg1) \
+	__dtrace_mysql___delete__done(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() \
+	__dtraceenabled_mysql___delete__done()
+#define	MYSQL_DELETE_ROW_DONE(arg0) \
+	__dtrace_mysql___delete__row__done(arg0)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___delete__row__done()
+#define	MYSQL_DELETE_ROW_START(arg0, arg1) \
+	__dtrace_mysql___delete__row__start(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() \
+	__dtraceenabled_mysql___delete__row__start()
+#define	MYSQL_DELETE_START(arg0) \
+	__dtrace_mysql___delete__start(arg0)
 #define	MYSQL_DELETE_START_ENABLED() \
-	__dtraceenabled_mysql___delete_start()
-#define	MYSQL_EXTERNAL_LOCK(arg0) \
-	__dtrace_mysql___external_lock(arg0)
-#define	MYSQL_EXTERNAL_LOCK_ENABLED() \
-	__dtraceenabled_mysql___external_lock()
-#define	MYSQL_FILESORT_END() \
-	__dtrace_mysql___filesort_end()
-#define	MYSQL_FILESORT_END_ENABLED() \
-	__dtraceenabled_mysql___filesort_end()
-#define	MYSQL_FILESORT_START() \
-	__dtrace_mysql___filesort_start()
+	__dtraceenabled_mysql___delete__start()
+#define	MYSQL_FILESORT_DONE(arg0, arg1) \
+	__dtrace_mysql___filesort__done(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() \
+	__dtraceenabled_mysql___filesort__done()
+#define	MYSQL_FILESORT_START(arg0, arg1) \
+	__dtrace_mysql___filesort__start(arg0, arg1)
 #define	MYSQL_FILESORT_START_ENABLED() \
-	__dtraceenabled_mysql___filesort_start()
-#define	MYSQL_INSERT_END() \
-	__dtrace_mysql___insert_end()
-#define	MYSQL_INSERT_END_ENABLED() \
-	__dtraceenabled_mysql___insert_end()
-#define	MYSQL_INSERT_ROW_END() \
-	__dtrace_mysql___insert_row_end()
-#define	MYSQL_INSERT_ROW_END_ENABLED() \
-	__dtraceenabled_mysql___insert_row_end()
-#define	MYSQL_INSERT_ROW_START() \
-	__dtrace_mysql___insert_row_start()
+	__dtraceenabled_mysql___filesort__start()
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0) \
+	__dtrace_mysql___handler__rdlock__done(arg0)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__rdlock__done()
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__rdlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__rdlock__start()
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0) \
+	__dtrace_mysql___handler__unlock__done(arg0)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__unlock__done()
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__unlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__unlock__start()
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0) \
+	__dtrace_mysql___handler__wrlock__done(arg0)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() \
+	__dtraceenabled_mysql___handler__wrlock__done()
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1) \
+	__dtrace_mysql___handler__wrlock__start(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() \
+	__dtraceenabled_mysql___handler__wrlock__start()
+#define	MYSQL_INSERT_DONE(arg0, arg1) \
+	__dtrace_mysql___insert__done(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__done()
+#define	MYSQL_INSERT_ROW_DONE(arg0) \
+	__dtrace_mysql___insert__row__done(arg0)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__row__done()
+#define	MYSQL_INSERT_ROW_START(arg0, arg1) \
+	__dtrace_mysql___insert__row__start(arg0, arg1)
 #define	MYSQL_INSERT_ROW_START_ENABLED() \
-	__dtraceenabled_mysql___insert_row_start()
-#define	MYSQL_INSERT_START() \
-	__dtrace_mysql___insert_start()
+	__dtraceenabled_mysql___insert__row__start()
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1) \
+	__dtrace_mysql___insert__select__done(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() \
+	__dtraceenabled_mysql___insert__select__done()
+#define	MYSQL_INSERT_SELECT_START(arg0) \
+	__dtrace_mysql___insert__select__start(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() \
+	__dtraceenabled_mysql___insert__select__start()
+#define	MYSQL_INSERT_START(arg0) \
+	__dtrace_mysql___insert__start(arg0)
 #define	MYSQL_INSERT_START_ENABLED() \
-	__dtraceenabled_mysql___insert_start()
-#define	MYSQL_SELECT_END() \
-	__dtrace_mysql___select_end()
-#define	MYSQL_SELECT_END_ENABLED() \
-	__dtraceenabled_mysql___select_end()
-#define	MYSQL_SELECT_START() \
-	__dtrace_mysql___select_start()
+	__dtraceenabled_mysql___insert__start()
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1) \
+	__dtrace_mysql___multi__delete__done(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() \
+	__dtraceenabled_mysql___multi__delete__done()
+#define	MYSQL_MULTI_DELETE_START(arg0) \
+	__dtrace_mysql___multi__delete__start(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() \
+	__dtraceenabled_mysql___multi__delete__start()
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___multi__update__done(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() \
+	__dtraceenabled_mysql___multi__update__done()
+#define	MYSQL_MULTI_UPDATE_START(arg0) \
+	__dtrace_mysql___multi__update__start(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() \
+	__dtraceenabled_mysql___multi__update__start()
+#define	MYSQL_NET_READ_DONE(arg0, arg1) \
+	__dtrace_mysql___net__read__done(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() \
+	__dtraceenabled_mysql___net__read__done()
+#define	MYSQL_NET_READ_START() \
+	__dtrace_mysql___net__read__start()
+#define	MYSQL_NET_READ_START_ENABLED() \
+	__dtraceenabled_mysql___net__read__start()
+#define	MYSQL_NET_WRITE_DONE(arg0) \
+	__dtrace_mysql___net__write__done(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() \
+	__dtraceenabled_mysql___net__write__done()
+#define	MYSQL_NET_WRITE_START(arg0) \
+	__dtrace_mysql___net__write__start(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() \
+	__dtraceenabled_mysql___net__write__start()
+#define	MYSQL_QUERY_CACHE_HIT(arg0, arg1) \
+	__dtrace_mysql___query__cache__hit(arg0, arg1)
+#define	MYSQL_QUERY_CACHE_HIT_ENABLED() \
+	__dtraceenabled_mysql___query__cache__hit()
+#define	MYSQL_QUERY_CACHE_MISS(arg0) \
+	__dtrace_mysql___query__cache__miss(arg0)
+#define	MYSQL_QUERY_CACHE_MISS_ENABLED() \
+	__dtraceenabled_mysql___query__cache__miss()
+#define	MYSQL_QUERY_DONE(arg0) \
+	__dtrace_mysql___query__done(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__done()
+#define	MYSQL_QUERY_EXEC_DONE(arg0) \
+	__dtrace_mysql___query__exec__done(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__exec__done()
+#define	MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5) \
+	__dtrace_mysql___query__exec__start(arg0, arg1, arg2, arg3, arg4, arg5)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() \
+	__dtraceenabled_mysql___query__exec__start()
+#define	MYSQL_QUERY_PARSE_DONE(arg0) \
+	__dtrace_mysql___query__parse__done(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_ENABLED() \
+	__dtraceenabled_mysql___query__parse__done()
+#define	MYSQL_QUERY_PARSE_START(arg0) \
+	__dtrace_mysql___query__parse__start(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() \
+	__dtraceenabled_mysql___query__parse__start()
+#define	MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4) \
+	__dtrace_mysql___query__start(arg0, arg1, arg2, arg3, arg4)
+#define	MYSQL_QUERY_START_ENABLED() \
+	__dtraceenabled_mysql___query__start()
+#define	MYSQL_SELECT_DONE(arg0, arg1) \
+	__dtrace_mysql___select__done(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() \
+	__dtraceenabled_mysql___select__done()
+#define	MYSQL_SELECT_START(arg0) \
+	__dtrace_mysql___select__start(arg0)
 #define	MYSQL_SELECT_START_ENABLED() \
-	__dtraceenabled_mysql___select_start()
-#define	MYSQL_UPDATE_END() \
-	__dtrace_mysql___update_end()
-#define	MYSQL_UPDATE_END_ENABLED() \
-	__dtraceenabled_mysql___update_end()
-#define	MYSQL_UPDATE_START() \
-	__dtrace_mysql___update_start()
+	__dtraceenabled_mysql___select__start()
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2) \
+	__dtrace_mysql___update__done(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() \
+	__dtraceenabled_mysql___update__done()
+#define	MYSQL_UPDATE_ROW_DONE(arg0) \
+	__dtrace_mysql___update__row__done(arg0)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() \
+	__dtraceenabled_mysql___update__row__done()
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1) \
+	__dtrace_mysql___update__row__start(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() \
+	__dtraceenabled_mysql___update__row__start()
+#define	MYSQL_UPDATE_START(arg0) \
+	__dtrace_mysql___update__start(arg0)
 #define	MYSQL_UPDATE_START_ENABLED() \
-	__dtraceenabled_mysql___update_start()
+	__dtraceenabled_mysql___update__start()
 
 
-extern void __dtrace_mysql___delete_end(void);
-extern int __dtraceenabled_mysql___delete_end(void);
-extern void __dtrace_mysql___delete_start(void);
-extern int __dtraceenabled_mysql___delete_start(void);
-extern void __dtrace_mysql___external_lock(int);
-extern int __dtraceenabled_mysql___external_lock(void);
-extern void __dtrace_mysql___filesort_end(void);
-extern int __dtraceenabled_mysql___filesort_end(void);
-extern void __dtrace_mysql___filesort_start(void);
-extern int __dtraceenabled_mysql___filesort_start(void);
-extern void __dtrace_mysql___insert_end(void);
-extern int __dtraceenabled_mysql___insert_end(void);
-extern void __dtrace_mysql___insert_row_end(void);
-extern int __dtraceenabled_mysql___insert_row_end(void);
-extern void __dtrace_mysql___insert_row_start(void);
-extern int __dtraceenabled_mysql___insert_row_start(void);
-extern void __dtrace_mysql___insert_start(void);
-extern int __dtraceenabled_mysql___insert_start(void);
-extern void __dtrace_mysql___select_end(void);
-extern int __dtraceenabled_mysql___select_end(void);
-extern void __dtrace_mysql___select_start(void);
-extern int __dtraceenabled_mysql___select_start(void);
-extern void __dtrace_mysql___update_end(void);
-extern int __dtraceenabled_mysql___update_end(void);
-extern void __dtrace_mysql___update_start(void);
-extern int __dtraceenabled_mysql___update_start(void);
+extern void __dtrace_mysql___command__done(int);
+extern int __dtraceenabled_mysql___command__done(void);
+extern void __dtrace_mysql___command__start(unsigned long, int, char *, char *);
+extern int __dtraceenabled_mysql___command__start(void);
+extern void __dtrace_mysql___connection__done(int, unsigned long);
+extern int __dtraceenabled_mysql___connection__done(void);
+extern void __dtrace_mysql___connection__start(unsigned long, char *, char *);
+extern int __dtraceenabled_mysql___connection__start(void);
+extern void __dtrace_mysql___delete__done(int, unsigned long);
+extern int __dtraceenabled_mysql___delete__done(void);
+extern void __dtrace_mysql___delete__row__done(int);
+extern int __dtraceenabled_mysql___delete__row__done(void);
+extern void __dtrace_mysql___delete__row__start(char *, char *);
+extern int __dtraceenabled_mysql___delete__row__start(void);
+extern void __dtrace_mysql___delete__start(char *);
+extern int __dtraceenabled_mysql___delete__start(void);
+extern void __dtrace_mysql___filesort__done(int, unsigned long);
+extern int __dtraceenabled_mysql___filesort__done(void);
+extern void __dtrace_mysql___filesort__start(char *, char *);
+extern int __dtraceenabled_mysql___filesort__start(void);
+extern void __dtrace_mysql___handler__rdlock__done(int);
+extern int __dtraceenabled_mysql___handler__rdlock__done(void);
+extern void __dtrace_mysql___handler__rdlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__rdlock__start(void);
+extern void __dtrace_mysql___handler__unlock__done(int);
+extern int __dtraceenabled_mysql___handler__unlock__done(void);
+extern void __dtrace_mysql___handler__unlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__unlock__start(void);
+extern void __dtrace_mysql___handler__wrlock__done(int);
+extern int __dtraceenabled_mysql___handler__wrlock__done(void);
+extern void __dtrace_mysql___handler__wrlock__start(char *, char *);
+extern int __dtraceenabled_mysql___handler__wrlock__start(void);
+extern void __dtrace_mysql___insert__done(int, unsigned long);
+extern int __dtraceenabled_mysql___insert__done(void);
+extern void __dtrace_mysql___insert__row__done(int);
+extern int __dtraceenabled_mysql___insert__row__done(void);
+extern void __dtrace_mysql___insert__row__start(char *, char *);
+extern int __dtraceenabled_mysql___insert__row__start(void);
+extern void __dtrace_mysql___insert__select__done(int, unsigned long);
+extern int __dtraceenabled_mysql___insert__select__done(void);
+extern void __dtrace_mysql___insert__select__start(char *);
+extern int __dtraceenabled_mysql___insert__select__start(void);
+extern void __dtrace_mysql___insert__start(char *);
+extern int __dtraceenabled_mysql___insert__start(void);
+extern void __dtrace_mysql___multi__delete__done(int, unsigned long);
+extern int __dtraceenabled_mysql___multi__delete__done(void);
+extern void __dtrace_mysql___multi__delete__start(char *);
+extern int __dtraceenabled_mysql___multi__delete__start(void);
+extern void __dtrace_mysql___multi__update__done(int, unsigned long, unsigned long);
+extern int __dtraceenabled_mysql___multi__update__done(void);
+extern void __dtrace_mysql___multi__update__start(char *);
+extern int __dtraceenabled_mysql___multi__update__start(void);
+extern void __dtrace_mysql___net__read__done(int, unsigned long);
+extern int __dtraceenabled_mysql___net__read__done(void);
+extern void __dtrace_mysql___net__read__start(void);
+extern int __dtraceenabled_mysql___net__read__start(void);
+extern void __dtrace_mysql___net__write__done(int);
+extern int __dtraceenabled_mysql___net__write__done(void);
+extern void __dtrace_mysql___net__write__start(unsigned long);
+extern int __dtraceenabled_mysql___net__write__start(void);
+extern void __dtrace_mysql___query__cache__hit(char *, unsigned long);
+extern int __dtraceenabled_mysql___query__cache__hit(void);
+extern void __dtrace_mysql___query__cache__miss(char *);
+extern int __dtraceenabled_mysql___query__cache__miss(void);
+extern void __dtrace_mysql___query__done(int);
+extern int __dtraceenabled_mysql___query__done(void);
+extern void __dtrace_mysql___query__exec__done(int);
+extern int __dtraceenabled_mysql___query__exec__done(void);
+extern void __dtrace_mysql___query__exec__start(char *, unsigned long, char *, char *, char *, int);
+extern int __dtraceenabled_mysql___query__exec__start(void);
+extern void __dtrace_mysql___query__parse__done(int);
+extern int __dtraceenabled_mysql___query__parse__done(void);
+extern void __dtrace_mysql___query__parse__start(char *);
+extern int __dtraceenabled_mysql___query__parse__start(void);
+extern void __dtrace_mysql___query__start(char *, unsigned long, char *, char *, char *);
+extern int __dtraceenabled_mysql___query__start(void);
+extern void __dtrace_mysql___select__done(int, unsigned long);
+extern int __dtraceenabled_mysql___select__done(void);
+extern void __dtrace_mysql___select__start(char *);
+extern int __dtraceenabled_mysql___select__start(void);
+extern void __dtrace_mysql___update__done(int, unsigned long, unsigned long);
+extern int __dtraceenabled_mysql___update__done(void);
+extern void __dtrace_mysql___update__row__done(int);
+extern int __dtraceenabled_mysql___update__row__done(void);
+extern void __dtrace_mysql___update__row__start(char *, char *);
+extern int __dtraceenabled_mysql___update__row__start(void);
+extern void __dtrace_mysql___update__start(char *);
+extern int __dtraceenabled_mysql___update__start(void);
 
 #else
 
-#define	MYSQL_DELETE_END()
-#define	MYSQL_DELETE_END_ENABLED() (0)
-#define	MYSQL_DELETE_START()
+#define	MYSQL_COMMAND_DONE(arg0)
+#define	MYSQL_COMMAND_DONE_ENABLED() (0)
+#define	MYSQL_COMMAND_START(arg0, arg1, arg2, arg3)
+#define	MYSQL_COMMAND_START_ENABLED() (0)
+#define	MYSQL_CONNECTION_DONE(arg0, arg1)
+#define	MYSQL_CONNECTION_DONE_ENABLED() (0)
+#define	MYSQL_CONNECTION_START(arg0, arg1, arg2)
+#define	MYSQL_CONNECTION_START_ENABLED() (0)
+#define	MYSQL_DELETE_DONE(arg0, arg1)
+#define	MYSQL_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_DONE(arg0)
+#define	MYSQL_DELETE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_DELETE_ROW_START(arg0, arg1)
+#define	MYSQL_DELETE_ROW_START_ENABLED() (0)
+#define	MYSQL_DELETE_START(arg0)
 #define	MYSQL_DELETE_START_ENABLED() (0)
-#define	MYSQL_EXTERNAL_LOCK(arg0)
-#define	MYSQL_EXTERNAL_LOCK_ENABLED() (0)
-#define	MYSQL_FILESORT_END()
-#define	MYSQL_FILESORT_END_ENABLED() (0)
-#define	MYSQL_FILESORT_START()
+#define	MYSQL_FILESORT_DONE(arg0, arg1)
+#define	MYSQL_FILESORT_DONE_ENABLED() (0)
+#define	MYSQL_FILESORT_START(arg0, arg1)
 #define	MYSQL_FILESORT_START_ENABLED() (0)
-#define	MYSQL_INSERT_END()
-#define	MYSQL_INSERT_END_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_END()
-#define	MYSQL_INSERT_ROW_END_ENABLED() (0)
-#define	MYSQL_INSERT_ROW_START()
+#define	MYSQL_HANDLER_RDLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_RDLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_RDLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_RDLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_UNLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_UNLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_UNLOCK_START_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_DONE(arg0)
+#define	MYSQL_HANDLER_WRLOCK_DONE_ENABLED() (0)
+#define	MYSQL_HANDLER_WRLOCK_START(arg0, arg1)
+#define	MYSQL_HANDLER_WRLOCK_START_ENABLED() (0)
+#define	MYSQL_INSERT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_DONE(arg0)
+#define	MYSQL_INSERT_ROW_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_ROW_START(arg0, arg1)
 #define	MYSQL_INSERT_ROW_START_ENABLED() (0)
-#define	MYSQL_INSERT_START()
+#define	MYSQL_INSERT_SELECT_DONE(arg0, arg1)
+#define	MYSQL_INSERT_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_INSERT_SELECT_START(arg0)
+#define	MYSQL_INSERT_SELECT_START_ENABLED() (0)
+#define	MYSQL_INSERT_START(arg0)
 #define	MYSQL_INSERT_START_ENABLED() (0)
-#define	MYSQL_SELECT_END()
-#define	MYSQL_SELECT_END_ENABLED() (0)
-#define	MYSQL_SELECT_START()
+#define	MYSQL_MULTI_DELETE_DONE(arg0, arg1)
+#define	MYSQL_MULTI_DELETE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_DELETE_START(arg0)
+#define	MYSQL_MULTI_DELETE_START_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_MULTI_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_MULTI_UPDATE_START(arg0)
+#define	MYSQL_MULTI_UPDATE_START_ENABLED() (0)
+#define	MYSQL_NET_READ_DONE(arg0, arg1)
+#define	MYSQL_NET_READ_DONE_ENABLED() (0)
+#define	MYSQL_NET_READ_START()
+#define	MYSQL_NET_READ_START_ENABLED() (0)
+#define	MYSQL_NET_WRITE_DONE(arg0)
+#define	MYSQL_NET_WRITE_DONE_ENABLED() (0)
+#define	MYSQL_NET_WRITE_START(arg0)
+#define	MYSQL_NET_WRITE_START_ENABLED() (0)
+#define	MYSQL_QUERY_CACHE_HIT(arg0, arg1)
+#define	MYSQL_QUERY_CACHE_HIT_ENABLED() (0)
+#define	MYSQL_QUERY_CACHE_MISS(arg0)
+#define	MYSQL_QUERY_CACHE_MISS_ENABLED() (0)
+#define	MYSQL_QUERY_DONE(arg0)
+#define	MYSQL_QUERY_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_DONE(arg0)
+#define	MYSQL_QUERY_EXEC_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_EXEC_START(arg0, arg1, arg2, arg3, arg4, arg5)
+#define	MYSQL_QUERY_EXEC_START_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_DONE(arg0)
+#define	MYSQL_QUERY_PARSE_DONE_ENABLED() (0)
+#define	MYSQL_QUERY_PARSE_START(arg0)
+#define	MYSQL_QUERY_PARSE_START_ENABLED() (0)
+#define	MYSQL_QUERY_START(arg0, arg1, arg2, arg3, arg4)
+#define	MYSQL_QUERY_START_ENABLED() (0)
+#define	MYSQL_SELECT_DONE(arg0, arg1)
+#define	MYSQL_SELECT_DONE_ENABLED() (0)
+#define	MYSQL_SELECT_START(arg0)
 #define	MYSQL_SELECT_START_ENABLED() (0)
-#define	MYSQL_UPDATE_END()
-#define	MYSQL_UPDATE_END_ENABLED() (0)
-#define	MYSQL_UPDATE_START()
+#define	MYSQL_UPDATE_DONE(arg0, arg1, arg2)
+#define	MYSQL_UPDATE_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_DONE(arg0)
+#define	MYSQL_UPDATE_ROW_DONE_ENABLED() (0)
+#define	MYSQL_UPDATE_ROW_START(arg0, arg1)
+#define	MYSQL_UPDATE_ROW_START_ENABLED() (0)
+#define	MYSQL_UPDATE_START(arg0)
 #define	MYSQL_UPDATE_START_ENABLED() (0)
 
 #endif

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2008-10-07 20:09:02 +0000
+++ b/sql/scheduler.cc	2008-10-17 17:47:16 +0000
@@ -602,6 +602,8 @@ pthread_handler_t libevent_thread_proc(v
       else
       {
         /* login successful */
+        MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+                               (char *) thd->security_ctx->host_or_ip);
         thd->scheduler.logged_in= TRUE;
         prepare_new_connection_state(thd);
         if (!libevent_needs_immediate_processing(thd))

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2008-09-29 18:41:59 +0000
+++ b/sql/share/errmsg.txt	2008-10-18 07:57:38 +0000
@@ -5020,7 +5020,7 @@ ER_WARN_HOSTNAME_WONT_WORK  
         por "MySQL foi inicializado em modo --skip-name-resolve. Voc�������o para este grant funcionar"
         spa "MySQL esta inicializado en modo --skip-name-resolve. Usted necesita reinicializarlo sin esta opci���n para este derecho funcionar"
 ER_UNKNOWN_STORAGE_ENGINE 42000 
-        eng "Unknown table engine '%s'"
+        eng "Unknown storage engine '%s'"
         ger "Unbekannte Speicher-Engine '%s'"
         por "Motor de tabela desconhecido '%s'"
         spa "Desconocido motor de tabla '%s'"

=== modified file 'sql/si_objects.cc'
--- a/sql/si_objects.cc	2008-10-10 10:11:22 +0000
+++ b/sql/si_objects.cc	2008-10-17 11:28:25 +0000
@@ -261,10 +261,10 @@ bool drop_object(THD *thd, const char *o
   cmd.append(" IF EXISTS ");
   if (name1 && (name1->length() > 0))
   {
-    append_identifier(thd, &cmd, name1->c_ptr(), name1->length());  
+    append_identifier(thd, &cmd, name1->c_ptr(), name1->length());
     cmd.append(".");
   }
-  append_identifier(thd, &cmd, name2->c_ptr(), name2->length());  
+  append_identifier(thd, &cmd, name2->c_ptr(), name2->length());
   DBUG_RETURN(silent_exec(thd, &cmd));
 }
 
@@ -279,7 +279,7 @@ bool drop_object(THD *thd, const char *o
 
   @note: The select condition is designed to form a WHERE clause based on
   the database/schema column of the information_schema views. Most views have
-  a database/schema column but for those that do not, you must ignore the 
+  a database/schema column but for those that do not, you must ignore the
   selection condition by passing db_list = NULL.
 
   @retval TABLE* The schema table
@@ -344,7 +344,7 @@ void prepend_db(THD *thd, String *serial
   */
   serialization->length(0);
   serialization->append("USE ");
-  append_identifier(thd, serialization, db_name->c_ptr(), db_name->length());  
+  append_identifier(thd, serialization, db_name->c_ptr(), db_name->length());
   serialization->append("; ");
   DBUG_VOID_RETURN;
 }
@@ -394,7 +394,7 @@ void delete_table_name_key(void *data)
 ///////////////////////////////////////////////////////////////////////////
 
 namespace obs {
-  
+
 /**
   Build a where clause for list of databases.
 
@@ -408,7 +408,7 @@ namespace obs {
 
   @returns NULL if no databases in list or pointer to COND tree.
 */
-COND *create_db_select_condition(THD *thd, 
+COND *create_db_select_condition(THD *thd,
                                  TABLE *t,
                                  List<LEX_STRING> *db_list)
 {
@@ -416,7 +416,7 @@ COND *create_db_select_condition(THD *th
   List_iterator< ::LEX_STRING> it(*db_list);
   ::LEX_STRING *db;
   DBUG_ENTER("Obj::create_select_condition()");
-  
+
   /*
     If no list of databases, just return NULL
   */
@@ -439,7 +439,7 @@ COND *create_db_select_condition(THD *th
   */
   Item *db_field= new Item_field(thd, thd->lex->current_context(), t->field[1]);
   in_db_list.push_front(db_field);
-  
+
   /*
     Build the in function item comparison and add list of databases.
   */
@@ -711,7 +711,7 @@ class TablespaceObj : public Obj
 {
 public:
   TablespaceObj(const String *ts_name);
-  
+
 public:
   virtual bool do_serialize(THD *thd, String *serialization);
 
@@ -891,7 +891,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////
 
-class InformationSchemaIterator : public ObjIterator
+class InformationSchemaIterator : public Obj_iterator
 {
 public:
   static bool prepare_is_table(
@@ -932,7 +932,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////
 
-class ObjIteratorDummyImpl : ObjIterator
+class ObjIteratorDummyImpl : Obj_iterator
 {
 public:
   ObjIteratorDummyImpl() { return; }
@@ -1081,7 +1081,7 @@ protected:
 private:
   String m_db_name;
 };
- 
+
 class TblGrantIterator : public InformationSchemaIterator
 {
 public:
@@ -1101,7 +1101,7 @@ protected:
 private:
   String m_db_name;
 };
- 
+
 class ColGrantIterator : public InformationSchemaIterator
 {
 public:
@@ -1121,7 +1121,7 @@ protected:
 private:
   String m_db_name;
 };
- 
+
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -1168,7 +1168,7 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////
 
-class ViewBaseObjectsIterator : public ObjIterator
+class ViewBaseObjectsIterator : public Obj_iterator
 {
 public:
   enum IteratorType
@@ -1197,13 +1197,13 @@ private:
   uint m_cur_idx;
 
 private:
-  friend ObjIterator *get_view_base_tables(THD *,
+  friend Obj_iterator *get_view_base_tables(THD *,
+                                            const String *,
+                                            const String *);
+
+  friend Obj_iterator *get_view_base_views(THD *,
                                            const String *,
                                            const String *);
-
-  friend ObjIterator *get_view_base_views(THD *,
-                                          const String *,
-                                          const String *);
 };
 
 ///////////////////////////////////////////////////////////////////////////
@@ -1509,13 +1509,13 @@ DbGrantObj* DbGrantIterator::create_obj(
   */
   if (db_name == m_db_name)
   {
-    DBUG_PRINT("DbGrantIterator::create", (" Found grant %s %s %s", 
+    DBUG_PRINT("DbGrantIterator::create", (" Found grant %s %s %s",
      db_name.ptr(), grantee.ptr(), priv_type.ptr()));
 
     /*
       Include grants for only users that exist at time of backup.
     */
-    if (user_exists(m_thd, &grantee))
+    if (check_user_existence(m_thd, &grantee))
       return new DbGrantObj(&grantee, &db_name, &priv_type);
     else
       return NULL;
@@ -1538,7 +1538,7 @@ TblGrantObj* TblGrantIterator::create_ob
   String db_name;   // corresponds with TABLE_SCHEMA
   String tbl_name;  // corresponds with TABLE_NAME
   String priv_type; // corresponds with PRIVILEGE_TYPE
- 
+
   t->field[0]->val_str(&grantee);
   t->field[2]->val_str(&db_name);
   t->field[3]->val_str(&tbl_name);
@@ -1553,13 +1553,13 @@ TblGrantObj* TblGrantIterator::create_ob
   */
   if (db_name == m_db_name)
   {
-    DBUG_PRINT("TblGrantIterator::create", (" Found grant %s %s %s %s", 
+    DBUG_PRINT("TblGrantIterator::create", (" Found grant %s %s %s %s",
      db_name.ptr(), grantee.ptr(), tbl_name.ptr(), priv_type.ptr()));
 
     /*
       Include grants for only users that exist at time of backup.
     */
-    if (user_exists(m_thd, &grantee))
+    if (check_user_existence(m_thd, &grantee))
       return new TblGrantObj(&grantee, &db_name, &tbl_name, &priv_type);
     else
       return NULL;
@@ -1583,7 +1583,7 @@ ColGrantObj* ColGrantIterator::create_ob
   String tbl_name;  // corresponds with TABLE_NAME
   String col_name;  // corresponds with COLUMN_NAME
   String priv_type; // corresponds with PRIVILEGE_TYPE
- 
+
   t->field[0]->val_str(&grantee);
   t->field[2]->val_str(&db_name);
   t->field[3]->val_str(&tbl_name);
@@ -1599,14 +1599,14 @@ ColGrantObj* ColGrantIterator::create_ob
   */
   if (db_name == m_db_name)
   {
-    DBUG_PRINT("ColGrantIterator::create", (" Found grant %s %s %s %s %s", 
+    DBUG_PRINT("ColGrantIterator::create", (" Found grant %s %s %s %s %s",
      db_name.ptr(), grantee.ptr(), tbl_name.ptr(), col_name.ptr(),
      priv_type.ptr()));
 
     /*
       Include grants for only users that exist at time of backup.
     */
-    if (user_exists(m_thd, &grantee))
+    if (check_user_existence(m_thd, &grantee))
       return new ColGrantObj(&grantee, &db_name, &tbl_name,
                              &col_name, &priv_type);
     else
@@ -1734,14 +1734,14 @@ TableObj *ViewBaseObjectsIterator::next(
 
 ///////////////////////////////////////////////////////////////////////////
 
-ObjIterator *get_databases(THD *thd)
+Obj_iterator *get_databases(THD *thd)
 {
   TABLE *is_table;
   handler *ha;
   my_bitmap_map *orig_columns;
 
   if (InformationSchemaIterator::prepare_is_table(
-      thd, &is_table, &ha, &orig_columns, SCH_SCHEMATA, 
+      thd, &is_table, &ha, &orig_columns, SCH_SCHEMATA,
       thd->lex->db_list))
     return NULL;
 
@@ -1810,37 +1810,37 @@ template
 ColGrantIterator *
 create_is_iterator<ColGrantIterator>(THD *, enum_schema_tables, const String *);
 
-ObjIterator *get_db_tables(THD *thd, const String *db_name)
+Obj_iterator *get_db_tables(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbTablesIterator>(thd, SCH_TABLES, db_name);
 }
 
-ObjIterator *get_db_views(THD *thd, const String *db_name)
+Obj_iterator *get_db_views(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbViewsIterator>(thd, SCH_TABLES, db_name);
 }
 
-ObjIterator *get_db_triggers(THD *thd, const String *db_name)
+Obj_iterator *get_db_triggers(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbTriggerIterator>(thd, SCH_TRIGGERS, db_name);
 }
 
-ObjIterator *get_db_stored_procedures(THD *thd, const String *db_name)
+Obj_iterator *get_db_stored_procedures(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbStoredProcIterator>(thd, SCH_PROCEDURES, db_name);

 }
 
-ObjIterator *get_db_stored_functions(THD *thd, const String *db_name)
+Obj_iterator *get_db_stored_functions(THD *thd, const String *db_name)
 {
   return create_is_iterator<DbStoredFuncIterator>(thd, SCH_PROCEDURES, db_name);
 }
 
-ObjIterator *get_db_events(THD *thd, const String *db_name)
+Obj_iterator *get_db_events(THD *thd, const String *db_name)
 {
 #ifdef HAVE_EVENT_SCHEDULER
   return create_is_iterator<DbEventIterator>(thd, SCH_EVENTS, db_name);
 #else
-  return (ObjIterator *)new ObjIteratorDummyImpl;
+  return (Obj_iterator *)new ObjIteratorDummyImpl;
 #endif
 }
 
@@ -1852,16 +1852,16 @@ ObjIterator *get_db_events(THD *thd, con
   The iterators return all of the grants for the database specified.
 */
 GrantObjIterator::GrantObjIterator(THD *thd, const String *db_name)
-: ObjIterator()
+: Obj_iterator()
 {
-  db_grants= create_is_iterator<DbGrantIterator>(thd, 
-                                                 SCH_SCHEMA_PRIVILEGES, 
+  db_grants= create_is_iterator<DbGrantIterator>(thd,
+                                                 SCH_SCHEMA_PRIVILEGES,
                                                  db_name);
   tbl_grants= create_is_iterator<TblGrantIterator>(thd,
-                                                 SCH_TABLE_PRIVILEGES, 
+                                                 SCH_TABLE_PRIVILEGES,
                                                  db_name);
-  col_grants= create_is_iterator<ColGrantIterator>(thd, 
-                                                 SCH_COLUMN_PRIVILEGES, 
+  col_grants= create_is_iterator<ColGrantIterator>(thd,
+                                                 SCH_COLUMN_PRIVILEGES,
                                                  db_name);
 }
 
@@ -1879,7 +1879,7 @@ Obj *GrantObjIterator::next()
 /**
   Creates a high-level iterator that iterates over database-, table-,
   routine-, and column-level privileges which shall permit a single
-  iterator from the si_objects to retrieve all of the privileges for 
+  iterator from the si_objects to retrieve all of the privileges for
   a given database.
 
   @param[IN] thd      Current THD object
@@ -1890,7 +1890,7 @@ Obj *GrantObjIterator::next()
   @return a pointer to an iterator object.
     @retval NULL in case of error.
 */
-ObjIterator *get_all_db_grants(THD *thd, const String *db_name)
+Obj_iterator *get_all_db_grants(THD *thd, const String *db_name)
 {
   return new GrantObjIterator(thd, db_name);
 }
@@ -1903,17 +1903,17 @@ ObjIterator *get_all_db_grants(THD *thd,
 
 ///////////////////////////////////////////////////////////////////////////
 
-ObjIterator* get_view_base_tables(THD *thd,
-                                  const String *db_name,
-                                  const String *view_name)
+Obj_iterator* get_view_base_tables(THD *thd,
+                                   const String *db_name,
+                                   const String *view_name)
 {
   return ViewBaseObjectsIterator::create(
     thd, db_name, view_name, ViewBaseObjectsIterator::GET_BASE_TABLES);
 }
 
-ObjIterator* get_view_base_views(THD *thd,
-                                 const String *db_name,
-                                 const String *view_name)
+Obj_iterator* get_view_base_views(THD *thd,
+                                  const String *db_name,
+                                  const String *view_name)
 {
   return ViewBaseObjectsIterator::create(
     thd, db_name, view_name, ViewBaseObjectsIterator::GET_BASE_VIEWS);
@@ -2918,8 +2918,8 @@ const String *TablespaceObj::build_seria
   if (m_ts_name.length() > 0)
   {
     THD *thd= current_thd;
-    append_identifier(thd, &m_create_stmt, 
-      m_ts_name.c_ptr(), m_ts_name.length());  
+    append_identifier(thd, &m_create_stmt,
+      m_ts_name.c_ptr(), m_ts_name.length());
   }
   m_create_stmt.append(" ADD DATAFILE '");
   m_create_stmt.append(m_datafile);
@@ -3046,7 +3046,7 @@ bool DbGrantObj::do_execute(THD *thd)
 TblGrantObj::TblGrantObj(const String *grantee,
                          const String *db_name,
                          const String *table_name,
-                         const String *priv_type) 
+                         const String *priv_type)
 : DbGrantObj(grantee, db_name, priv_type)
 {
   // copy strings to newly allocated memory
@@ -3095,7 +3095,7 @@ ColGrantObj::ColGrantObj(const String *g
                          const String *db_name,
                          const String *table_name,
                          const String *col_name,
-                         const String *priv_type) 
+                         const String *priv_type)
 : TblGrantObj(grantee, db_name, table_name, priv_type)
 {
   // copy strings to newly allocated memory
@@ -3188,10 +3188,10 @@ Obj *get_event(const String *db_name,
 
 Obj *materialize_database(const String *db_name,
                           uint serialization_version,
-                          const String *serialialization)
+                          const String *serialization)
 {
   Obj *obj= new DatabaseObj(db_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3199,10 +3199,10 @@ Obj *materialize_database(const String *
 Obj *materialize_table(const String *db_name,
                        const String *table_name,
                        uint serialization_version,
-                       const String *serialialization)
+                       const String *serialization)
 {
   Obj *obj= new TableObj(db_name, table_name, false);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3210,10 +3210,10 @@ Obj *materialize_table(const String *db_
 Obj *materialize_view(const String *db_name,
                       const String *view_name,
                       uint serialization_version,
-                      const String *serialialization)
+                      const String *serialization)
 {
   Obj *obj= new TableObj(db_name, view_name, true);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3221,10 +3221,10 @@ Obj *materialize_view(const String *db_n
 Obj *materialize_trigger(const String *db_name,
                          const String *trigger_name,
                          uint serialization_version,
-                         const String *serialialization)
+                         const String *serialization)
 {
   Obj *obj= new TriggerObj(db_name, trigger_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3232,10 +3232,10 @@ Obj *materialize_trigger(const String *d
 Obj *materialize_stored_procedure(const String *db_name,
                                   const String *stored_proc_name,
                                   uint serialization_version,
-                                  const String *serialialization)
+                                  const String *serialization)
 {
   Obj *obj= new StoredProcObj(db_name, stored_proc_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3243,10 +3243,10 @@ Obj *materialize_stored_procedure(const 
 Obj *materialize_stored_function(const String *db_name,
                                  const String *stored_func_name,
                                  uint serialization_version,
-                                 const String *serialialization)
+                                 const String *serialization)
 {
   Obj *obj= new StoredFuncObj(db_name, stored_func_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3255,10 +3255,10 @@ Obj *materialize_stored_function(const S
 Obj *materialize_event(const String *db_name,
                        const String *event_name,
                        uint serialization_version,
-                       const String *serialialization)
+                       const String *serialization)
 {
   Obj *obj= new EventObj(db_name, event_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3266,10 +3266,10 @@ Obj *materialize_event(const String *db_
 
 Obj *materialize_tablespace(const String *ts_name,
                             uint serialization_version,
-                            const String *serialialization)
+                            const String *serialization)
 {
   Obj *obj= new TablespaceObj(ts_name);
-  obj->materialize(serialization_version, serialialization);
+  obj->materialize(serialization_version, serialization);
 
   return obj;
 }
@@ -3293,7 +3293,7 @@ Obj *materialize_db_grant(const String *
     grants. We use DbGrantObj for all types of grants because
     we only have the GRANT statement in the serialization
     string and therefore do not that the 'parts' to create
-    the specific types. 
+    the specific types.
   */
   Obj *obj= get_db_grant(grantee, db_name);
   obj->materialize(serialization_version, serialization);
@@ -3383,10 +3383,7 @@ int split_user_host(String *grantee, Str
   return 0;
 }
 
-/*
-  Returns TRUE if user is defined on the system.
-*/
-bool user_exists(THD *thd, const String *grantee)
+bool check_user_existence(THD *thd, const String *grantee)
 {
   String user;
   String host;
@@ -3412,7 +3409,7 @@ bool user_exists(THD *thd, const String 
   Locate the row in the information_schema view for this tablespace.
 
   This method returns a row from a tablespace information_schema view
-  that matches the tablespace name passed. 
+  that matches the tablespace name passed.
 
   @param[in]     thd           Thread context
   @param[in]     is_table_idx  The information schema to search
@@ -3420,7 +3417,7 @@ bool user_exists(THD *thd, const String 
   @param[in]     ts_engine     Engine of the tablespace to find
   @param[out]    datafile      The datafile for the tablespace
   @param[out]    comments      The comments for the tablespace
-  
+
   @retval FALSE if tablespace exists and no errors
   @retval TRUE if tablespace does not exist or errors
 */
@@ -3529,14 +3526,14 @@ static bool find_tablespace_schema_row(T
   @param[out]    TablespaceObj A pointer to a new tablespace object
   @param[in]     ts_name       The name of the tablespace to find
   @param[in]     ts_engine     Engine of the tablespace to find
-  
+
   @note Caller is responsible for destroying the tablespace object.
 
   @retval FALSE if tablespace exists and no errors
   @retval TRUE if tablespace does not exist or errors
 */
 static bool get_tablespace_from_schema(THD *thd,
-                                       TablespaceObj **ts, 
+                                       TablespaceObj **ts,
                                        const String *ts_name,
                                        const String *ts_engine)
 {
@@ -3547,14 +3544,14 @@ static bool get_tablespace_from_schema(T
   /*
     Locate the row in TABLESPACES and get the comments.
   */
-  if (find_tablespace_schema_row(thd, SCH_TABLESPACES, 
+  if (find_tablespace_schema_row(thd, SCH_TABLESPACES,
       ts_name, ts_engine, &datafile, &comments))
     DBUG_RETURN(TRUE);
 
   /*
     Locate the row in FILES and get the datafile.
   */
-  if (find_tablespace_schema_row(thd, SCH_FILES, 
+  if (find_tablespace_schema_row(thd, SCH_FILES,
       ts_name, ts_engine, &datafile, &comments))
     DBUG_RETURN(TRUE);
 
@@ -3564,7 +3561,7 @@ static bool get_tablespace_from_schema(T
   if (datafile.length() == 0)
     DBUG_RETURN(TRUE);
 
-  DBUG_PRINT("get_tablespace_from_schema", (" Found tablespace %s %s", 
+  DBUG_PRINT("get_tablespace_from_schema", (" Found tablespace %s %s",
     ts_name->ptr(), datafile.ptr()));
 
   TablespaceObj *ts_local= new TablespaceObj(ts_name);
@@ -3578,20 +3575,20 @@ static bool get_tablespace_from_schema(T
 
 /**
   Retrieve the tablespace for a table if it exists
-  
+
   This method returns a @c TablespaceObj object if the table has a tablespace.
 
   @param[in]  thd       Thread context.
   @param[in]  db_name   The database name for the table.
   @param[in]  tbl_name  The table name.
-  
+
   @note Caller is responsible for destroying the object.
 
-  @retval Tablespace object if table uses a tablespace 
+  @retval Tablespace object if table uses a tablespace
   @retval NULL if table does not use a tablespace
 */
-Obj *get_tablespace_for_table(THD *thd, 
-                              const String *db_name, 
+Obj *get_tablespace_for_table(THD *thd,
+                              const String *db_name,
                               const String *tbl_name)
 {
   TablespaceObj *ts= NULL;
@@ -3599,7 +3596,7 @@ Obj *get_tablespace_for_table(THD *thd, 
   String ts_name, ts_engine;
   const char *ts_name_str= NULL;
   DBUG_ENTER("obs::get_tablespace_for_table()");
-  DBUG_PRINT("obs::get_tablespace_for_table", ("name: %s.%s", 
+  DBUG_PRINT("obs::get_tablespace_for_table", ("name: %s.%s",
              db_name->ptr(), tbl_name->ptr()));
 
   const char *db= db_name->ptr();
@@ -3641,12 +3638,12 @@ end:
   Determine if tablespace exists.
 
   This method determines if a materialized tablespace exists on the
-  system. This compares the name and all saved attributes of the 
+  system. This compares the name and all saved attributes of the
   tablespace. A FALSE return would mean either the tablespace does
   not exist or the tablespace attributes are different.
 
   @param[in]  Obj  The TablspaceObj pointer to compare.
-  
+
   @retval TRUE if it exists
   @retval FALSE if it does not exist
 */
@@ -3660,8 +3657,8 @@ bool tablespace_exists(THD *thd,
                              this_ts->get_engine());
   if (!other_ts)
     DBUG_RETURN(retval);
-  retval= (my_strcasecmp(system_charset_info, 
-           other_ts->build_serialization()->ptr(), 
+  retval= (my_strcasecmp(system_charset_info,
+           other_ts->build_serialization()->ptr(),
            ((TablespaceObj *)ts)->build_serialization()->ptr()) == 0);
   delete other_ts;
   DBUG_RETURN(retval);
@@ -3669,12 +3666,12 @@ bool tablespace_exists(THD *thd,
 
 /**
   Is there a tablespace with the given name?
-  
+
   This method determines if the tablespace referenced by name exists on the
   system. Returns a TablespaceObj if it exists or NULL if it doesn't.
 
   @param[in]  Obj  The TablspaceObj pointer to compare.
-  
+
   @note Caller is responsible for destroying the tablespace object.
 
   @returns the tablespace if found or NULL if not found
@@ -3695,12 +3692,12 @@ Obj *is_tablespace(THD *thd, Obj *ts)
   with the user.
 
   @param[in]  ts  The Tablspace to describe.
-  
+
   @returns tablespace description
 */
-const String *describe_tablespace(Obj *ts)
+const String *get_tablespace_description(Obj *ts)
 {
-  DBUG_ENTER("obs::describe_tablespace()");
+  DBUG_ENTER("obs::get_tablespace_description()");
   DBUG_RETURN(((TablespaceObj *)ts)->describe());
 }
 
@@ -3794,7 +3791,7 @@ TABLE_LIST *Name_locker::build_table_lis
   TABLE_LIST *tl= NULL;
   Obj *tbl= NULL;
   DBUG_ENTER("Name_locker::build_table_list()");
-  
+
   List_iterator<Obj> it(*tables);
   while ((tbl= it++))
   {

=== modified file 'sql/si_objects.h'
--- a/sql/si_objects.h	2008-09-11 16:28:29 +0000
+++ b/sql/si_objects.h	2008-10-17 11:28:25 +0000
@@ -19,10 +19,11 @@ namespace obs {
   Obj defines the basic set of operations for each database object.
 */
 
-class Obj { 
+class Obj
+{
 public:
 
-  bool serialize(THD *thd, String *serialialization);
+  bool serialize(THD *thd, String *serialization);
 
   /**
     Return the name of the object.
@@ -50,18 +51,18 @@ private:
     Read the object state from a given buffer and restores object state to
     the point, where it can be executed.
 
-    @param[in] serialialization_version The version of the serialization format.
-    @param[in] serialialization         Buffer contained serialized object.
+    @param[in] serialization_version The version of the serialization format.
+    @param[in] serialization         Buffer contained serialized object.
 
     @return error status.
       @retval FALSE on success.
       @retval TRUE on error.
   */
   virtual bool materialize(uint serialization_version,
-                           const String *serialialization) = 0;
+                           const String *serialization) = 0;
 
   /// Primitive implementing @c serialize() method.
-  virtual bool do_serialize(THD *thd, String *serialialization) = 0;
+  virtual bool do_serialize(THD *thd, String *serialization) = 0;
 
   /// Primitive implementing @c execute() method.
   virtual bool do_execute(THD *thd) = 0;
@@ -174,8 +175,8 @@ bool Obj::execute(THD *thd)
   the server must be able to materialize objects coded in any previous
   formats.
 
-  @param[in] thd              Server thread context.
-  @param[in] serialialization Buffer to serialize the object
+  @param[in] thd           Server thread context.
+  @param[in] serialization Buffer to serialize the object
 
   @return error status.
     @retval FALSE on success.
@@ -190,7 +191,7 @@ bool Obj::serialize(THD *thd, String *se
 {
   ulong saved_sql_mode= thd->variables.sql_mode;
   thd->variables.sql_mode= 0;
-  
+
   bool ret= do_serialize(thd, serialization);
 
   thd->variables.sql_mode= saved_sql_mode;
@@ -201,14 +202,14 @@ bool Obj::serialize(THD *thd, String *se
 ///////////////////////////////////////////////////////////////////////////
 
 /**
-  ObjIterator is a basic interface to enumerate the objects.
+  Obj_iterator is a basic interface to enumerate the objects.
 */
 
-class ObjIterator
+class Obj_iterator
 {
 public:
 
-  ObjIterator()
+  Obj_iterator()
   { }
 
   /**
@@ -223,7 +224,7 @@ public:
   virtual Obj *next() = 0;
 
 public:
-  virtual ~ObjIterator()
+  virtual ~Obj_iterator()
   { }
 
 };
@@ -232,12 +233,12 @@ public:
   GrantObjIternator is an encapsulation of the three iterators for each level
   of grant supported: database-, table- and routine-, and column-level.
 */
-class GrantObjIterator : public ObjIterator
+class GrantObjIterator : public Obj_iterator
 {
 public:
   GrantObjIterator(THD *thd, const String *db_name);
 
-  ~GrantObjIterator() 
+  ~GrantObjIterator()
   {
     delete db_grants;
     delete tbl_grants;
@@ -256,9 +257,9 @@ public:
   Obj *next();
 
 private:
-  ObjIterator *db_grants;  ///< database-level grants
-  ObjIterator *tbl_grants; ///< table- and routine-level grants
-  ObjIterator *col_grants; ///< column-level grants
+  Obj_iterator *db_grants;  ///< database-level grants
+  Obj_iterator *tbl_grants; ///< table- and routine-level grants
+  Obj_iterator *col_grants; ///< column-level grants
 };
 
 ///////////////////////////////////////////////////////////////////////////
@@ -400,7 +401,7 @@ Obj *get_event(const String *db_name, co
   @return a pointer to an iterator object.
 */
 
-ObjIterator *get_databases(THD *thd);
+Obj_iterator *get_databases(THD *thd);
 
 /**
   Create an iterator over all tables in the particular database.
@@ -411,7 +412,7 @@ ObjIterator *get_databases(THD *thd);
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_tables(THD *thd, const String *db_name);
+Obj_iterator *get_db_tables(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all views in the particular database.
@@ -422,7 +423,7 @@ ObjIterator *get_db_tables(THD *thd, con
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_views(THD *thd, const String *db_name);
+Obj_iterator *get_db_views(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all triggers in the particular database.
@@ -433,7 +434,7 @@ ObjIterator *get_db_views(THD *thd, cons
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_triggers(THD *thd, const String *db_name);
+Obj_iterator *get_db_triggers(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all stored procedures in the particular database.
@@ -444,7 +445,7 @@ ObjIterator *get_db_triggers(THD *thd, c
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_stored_procedures(THD *thd, const String *db_name);
+Obj_iterator *get_db_stored_procedures(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all stored functions in the particular database.
@@ -455,7 +456,7 @@ ObjIterator *get_db_stored_procedures(TH
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_stored_functions(THD *thd, const String *db_name);
+Obj_iterator *get_db_stored_functions(THD *thd, const String *db_name);
 
 /**
   Create an iterator over all events in the particular database.
@@ -466,15 +467,15 @@ ObjIterator *get_db_stored_functions(THD
     @retval NULL in case of error.
 */
 
-ObjIterator *get_db_events(THD *thd, const String *db_name);
+Obj_iterator *get_db_events(THD *thd, const String *db_name);
 
 /*
   Creates a high-level iterator that iterates over database-, table-,
   routine-, and column-level privileges which shall permit a single
-  iterator from the si_objects to retrieve all of the privileges for 
+  iterator from the si_objects to retrieve all of the privileges for
   a given database.
 */
-ObjIterator *get_all_db_grants(THD *thd, const String *db_name);
+Obj_iterator *get_all_db_grants(THD *thd, const String *db_name);
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -491,9 +492,9 @@ ObjIterator *get_all_db_grants(THD *thd,
     @retval NULL in case of error.
 */
 
-ObjIterator* get_view_base_tables(THD *thd,
-                                  const String *db_name,
-                                  const String *view_name);
+Obj_iterator* get_view_base_tables(THD *thd,
+                                   const String *db_name,
+                                   const String *view_name);
 
 /**
   Create an iterator overl all base tables in the particular view.
@@ -504,9 +505,9 @@ ObjIterator* get_view_base_tables(THD *t
     @retval NULL in case of error.
 */
 
-ObjIterator* get_view_base_views(THD *thd,
-                                 const String *db_name,
-                                 const String *view_name);
+Obj_iterator* get_view_base_views(THD *thd,
+                                  const String *db_name,
+                                  const String *view_name);
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -517,41 +518,41 @@ ObjIterator* get_view_base_views(THD *th
 
 Obj *materialize_database(const String *db_name,
                           uint serialization_version,
-                          const String *serialialization);
+                          const String *serialization);
 
 Obj *materialize_table(const String *db_name,
                        const String *table_name,
                        uint serialization_version,
-                       const String *serialialization);
+                       const String *serialization);
 
 Obj *materialize_view(const String *db_name,
                       const String *view_name,
                       uint serialization_version,
-                      const String *serialialization);
+                      const String *serialization);
 
 Obj *materialize_trigger(const String *db_name,
                          const String *trigger_name,
                          uint serialization_version,
-                         const String *serialialization);
+                         const String *serialization);
 
 Obj *materialize_stored_procedure(const String *db_name,
                                   const String *stored_proc_name,
                                   uint serialization_version,
-                                  const String *serialialization);
+                                  const String *serialization);
 
 Obj *materialize_stored_function(const String *db_name,
                                  const String *stored_func_name,
                                  uint serialization_version,
-                                 const String *serialialization);
+                                 const String *serialization);
 
 Obj *materialize_event(const String *db_name,
                        const String *event_name,
                        uint serialization_version,
-                       const String *serialialization);
+                       const String *serialization);
 
 Obj *materialize_tablespace(const String *ts_name,
                             uint serialization_version,
-                            const String *serialialization);
+                            const String *serialization);
 
 Obj *materialize_db_grant(const String *grantee,
                           const String *db_name,
@@ -560,6 +561,14 @@ Obj *materialize_db_grant(const String *
 
 ///////////////////////////////////////////////////////////////////////////
 
+/**
+  Check if the given database name is reserved for internal use.
+
+  @return
+    @retval TRUE if the given database name is reserved for internal use
+    @retval FALSE otherwise.
+*/
+
 bool is_internal_db_name(const String *db_name);
 
 ///////////////////////////////////////////////////////////////////////////
@@ -571,40 +580,49 @@ bool is_internal_db_name(const String *d
     @retval FALSE on success (the database exists and accessible).
     @retval TRUE on error (the database either not exists, or not accessible).
 */
+
 bool check_db_existence(const String *db_name);
 
 /*
-  Returns TRUE if user is defined on the system.
+  Check if the given user is actually defined on the system.
+
+  @return Existence status.
+    @retval TRUE if user is defined on the system.
+    @retval FALSE if user does not exist.
 */
-bool user_exists(THD *thd, const String *grantee);
+
+bool check_user_existence(THD *thd, const String *grantee);
 
 /*
   This method returns a @c TablespaceObj object if the table has a tablespace.
 */
-Obj *get_tablespace_for_table(THD *thd, 
-                              const String *db_name, 
+
+Obj *get_tablespace_for_table(THD *thd,
+                              const String *db_name,
                               const String *tbl_name);
 
 /*
   This method determines if a materialized tablespace exists on the
-  system. This compares the name and all saved attributes of the 
+  system. This compares the name and all saved attributes of the
   tablespace. A FALSE return would mean either the tablespace does
   not exist or the tablespace attributes are different.
 */
-bool tablespace_exists(THD *thd,
-                       Obj *ts);
+
+bool tablespace_exists(THD *thd, Obj *ts);
 
 /*
   This method determines if the tablespace referenced by name exists on the
   system. Returns a TablespaceObj if it exists or NULL if it doesn't.
 */
+
 Obj *is_tablespace(THD *thd, Obj *ts);
 
-/*
-  This method returns a description of the tablespace useful for communicating
-  with the user.
+/**
+  Return a description of the tablespace useful for communicating with the
+  user.
 */
-const String *describe_tablespace(Obj *ts);
+
+const String *get_tablespace_description(Obj *ts);
 
 ///////////////////////////////////////////////////////////////////////////
 
@@ -656,22 +674,22 @@ void ddl_blocker_exception_off(THD *thd)
   Creates a WHERE clause for information schema table lookups of the
   for FROM INFORMATION_SCHEMA.X WHERE <db_col> IN ('a','b','c').
 */
-COND *create_db_select_condition(THD *thd, 
+COND *create_db_select_condition(THD *thd,
                                  TABLE *t,
                                  List<LEX_STRING> *db_list);
 
 /*
   The following class is used to manage name locks on a list of tables.
 
-  This class uses a list of type List<Obj> to establish the table list 
+  This class uses a list of type List<Obj> to establish the table list
   that will be used to manage locks on the tables.
 */
 class Name_locker
 {
 public:
   Name_locker(THD *thd) { m_thd= thd; }
-  ~Name_locker() 
-  { 
+  ~Name_locker()
+  {
     free_table_list(m_table_list);
     m_table_list= NULL;
   }

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2008-10-08 09:27:11 +0000
+++ b/sql/sp_head.cc	2008-10-17 17:47:16 +0000
@@ -2901,7 +2901,14 @@ sp_instr_stmt::print(String *str)
 int
 sp_instr_stmt::exec_core(THD *thd, uint *nextp)
 {
+  MYSQL_QUERY_EXEC_START(thd->query,
+                         thd->thread_id,
+                         (char *) (thd->db ? thd->db: ""),
+                         thd->security_ctx->priv_user,
+                         (char *) thd->security_ctx->host_or_ip,
+                         3);
   int res= mysql_execute_command(thd);
+  MYSQL_QUERY_EXEC_DONE(res);
   *nextp= m_ip+1;
   return res;
 }

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2008-09-30 14:07:24 +0000
+++ b/sql/sql_cache.cc	2008-10-17 17:47:16 +0000
@@ -1482,12 +1482,14 @@ def_week_frmt: %lu",                    
   thd->status_var.last_query_cost= 0.0;
   thd->main_da.disable_status();
 
+  MYSQL_QUERY_CACHE_HIT(thd->query, (ulong) thd->limit_found_rows);
   BLOCK_UNLOCK_RD(query_block);
   DBUG_RETURN(1);				// Result sent to client
 
 err_unlock:
   STRUCT_UNLOCK(&structure_guard_mutex);
 err:
+  MYSQL_QUERY_CACHE_MISS(thd->query);
   DBUG_RETURN(0);				// Query was not cached
 }
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2008-10-08 15:29:55 +0000
+++ b/sql/sql_class.cc	2008-10-21 12:38:13 +0000
@@ -3517,7 +3517,7 @@ int THD::binlog_delete_row(TABLE* table,
 
 int THD::binlog_remove_pending_rows_event(bool clear_maps)
 {
-  DBUG_ENTER(__FUNCTION__);
+  DBUG_ENTER("THD::binlog_remove_pending_rows_event");
 
   if (!mysql_bin_log.is_open())
     DBUG_RETURN(0);

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2008-07-23 08:52:08 +0000
+++ b/sql/sql_connect.cc	2008-10-17 17:47:16 +0000
@@ -1144,6 +1144,9 @@ pthread_handler_t handle_one_connection(
     if (login_connection(thd))
       goto end_thread;
 
+    MYSQL_CONNECTION_START(thd->thread_id, thd->security_ctx->priv_user,
+                           (char *) thd->security_ctx->host_or_ip);
+  
     prepare_new_connection_state(thd);
 
     while (!net->error && net->vio != 0 &&

=== modified file 'sql/sql_cursor.cc'
--- a/sql/sql_cursor.cc	2008-09-04 18:30:34 +0000
+++ b/sql/sql_cursor.cc	2008-10-10 16:23:30 +0000
@@ -167,8 +167,14 @@ int mysql_open_cursor(THD *thd, uint fla
     thd->lock_id= sensitive_cursor->get_lock_id();
     thd->cursor= sensitive_cursor;
   }
-
+  MYSQL_QUERY_EXEC_START(thd->query,
+                         thd->thread_id,
+                         (char *) (thd->db ? thd->db : ""),
+                         thd->security_ctx->priv_user,
+                         (char *) thd->security_ctx->host_or_ip,
+                         2);
   rc= mysql_execute_command(thd);
+  MYSQL_QUERY_EXEC_DONE(rc);
 
   lex->result= save_result;
   thd->lock_id= &thd->main_lock_id;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2008-07-26 16:38:20 +0000
+++ b/sql/sql_delete.cc	2008-10-10 16:23:30 +0000
@@ -37,7 +37,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
                   bool reset_auto_increment)
 {
   bool          will_batch;
-  int		error, loc_error;
+  int		error, loc_error, res;
   TABLE		*table;
   SQL_SELECT	*select=0;
   READ_RECORD	info;
@@ -52,11 +52,15 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   DBUG_ENTER("mysql_delete");
 
   if (open_and_lock_tables(thd, table_list))
+  {
+    MYSQL_DELETE_DONE(1, 0);
     DBUG_RETURN(TRUE);
+  }
   if (!(table= table_list->table))
   {
     my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
 	     table_list->view_db.str, table_list->view_name.str);
+    MYSQL_DELETE_DONE(1, 0);
     DBUG_RETURN(TRUE);
   }
   thd_proc_info(thd, "init");
@@ -160,7 +164,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   {
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    MYSQL_DELETE_END();
+    MYSQL_DELETE_DONE(0, 0);
     my_ok(thd, (ha_rows) thd->row_count_func);  // No matching records
     DBUG_RETURN(0);
   }
@@ -178,7 +182,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
     delete select;
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    MYSQL_DELETE_END();
+    MYSQL_DELETE_DONE(0, 0);
     my_ok(thd, (ha_rows) thd->row_count_func);
     /*
       We don't need to call reset_auto_increment in this case, because
@@ -401,17 +405,18 @@ cleanup:
 
   DEBUG_SYNC(thd, "at_delete_end");
 
-  MYSQL_DELETE_END();
   if (error < 0 || (thd->lex->ignore && !thd->is_fatal_error))
   {
     thd->row_count_func= deleted;
     my_ok(thd, (ha_rows) thd->row_count_func);
     DBUG_PRINT("info",("%ld records deleted",(long) deleted));
   }
-  DBUG_RETURN(error >= 0 || thd->is_error());
+  res= error >= 0 || thd->is_error();
+  MYSQL_DELETE_DONE(res, (ulong) deleted);
+  DBUG_RETURN(res);
 
 err:
-  MYSQL_DELETE_END();
+  MYSQL_DELETE_DONE(1, 0);
   DBUG_RETURN(TRUE);
 }
 
@@ -745,6 +750,7 @@ bool multi_delete::send_data(List<Item> 
       }
     }
   }
+  MYSQL_MULTI_DELETE_DONE(0, (ulong) deleted);
   DBUG_RETURN(0);
 }
 

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2008-10-08 11:46:49 +0000
+++ b/sql/sql_insert.cc	2008-10-17 17:47:16 +0000
@@ -605,18 +605,25 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   {
     my_error(ER_DELAYED_INSERT_TABLE_LOCKED, MYF(0),
              table_list->table_name);
+    MYSQL_INSERT_DONE(1, 0);
     DBUG_RETURN(TRUE);
   }
 
   if (table_list->lock_type == TL_WRITE_DELAYED)
   {
     if (open_and_lock_for_insert_delayed(thd, table_list))
+    {
+      MYSQL_INSERT_DONE(1, 0);
       DBUG_RETURN(TRUE);
+    }
   }
   else
   {
     if (open_and_lock_tables(thd, table_list))
+    {
+      MYSQL_INSERT_DONE(1, 0);
       DBUG_RETURN(TRUE);
+    }
   }
   lock_type= table_list->lock_type;
 
@@ -987,7 +994,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
     ::my_ok(thd, (ulong) thd->row_count_func, id, buff);
   }
   thd->abort_on_warning= 0;
-  MYSQL_INSERT_END();
+  MYSQL_INSERT_DONE(0, (ulong) thd->row_count_func);
   DBUG_RETURN(FALSE);
 
 abort:
@@ -1000,7 +1007,7 @@ abort:
   if (!joins_freed)
     free_underlaid_joins(thd, &thd->lex->select_lex);
   thd->abort_on_warning= 0;
-  MYSQL_INSERT_END();
+  MYSQL_INSERT_DONE(1, 0);
   DBUG_RETURN(TRUE);
 }
 
@@ -3257,6 +3264,7 @@ bool select_insert::send_eof()
   if (error)
   {
     table->file->print_error(error,MYF(0));
+    MYSQL_INSERT_SELECT_DONE(error, 0);
     DBUG_RETURN(1);
   }
   char buff[160];
@@ -3276,6 +3284,7 @@ bool select_insert::send_eof()
      thd->first_successful_insert_id_in_prev_stmt :
      (info.copied ? autoinc_value_of_last_inserted_row : 0));
   ::my_ok(thd, (ulong) thd->row_count_func, id, buff);
+  MYSQL_INSERT_SELECT_DONE(0, (ulong) thd->row_count_func);
   DBUG_RETURN(0);
 }
 
@@ -3329,6 +3338,12 @@ void select_insert::abort() {
     table->file->ha_release_auto_increment();
   }
 
+  if (MYSQL_INSERT_SELECT_DONE_ENABLED())
+  {
+    MYSQL_INSERT_SELECT_DONE(0, (ulong) (info.copied + info.deleted +
+                                         info.updated));
+  }
+
   DBUG_VOID_RETURN;
 }
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2008-10-08 11:46:49 +0000
+++ b/sql/sql_parse.cc	2008-10-17 17:47:16 +0000
@@ -794,7 +794,10 @@ bool dispatch_command(enum enum_server_c
 #if defined(ENABLED_PROFILING)
   thd->profiling.start_new_query();
 #endif
-
+  MYSQL_COMMAND_START(thd->thread_id, command,
+                      thd->security_ctx->priv_user,
+                      (char *) thd->security_ctx->host_or_ip);
+  
   thd->command=command;
   /*
     Commands which always take a long time are logged into
@@ -986,6 +989,10 @@ bool dispatch_command(enum enum_server_c
   {
     if (alloc_query(thd, packet, packet_length))
       break;					// fatal error is set
+    MYSQL_QUERY_START(thd->query, thd->thread_id,
+                      (char *) (thd->db ? thd->db : ""),
+                      thd->security_ctx->priv_user,
+                      (char *) thd->security_ctx->host_or_ip);
     char *packet_end= thd->query + thd->query_length;
     /* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
     const char* end_of_stmt= NULL;
@@ -1026,12 +1033,22 @@ bool dispatch_command(enum enum_server_c
         length--;
       }
 
+      if (MYSQL_QUERY_DONE_ENABLED())
+      {
+        MYSQL_QUERY_DONE(thd->is_error());
+      }
+      
 #if defined(ENABLED_PROFILING)
       thd->profiling.finish_current_query();
       thd->profiling.start_new_query("continuing");
       thd->profiling.set_query_source(beginning_of_next_stmt, length);
 #endif
 
+      MYSQL_QUERY_START(thd->query, thd->thread_id,
+                        (char *) (thd->db ? thd->db : ""),
+                        thd->security_ctx->priv_user,
+                        (char *) thd->security_ctx->host_or_ip);
+      
       pthread_mutex_lock(&LOCK_thread_count);
       thd->query_length= length;
       thd->query= beginning_of_next_stmt;
@@ -1419,7 +1436,17 @@ bool dispatch_command(enum enum_server_c
 #if defined(ENABLED_PROFILING)
   thd->profiling.finish_current_query();
 #endif
-
+  if (MYSQL_QUERY_DONE_ENABLED() || MYSQL_COMMAND_DONE_ENABLED())
+  {
+    int res;
+    res= (int) thd->is_error();
+    if (command == COM_QUERY)
+    {
+      MYSQL_QUERY_DONE(res);
+    }
+    MYSQL_COMMAND_DONE(res);
+  }
+  
   DBUG_RETURN(error);
 }
 
@@ -2858,6 +2885,7 @@ ddl_blocker_err:
       break;
     DBUG_ASSERT(select_lex->offset_limit == 0);
     unit->set_limit(select_lex);
+    MYSQL_UPDATE_START(thd->query);
     res= (up_result= mysql_update(thd, all_tables,
                                   select_lex->item_list,
                                   lex->value_list,
@@ -2917,7 +2945,7 @@ ddl_blocker_err:
 #ifdef HAVE_REPLICATION
     }  /* unlikely */
 #endif
-
+    MYSQL_MULTI_UPDATE_START(thd->query);
     res= mysql_multi_update(thd, all_tables,
                             &select_lex->item_list,
                             &lex->value_list,
@@ -2970,6 +2998,7 @@ ddl_blocker_err:
       break;
     }
 
+    MYSQL_INSERT_START(thd->query);
     res= mysql_insert(thd, all_tables, lex->field_list, lex->many_values,
 		      lex->update_list, lex->value_list,
                       lex->duplicates, lex->ignore);
@@ -3013,6 +3042,8 @@ ddl_blocker_err:
 
     if (!(res= open_and_lock_tables(thd, all_tables)))
     {
+      MYSQL_INSERT_SELECT_START(thd->query);
+      
       /* Skip first table, which is the table we are inserting in */
       TABLE_LIST *second_table= first_table->next_local;
       select_lex->table_list.first= (uchar*) second_table;
@@ -3097,6 +3128,7 @@ ddl_blocker_err:
       break;
     }
 
+    MYSQL_DELETE_START(thd->query);
     res = mysql_delete(thd, all_tables, select_lex->where,
                        &select_lex->order_list,
                        unit->select_limit_cnt, select_lex->options,
@@ -3127,6 +3159,7 @@ ddl_blocker_err:
       goto error;
 
     thd_proc_info(thd, "init");
+    MYSQL_MULTI_DELETE_START(thd->query);
     if ((res= open_and_lock_tables(thd, all_tables)))
       break;
 
@@ -5516,6 +5549,7 @@ void mysql_init_multi_delete(LEX *lex)
 void mysql_parse(THD *thd, const char *inBuf, uint length,
                  const char ** found_semicolon)
 {
+  int error;
   DBUG_ENTER("mysql_parse");
 
   DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););
@@ -5584,7 +5618,15 @@ void mysql_parse(THD *thd, const char *i
             thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
           }
           lex->set_trg_event_type_for_tables();
-          mysql_execute_command(thd);
+	  MYSQL_QUERY_EXEC_START(thd->query,
+                                 thd->thread_id,
+                                 (char *) (thd->db ? thd->db : ""),
+                                 thd->security_ctx->priv_user,
+                                 (char *) thd->security_ctx->host_or_ip,
+                                 0);
+
+          error= mysql_execute_command(thd);
+	  MYSQL_QUERY_EXEC_DONE(error);
 	}
       }
     }
@@ -7518,6 +7560,8 @@ bool parse_sql(THD *thd,
   bool mysql_parse_status;
   DBUG_ASSERT(thd->m_parser_state == NULL);
 
+  MYSQL_QUERY_PARSE_START(thd->query);
+  
   /* Backup creation context. */
 
   Object_creation_ctx *backup_ctx= NULL;
@@ -7549,6 +7593,8 @@ bool parse_sql(THD *thd,
 
   /* That's it. */
 
+  MYSQL_QUERY_PARSE_DONE(mysql_parse_status || thd->is_fatal_error);
+  
   return mysql_parse_status || thd->is_fatal_error;
 }
 

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2008-08-07 17:52:43 +0000
+++ b/sql/sql_prepare.cc	2008-10-10 16:23:30 +0000
@@ -3568,7 +3568,14 @@ bool Prepared_statement::execute(String 
     if (query_cache_send_result_to_client(thd, thd->query,
                                           thd->query_length) <= 0)
     {
+      MYSQL_QUERY_EXEC_START(thd->query,
+                             thd->thread_id,
+                             (char *) (thd->db ? thd->db : ""),
+                             thd->security_ctx->priv_user,
+                             (char *) thd->security_ctx->host_or_ip,
+                             1);
       error= mysql_execute_command(thd);
+      MYSQL_QUERY_EXEC_DONE(error);
     }
   }
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-10-19 07:25:05 +0000
+++ b/sql/sql_select.cc	2008-10-23 15:13:34 +0000
@@ -31,6 +31,7 @@
 #include "mysql_priv.h"
 #include "sql_select.h"
 #include "sql_cursor.h"
+
 #include <m_ctype.h>
 #include <my_bit.h>
 #include <hash.h>
@@ -278,7 +279,7 @@ bool handle_select(THD *thd, LEX *lex, s
   bool res;
   register SELECT_LEX *select_lex = &lex->select_lex;
   DBUG_ENTER("handle_select");
-  MYSQL_SELECT_START();
+  MYSQL_SELECT_START(thd->query);
 
   if (select_lex->master_unit()->is_union() || 
       select_lex->master_unit()->fake_select_lex)
@@ -312,7 +313,8 @@ bool handle_select(THD *thd, LEX *lex, s
   if (unlikely(res))
     result->abort();
 
-  MYSQL_SELECT_END();
+  MYSQL_SELECT_DONE((int) res, (ulong) thd->limit_found_rows);
+
   DBUG_RETURN(res);
 }
 

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2008-10-08 11:46:49 +0000
+++ b/sql/sql_table.cc	2008-10-16 12:18:07 +0000
@@ -7024,7 +7024,6 @@ view_err:
   /* Copy the data if necessary. */
   thd->count_cuted_fields= CHECK_FIELD_WARN;	// calc cuted fields
   thd->cuted_fields=0L;
-  thd_proc_info(thd, "copy to tmp table");
   copied=deleted=0;
   /*
     We do not copy data for MERGE tables. Only the children have data.
@@ -7035,6 +7034,7 @@ view_err:
     /* We don't want update TIMESTAMP fields during ALTER TABLE. */
     new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
     new_table->next_number_field=new_table->found_next_number_field;
+    thd_proc_info(thd, "copy to tmp table");
     error= copy_data_between_tables(table, new_table,
                                     alter_info->create_list, ignore,
                                    order_num, order, &copied, &deleted,
@@ -7604,6 +7604,12 @@ bool mysql_checksum_table(THD *thd, TABL
 	{
 	  for (;;)
 	  {
+            if (thd->killed)
+            {
+              t->file->ha_rnd_end();
+              thd->protocol->remove_last_row();
+              goto err;
+            }
 	    ha_checksum row_crc= 0;
             int error= t->file->rnd_next(t->record[0]);
             if (unlikely(error))

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2008-10-09 16:13:03 +0000
+++ b/sql/sql_update.cc	2008-10-17 17:47:16 +0000
@@ -209,7 +209,10 @@ int mysql_update(THD *thd,
   for ( ; ; )
   {
     if (open_tables(thd, &table_list, &table_count, 0))
+    {
+      MYSQL_UPDATE_DONE(1, 0, 0);
       DBUG_RETURN(1);
+    }
 
     if (table_list->multitable_view)
     {
@@ -218,21 +221,27 @@ int mysql_update(THD *thd,
       /* pass counter value */
       thd->lex->table_count= table_count;
       /* convert to multiupdate */
+      MYSQL_UPDATE_DONE(2, 0, 0);
       DBUG_RETURN(2);
     }
     if (!lock_tables(thd, table_list, table_count, 0, &need_reopen))
       break;
     if (!need_reopen)
+    {
+      MYSQL_UPDATE_DONE(1, 0, 0);
       DBUG_RETURN(1);
+    }
     close_tables_for_reopen(thd, &table_list, FALSE);
   }
 
   if (mysql_handle_derived(thd->lex, &mysql_derived_prepare) ||
       (thd->fill_derived_tables() &&
        mysql_handle_derived(thd->lex, &mysql_derived_filling)))
+  {
+    MYSQL_UPDATE_DONE(1, 0, 0);
     DBUG_RETURN(1);
+  }
 
-  MYSQL_UPDATE_START();
   thd_proc_info(thd, "init");
   table= table_list->table;
 
@@ -292,7 +301,7 @@ int mysql_update(THD *thd,
   if (select_lex->inner_refs_list.elements &&
     fix_inner_refs(thd, all_fields, select_lex, select_lex->ref_pointer_array))
   {
-    MYSQL_UPDATE_END();
+    MYSQL_UPDATE_DONE(1, 0, 0);
     DBUG_RETURN(-1);
   }
 
@@ -321,8 +330,8 @@ int mysql_update(THD *thd,
   if (prune_partitions(thd, table, conds))
   {
     free_underlaid_joins(thd, select_lex);
-    MYSQL_UPDATE_END();
     my_ok(thd);				// No matching records
+    MYSQL_UPDATE_DONE(0, 0, 0);
     DBUG_RETURN(0);
   }
 #endif
@@ -337,8 +346,8 @@ int mysql_update(THD *thd,
     free_underlaid_joins(thd, select_lex);
     if (error)
       goto abort;				// Error in where
-    MYSQL_UPDATE_END();
     my_ok(thd);				// No matching records
+    MYSQL_UPDATE_DONE(0, 0, 0);
     DBUG_RETURN(0);
   }
   if (!select && limit != HA_POS_ERROR)
@@ -811,7 +820,6 @@ int mysql_update(THD *thd,
   id= thd->arg_of_last_insert_id_function ?
     thd->first_successful_insert_id_in_prev_stmt : 0;
 
-  MYSQL_UPDATE_END();
   if (error < 0)
   {
     char buff[STRING_BUFFER_USUAL_SIZE];
@@ -824,7 +832,10 @@ int mysql_update(THD *thd,
   }
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;		/* calc cuted fields */
   thd->abort_on_warning= 0;
-  DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
+
+  res= (error >= 0 || thd->is_error()) ? 1 : 0;
+  MYSQL_UPDATE_DONE(res, (ulong) found, (ulong) updated);
+  DBUG_RETURN(res);
 
 err:
   delete select;
@@ -837,7 +848,7 @@ err:
   thd->abort_on_warning= 0;
 
 abort:
-  MYSQL_UPDATE_END();
+  MYSQL_UPDATE_DONE(1, 0, 0);
   DBUG_RETURN(1);
 }
 
@@ -1622,7 +1633,10 @@ bool multi_update::send_data(List<Item> 
                                                *values_for_table[offset], 0,
                                                table->triggers,
                                                TRG_EVENT_UPDATE))
+      {
+        MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
 	DBUG_RETURN(1);
+      }
 
       found++;
       if (!can_compare_record || compare_record(table))
@@ -1635,7 +1649,10 @@ bool multi_update::send_data(List<Item> 
           if (error == VIEW_CHECK_SKIP)
             continue;
           else if (error == VIEW_CHECK_ERROR)
+          {
+            MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
             DBUG_RETURN(1);
+          }
         }
         if (!updated++)
         {
@@ -1665,6 +1682,7 @@ bool multi_update::send_data(List<Item> 
 
             prepare_record_for_error_message(error, table);
             table->file->print_error(error,MYF(flags));
+            MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
             DBUG_RETURN(1);
           }
         }
@@ -1689,7 +1707,10 @@ bool multi_update::send_data(List<Item> 
       if (table->triggers &&
           table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
                                             TRG_ACTION_AFTER, TRUE))
+      {
+        MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
         DBUG_RETURN(1);
+      }
     }
     else
     {
@@ -1732,12 +1753,14 @@ bool multi_update::send_data(List<Item> 
                                          error, 1))
         {
           do_update=0;
+          MYSQL_MULTI_UPDATE_DONE(1, 0, 0);
 	  DBUG_RETURN(1);			// Not a table_is_full error
 	}
         found++;
       }
     }
   }
+  MYSQL_UPDATE_DONE(0, (ulong) found, (ulong) updated);
   DBUG_RETURN(0);
 }
 

=== modified file 'storage/falcon/NNode.h'
--- a/storage/falcon/NNode.h	2007-09-20 15:44:25 +0000
+++ b/storage/falcon/NNode.h	2008-09-20 23:20:02 +0000
@@ -109,7 +109,7 @@ enum NType {
 	Cast,
 	BlobRef,
 	Upper,
-	Lower,
+	Lower
    };
 
 class NNode  

=== modified file 'storage/falcon/Types.h'
--- a/storage/falcon/Types.h	2008-06-19 15:09:45 +0000
+++ b/storage/falcon/Types.h	2008-09-20 23:20:02 +0000
@@ -70,7 +70,7 @@ enum JdbcType {
 	jdbcBLOB	= 2004,
 	jdbcCLOB	= 2005,
 	CLOB		= 2005,
-	NUMERIC		= 2,
+	NUMERIC		= 2
 	};
 #endif
 
@@ -103,7 +103,7 @@ enum TerType {
 	terScaledLong,
 	terScaledQuad,
 	terRepositoryBlob,
-	terRepositoryClob,
+	terRepositoryClob
 	};
 
 

=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp	2008-10-03 05:15:40 +0000
+++ b/storage/falcon/ha_falcon.cpp	2008-10-08 10:54:19 +0000
@@ -1094,14 +1094,19 @@ int StorageInterface::write_row(uchar *b
 
 	if (table->next_number_field && buff == table->record[0])
 		{
-		update_auto_increment();
+		int code = update_auto_increment();
+		/*
+		   May fail, e.g. due to an out of range value in STRICT mode.
+		*/
+		if (code)
+			DBUG_RETURN(code);
 
 		/*
 		   If the new value is less than the current highest value, it will be
 		   ignored by setSequenceValue().
 		*/
 
-		int code = storageShare->setSequenceValue(table->next_number_field->val_int());
+		code = storageShare->setSequenceValue(table->next_number_field->val_int());
 
 		if (code)
 			DBUG_RETURN(error(code));

=== modified file 'storage/falcon/plug.in'
--- a/storage/falcon/plug.in	2008-08-20 13:27:29 +0000
+++ b/storage/falcon/plug.in	2008-09-23 09:08:59 +0000
@@ -66,33 +66,40 @@ MYSQL_PLUGIN_ACTIONS(falcon,[
   AC_CACHE_CHECK([compiler flag to enable implicit templates],
                  falcon_cxx_enable_implicit_templates,[
     CXXFLAGS="$ac_save_CXXFLAGS -fimplicit-templates"
-    AC_TRY_LINK([],
-      [int i = 0;
-       i++;],
-      falcon_cxx_enable_implicit_templates="-fimplicit-templates",
-      falcon_cxx_enable_implicit_templates=""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+      falcon_cxx_enable_implicit_templates="-fimplicit-templates"
     )
   ])
 
+  # -lstdc++ really shouldn't be here, and is only required while we continue
+  # to use gcc to link C++ code for the static linking hack.  Once we stop
+  # doing that it should be removed from here, and the CXXLDFLAG setting below
+  # will do the right thing for g++.
   AC_CACHE_CHECK([compiler flag to enable exceptions],
                  falcon_cxx_enable_exceptions,[
-    CXXFLAGS="$ac_save_CXXFLAGS -fexceptions -lstdc++"
-    AC_TRY_LINK([],
-      [int i = 0;
-       i++;],
-      falcon_cxx_enable_exceptions="-fexceptions -lstdc++",
-      falcon_cxx_enable_exceptions=""
-    )
+    m4_foreach([cxxflag], [[-fexceptions -lstdc++], [-features=except]],[
+      CXXFLAGS="$ac_save_CXXFLAGS cxxflag"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+        falcon_cxx_enable_exceptions="cxxflag"
+      )
+    ])
+  ])
+
+  AC_CACHE_CHECK([linker flag to enable STL],
+                 falcon_cxx_enable_stl,[
+    m4_foreach([cxxflag], [-lstdc++],[
+      CXXFLAGS="$ac_save_CXXFLAGS cxxflag"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+        falcon_cxx_enable_stl="cxxflag"
+      )
+    ])
   ])
 
   AC_CACHE_CHECK([compiler flag to silence offsetof warnings],
                  falcon_cxx_no_invalid_offsetof,[
     CXXFLAGS="$ac_save_CXXFLAGS -Wno-invalid-offsetof"
-    AC_TRY_LINK([],
-      [int i = 0;
-       i++;],
-      falcon_cxx_no_invalid_offsetof="-Wno-invalid-offsetof",
-      falcon_cxx_no_invalid_offsetof=""
+    AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+      falcon_cxx_no_invalid_offsetof="-Wno-invalid-offsetof"
     )
   ])
 
@@ -100,7 +107,7 @@ MYSQL_PLUGIN_ACTIONS(falcon,[
   AC_LANG_POP([C++])
 
   # Falcon uses exceptions and STL.
-  CXXLDFLAGS="$CXXLDFLAGS $falcon_cxx_enable_exceptions"
+  CXXLDFLAGS="$CXXLDFLAGS $falcon_cxx_enable_stl"
   FALCON_CXXFLAGS="$falcon_cxx_no_invalid_offsetof $falcon_cxx_enable_implicit_templates $falcon_cxx_enable_exceptions"
   case "$with_debug" in
     yes)  FALCON_CXXFLAGS="$FALCON_CXXFLAGS -D_DEBUG" ;;

=== modified file 'support-files/my-huge.cnf.sh'
--- a/support-files/my-huge.cnf.sh	2008-10-03 12:24:19 +0000
+++ b/support-files/my-huge.cnf.sh	2008-10-16 12:18:07 +0000
@@ -124,7 +124,6 @@ server-id	= 1
 #innodb_data_home_dir = @localstatedir@/
 #innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
 #innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
 # You can set .._buffer_pool_size up to 50 - 80 %
 # of RAM but beware of setting memory usage too high
 #innodb_buffer_pool_size = 384M

=== modified file 'support-files/my-large.cnf.sh'
--- a/support-files/my-large.cnf.sh	2008-10-03 12:24:19 +0000
+++ b/support-files/my-large.cnf.sh	2008-10-16 12:18:07 +0000
@@ -124,7 +124,6 @@ server-id	= 1
 #innodb_data_home_dir = @localstatedir@/
 #innodb_data_file_path = ibdata1:10M:autoextend
 #innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
 # You can set .._buffer_pool_size up to 50 - 80 %
 # of RAM but beware of setting memory usage too high
 #innodb_buffer_pool_size = 256M

=== modified file 'support-files/my-medium.cnf.sh'
--- a/support-files/my-medium.cnf.sh	2008-10-03 12:24:19 +0000
+++ b/support-files/my-medium.cnf.sh	2008-10-16 12:18:07 +0000
@@ -122,7 +122,6 @@ server-id	= 1
 #innodb_data_home_dir = @localstatedir@/
 #innodb_data_file_path = ibdata1:10M:autoextend
 #innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
 # You can set .._buffer_pool_size up to 50 - 80 %
 # of RAM but beware of setting memory usage too high
 #innodb_buffer_pool_size = 16M

=== modified file 'support-files/my-small.cnf.sh'
--- a/support-files/my-small.cnf.sh	2008-10-03 12:24:19 +0000
+++ b/support-files/my-small.cnf.sh	2008-10-16 12:18:07 +0000
@@ -55,7 +55,6 @@ server-id	= 1
 #innodb_data_home_dir = @localstatedir@/
 #innodb_data_file_path = ibdata1:10M:autoextend
 #innodb_log_group_home_dir = @localstatedir@/
-#innodb_log_arch_dir = @localstatedir@/
 # You can set .._buffer_pool_size up to 50 - 80 %
 # of RAM but beware of setting memory usage too high
 #innodb_buffer_pool_size = 16M

=== modified file 'support-files/mysql.spec.sh'
--- a/support-files/mysql.spec.sh	2008-09-11 08:01:28 +0000
+++ b/support-files/mysql.spec.sh	2008-10-21 15:45:46 +0000
@@ -252,8 +252,8 @@ BuildMySQL() {
 # The --enable-assembler simply does nothing on systems that does not
 # support assembler speedups.
 sh -c  "PATH=\"${MYSQL_BUILD_PATH:-$PATH}\" \
-	CC=\"${CC:-$MYSQL_BUILD_CC}\" \
-	CXX=\"${CXX:-$MYSQL_BUILD_CXX}\" \
+	CC=\"${MYSQL_BUILD_CC:-$CC}\" \
+	CXX=\"${MYSQL_BUILD_CXX:-$CXX}\" \
 	CFLAGS=\"$CFLAGS\" \
 	CXXFLAGS=\"$CXXFLAGS\" \
 	LDFLAGS=\"$MYSQL_BUILD_LDFLAGS\" \

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2008-09-15 20:37:25 +0000
+++ b/tests/mysql_client_test.c	2008-10-17 12:39:34 +0000
@@ -18456,6 +18456,49 @@ static void test_bug38486(void)
   DBUG_VOID_RETURN;
 }
 
+
+/**
+     Bug# 33831 mysql_real_connect() should fail if
+     given an already connected MYSQL handle.
+*/
+
+static void test_bug33831(void)
+{
+  MYSQL *l_mysql;
+  my_bool error;
+
+  DBUG_ENTER("test_bug33831");
+  
+  error= 0;
+
+  if (!(l_mysql= mysql_init(NULL)))
+  {
+    myerror("mysql_init() failed");
+    DIE_UNLESS(0);
+  }
+  if (!(mysql_real_connect(l_mysql, opt_host, opt_user,
+                           opt_password, current_db, opt_port,
+                           opt_unix_socket, 0)))
+  {
+    myerror("connection failed");
+    DIE_UNLESS(0);
+  }
+
+  if (mysql_real_connect(l_mysql, opt_host, opt_user,
+                         opt_password, current_db, opt_port,
+                         opt_unix_socket, 0))
+  {
+    myerror("connection should have failed");
+    DIE_UNLESS(0);
+  }
+
+
+  mysql_close(l_mysql);
+  
+  DBUG_VOID_RETURN;
+}
+
+
 /*
   Read and parse arguments and MySQL options from my.cnf
 */
@@ -18770,6 +18813,7 @@ static struct my_tests_st my_tests[]= {
   { "test_wl4284_1", test_wl4284_1 },
   { "test_wl4435",   test_wl4435 },
   { "test_bug38486", test_bug38486 },
+  { "test_bug33831", test_bug33831 },
   { 0, 0 }
 };
 

Thread
bzr commit into mysql-6.0-opt-subqueries branch (sergefp:2708)Sergey Petrunia23 Oct