List:Commits« Previous MessageNext Message »
From:Daniel Fischer Date:April 19 2007 6:01pm
Subject:bk commit into 5.0-community tree (df:1.2464)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0-community repository of df. When df does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-04-19 18:01:30+02:00, df@stripped +35 -0
  Merge dev:my/mysql-5.0-release
  into  pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-community-work-27020
  MERGE: 1.2392.104.26

  configure.in@stripped, 2007-04-19 18:01:28+02:00, df@stripped +2 -4
    merge fix
    MERGE: 1.416.1.22

  include/config-win.h@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.84.1.1

  myisam/mi_open.c@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.105.1.1

  mysql-test/r/func_in.result@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0
-5
    Auto merged
    MERGE: 1.33.1.1

  mysql-test/r/information_schema.result@stripped, 2007-04-19 17:59:55+02:00,
df@stripped +0 -0
    Auto merged
    MERGE: 1.117.1.4

  mysql-test/t/func_in.test@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0
-11
    Auto merged
    MERGE: 1.27.1.1

  ndb/src/ndbapi/DictCache.cpp@stripped, 2007-04-19 17:59:55+02:00, df@stripped
+0 -0
    Auto merged
    MERGE: 1.20.1.1

  sql/ha_archive.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.83.1.1

  sql/ha_myisam.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.175.2.1

  sql/ha_ndbcluster.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.299.4.1

  sql/item_cmpfunc.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -2
    Auto merged
    MERGE: 1.240.1.2

  sql/item_func.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.327.2.1

  sql/lex.h@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.145.1.1

  sql/lock.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.93.1.2

  sql/log_event.cc@stripped, 2007-04-19 17:59:55+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.228.1.1

  sql/mysql_priv.h@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.437.1.2

  sql/mysqld.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.598.2.1

  sql/slave.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.295.1.1

  sql/sp_head.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.236.1.2

  sql/sql_base.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.360.1.15

  sql/sql_class.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.256.1.11

  sql/sql_class.h@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.314.1.13

  sql/sql_delete.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.188.1.9

  sql/sql_insert.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.211.1.18

  sql/sql_lex.cc@stripped, 2007-04-19 17:59:56+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.217.1.2

  sql/sql_parse.cc@stripped, 2007-04-19 17:59:57+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.593.1.19

  sql/sql_prepare.cc@stripped, 2007-04-19 17:59:57+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.196.1.1

  sql/sql_select.cc@stripped, 2007-04-19 17:59:57+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.498.3.1

  sql/sql_show.cc@stripped, 2007-04-19 17:59:57+02:00, df@stripped +0 -9
    Auto merged
    MERGE: 1.341.2.2

  sql/sql_table.cc@stripped, 2007-04-19 17:59:58+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.333.3.1

  sql/sql_update.cc@stripped, 2007-04-19 17:59:58+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.212.1.1

  sql/sql_view.cc@stripped, 2007-04-19 17:59:58+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.105.1.1

  sql/sql_yacc.yy@stripped, 2007-04-19 17:59:58+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.509.2.1

  sql/table.h@stripped, 2007-04-19 17:59:58+02:00, df@stripped +0 -0
    Auto merged
    MERGE: 1.138.1.3

  support-files/mysql.spec.sh@stripped, 2007-04-19 18:01:28+02:00, df@stripped
+1 -0
    merge fix
    MERGE: 1.169.1.1

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	df
# Host:	pippilotta.erinye.com
# Root:	/shared/home/df/mysql/build/mysql-5.0-community-work-27020/RESYNC

--- 1.425/configure.in	2007-04-04 13:44:10 +02:00
+++ 1.426/configure.in	2007-04-19 18:01:28 +02:00
@@ -7,7 +7,7 @@
 AC_CANONICAL_SYSTEM
 # The Docs Makefile.am parses this line!
 # remember to also change ndb version below and update version.c in ndb
-AM_INIT_AUTOMAKE(mysql, 5.0.39)
+AM_INIT_AUTOMAKE(mysql, 5.0.41)
 AM_CONFIG_HEADER(config.h)
 
 PROTOCOL_VERSION=10
@@ -23,14 +23,14 @@
 # ndb version
 NDB_VERSION_MAJOR=5
 NDB_VERSION_MINOR=0
-NDB_VERSION_BUILD=39
+NDB_VERSION_BUILD=41
 NDB_VERSION_STATUS=""
 
 # Set all version vars based on $VERSION. How do we do this more elegant ?
 # Remember that regexps needs to quote [ and ] since this is run through m4
 MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"`
 MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"`
-MYSQL_VERSION_ID=`echo $MYSQL_NO_DASH_VERSION. | sed -e 's/[[^0-9.]]//g; s/\./  /g; s/
\([[0-9]]\) / 0\\1 /g; s/ //g'`
+MYSQL_VERSION_ID=`echo $MYSQL_NO_DASH_VERSION | sed -e 's|[[^0-9.]].*$||;s|$|.|' | sed -e
's/[[^0-9.]]//g; s/\./  /g; s/ \([[0-9]]\) / 0\\1 /g; s/ //g'`
 
 # The port should be constant for a LONG time
 MYSQL_TCP_PORT_DEFAULT=3306
@@ -1615,9 +1615,9 @@
 # dlopen, dlerror
 case "$with_mysqld_ldflags " in
 
-  *"-static "*)
+  *"-all-static "*)
     # No need to check for dlopen when mysqld is linked with
-    # -all-static or -static as it won't be able to load any functions.
+    # -all-static as it won't be able to load any functions.
     # NOTE! It would be better if it was possible to test if dlopen
     # can be used, but a good way to test it couldn't be found
 
@@ -2390,22 +2390,6 @@
     [with_man=yes]
 )
 
-if test "$with_man" = "yes"
-then
-  man_dirs="man"
-  man1_files=`ls -1 $srcdir/man/*.1 | sed -e 's;^.*man/;;'`
-  man1_files=`echo $man1_files`
-  man8_files=`ls -1 $srcdir/man/*.8 | sed -e 's;^.*man/;;'`
-  man8_files=`echo $man8_files`
-else
-  man_dirs=""
-  man1_files=""
-  man8_files=""
-fi
-AC_SUBST(man_dirs)
-AC_SUBST(man1_files)
-AC_SUBST(man8_files)
-
 # Shall we build the bench code?
 AC_ARG_WITH(bench,
     [  --without-bench         Skip building of the benchmark suite.],
@@ -2539,6 +2523,60 @@
 MYSQL_CHECK_BLACKHOLEDB
 MYSQL_CHECK_NDBCLUSTER
 MYSQL_CHECK_FEDERATED
+
+# Include man pages, if desired, adapted to the configured parts.
+if test X"$with_man" = Xyes
+then
+  # First, create the list of all man pages present.
+  MANLISTFIL=manlist.$$
+  TMPLISTFIL=`echo $MANLISTFIL | sed -e 's/manlist/tmplist/'`
+  if test -f $MANLISTFIL -o -f $TMPLISTFIL
+  then
+    echo "Temp file '$MANLISTFIL' or '$TMPLISTFIL' already exists in '`pwd`' - aborting"
+    exit 1
+  fi
+  touch $MANLISTFIL $TMPLISTFIL
+
+  ls $srcdir/man/*.[[18]] > $MANLISTFIL
+
+  # Then, remove all those pages from the list which are specific to parts
+  # (table handlers, features, ...) which are not configured in this run.
+  AC_MSG_CHECKING("for man pages to remove")
+  MAN_DROP="dropping"
+  if test X"$have_ndbcluster" != Xyes
+  then
+    MAN_DROP="$MAN_DROP ndbcluster"
+    grep -v '/ndb' $MANLISTFIL > $TMPLISTFIL ; mv -f $TMPLISTFIL $MANLISTFIL
+  fi
+  if test X"$with_embedded_server" != Xyes
+  then
+    MAN_DROP="$MAN_DROP embedded"
+    grep -v 'embedded' $MANLISTFIL > $TMPLISTFIL ; mv -f $TMPLISTFIL $MANLISTFIL
+  fi
+  if test X"$have_innodb" != Xyes
+  then
+    MAN_DROP="$MAN_DROP innodb"
+    grep -v 'inno' $MANLISTFIL > $TMPLISTFIL ; mv -f $TMPLISTFIL $MANLISTFIL
+  fi
+  AC_MSG_RESULT([$MAN_DROP])
+
+  # Finally, split the man pages into sections 1 and 8.
+  # Get rid of line breaks.
+  man1_files=`sed -n -e '/\.1$/s/^.*man\///p' <$MANLISTFIL`
+  man8_files=`sed -n -e '/\.8$/s/^.*man\///p' <$MANLISTFIL`
+
+  man_dirs="man"
+  man1_files=`echo $man1_files`
+  man8_files=`echo $man8_files`
+  rm -f $MANLISTFIL $TMPLISTFIL
+else
+  man_dirs=""
+  man1_files=""
+  man8_files=""
+fi
+AC_SUBST(man_dirs)
+AC_SUBST(man1_files)
+AC_SUBST(man8_files)
 
 # If we have threads generate some library functions and test programs
 sql_server_dirs=

--- 1.85/include/config-win.h	2007-03-28 23:00:25 +02:00
+++ 1.86/include/config-win.h	2007-04-19 17:59:55 +02:00
@@ -205,6 +205,9 @@
 /* If LOAD DATA LOCAL INFILE should be enabled by default */
 #define ENABLED_LOCAL_INFILE 1
 
+/* If query profiling should be enabled by default */
+#define ENABLED_PROFILING 1
+
 /* Convert some simple functions to Posix */
 
 #define my_sigset(A,B) signal((A),(B))

--- 1.107/myisam/mi_open.c	2007-04-02 10:41:31 +02:00
+++ 1.108/myisam/mi_open.c	2007-04-19 17:59:55 +02:00
@@ -196,7 +196,7 @@
     if (len != MI_BASE_INFO_SIZE)
     {
       DBUG_PRINT("warning",("saved_base_info_length: %d  base_info_length: %d",
-			    len,MI_BASE_INFO_SIZE))
+			    len,MI_BASE_INFO_SIZE));
     }
     disk_pos= (char*) 
       my_n_base_info_read((uchar*) disk_cache + base_pos, &share->base);

--- 1.178/sql/ha_myisam.cc	2007-03-28 10:22:20 +02:00
+++ 1.179/sql/ha_myisam.cc	2007-04-19 17:59:55 +02:00
@@ -673,7 +673,7 @@
   MYISAM_SHARE* share = file->s;
   const char *old_proc_info=thd->proc_info;
 
-  thd->proc_info="Checking table";
+  thd_proc_info(thd, "Checking table");
   myisamchk_init(&param);
   param.thd = thd;
   param.op_name =   "check";
@@ -747,7 +747,7 @@
     file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
   }
 
-  thd->proc_info=old_proc_info;
+  thd_proc_info(thd, old_proc_info);
   return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
 }
 
@@ -1029,22 +1029,22 @@
         char buf[40];
         /* TODO: respect myisam_repair_threads variable */
         my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
-        thd->proc_info=buf;
+        thd_proc_info(thd, buf);
         error = mi_repair_parallel(&param, file, fixed_name,
             param.testflag & T_QUICK);
-        thd->proc_info="Repair done"; // to reset proc_info, as
+        thd_proc_info(thd, "Repair done"); // to reset proc_info, as
                                       // it was pointing to local buffer
       }
       else
       {
-        thd->proc_info="Repair by sorting";
+        thd_proc_info(thd, "Repair by sorting");
         error = mi_repair_by_sort(&param, file, fixed_name,
             param.testflag & T_QUICK);
       }
     }
     else
     {
-      thd->proc_info="Repair with keycache";
+      thd_proc_info(thd, "Repair with keycache");
       param.testflag &= ~T_REP_BY_SORT;
       error=  mi_repair(&param, file, fixed_name,
 			param.testflag & T_QUICK);
@@ -1058,7 +1058,7 @@
 	(share->state.changed & STATE_NOT_SORTED_PAGES))
     {
       optimize_done=1;
-      thd->proc_info="Sorting index";
+      thd_proc_info(thd, "Sorting index");
       error=mi_sort_index(&param,file,fixed_name);
     }
     if (!statistics_done && (local_testflag & T_STATISTICS))
@@ -1066,14 +1066,14 @@
       if (share->state.changed & STATE_NOT_ANALYZED)
       {
 	optimize_done=1;
-	thd->proc_info="Analyzing";
+	thd_proc_info(thd, "Analyzing");
 	error = chk_key(&param, file);
       }
       else
 	local_testflag&= ~T_STATISTICS;		// Don't update statistics
     }
   }
-  thd->proc_info="Saving state";
+  thd_proc_info(thd, "Saving state");
   if (!error)
   {
     if ((share->state.changed & STATE_CHANGED) || mi_is_crashed(file))
@@ -1111,7 +1111,7 @@
     file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
     update_state_info(&param, file, 0);
   }
-  thd->proc_info=old_proc_info;
+  thd_proc_info(thd, old_proc_info);
   if (!thd->locked_tables)
     mi_lock_database(file,F_UNLCK);
   DBUG_RETURN(error ? HA_ADMIN_FAILED :
@@ -1336,7 +1336,7 @@
     THD *thd=current_thd;
     MI_CHECK param;
     const char *save_proc_info=thd->proc_info;
-    thd->proc_info="Creating index";
+    thd_proc_info(thd, "Creating index");
     myisamchk_init(&param);
     param.op_name= "recreating_index";
     param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
@@ -1361,7 +1361,7 @@
         thd->clear_error();
     }
     info(HA_STATUS_CONST);
-    thd->proc_info=save_proc_info;
+    thd_proc_info(thd, save_proc_info);
   }
   else
   {

--- 1.244/sql/item_cmpfunc.cc	2007-04-11 21:45:25 +02:00
+++ 1.245/sql/item_cmpfunc.cc	2007-04-19 17:59:55 +02:00
@@ -3365,7 +3365,7 @@
   }
   if (args[0]->is_null())
   {
-    DBUG_PRINT("info", ("null"))
+    DBUG_PRINT("info", ("null"));
     owner->was_null|= 1;
     DBUG_RETURN(0);
   }

--- 1.333/sql/item_func.cc	2007-04-08 20:46:37 +02:00
+++ 1.334/sql/item_func.cc	2007-04-19 17:59:55 +02:00
@@ -3215,7 +3215,7 @@
     Structure is now initialized.  Try to get the lock.
     Set up control struct to allow others to abort locks
   */
-  thd->proc_info="User lock";
+  thd_proc_info(thd, "User lock");
   thd->mysys_var->current_mutex= &LOCK_user_locks;
   thd->mysys_var->current_cond=  &ull->cond;
 
@@ -3240,7 +3240,7 @@
   }
   pthread_mutex_unlock(&LOCK_user_locks);
   pthread_mutex_lock(&thd->mysys_var->mutex);
-  thd->proc_info=0;
+  thd_proc_info(thd, 0);
   thd->mysys_var->current_mutex= 0;
   thd->mysys_var->current_cond=  0;
   pthread_mutex_unlock(&thd->mysys_var->mutex);
@@ -3321,7 +3321,7 @@
     Structure is now initialized.  Try to get the lock.
     Set up control struct to allow others to abort locks.
   */
-  thd->proc_info="User lock";
+  thd_proc_info(thd, "User lock");
   thd->mysys_var->current_mutex= &LOCK_user_locks;
   thd->mysys_var->current_cond=  &ull->cond;
 
@@ -3359,7 +3359,7 @@
   pthread_mutex_unlock(&LOCK_user_locks);
 
   pthread_mutex_lock(&thd->mysys_var->mutex);
-  thd->proc_info=0;
+  thd_proc_info(thd, 0);
   thd->mysys_var->current_mutex= 0;
   thd->mysys_var->current_cond=  0;
   pthread_mutex_unlock(&thd->mysys_var->mutex);

--- 1.146/sql/lex.h	2007-01-04 00:24:20 +01:00
+++ 1.147/sql/lex.h	2007-04-19 17:59:55 +02:00
@@ -32,10 +32,10 @@
 #define SYM(A) SYM_OR_NULL(A),0,0,&sym_group_common
 #define F_SYM(A) SYM_OR_NULL(A)
 
-#define CREATE_FUNC(A) (void *)(SYM_OR_NULL(A)), &sym_group_common
+#define CREATE_FUNC(A) (void (*)())(SYM_OR_NULL(A)), &sym_group_common
 
 #ifdef HAVE_SPATIAL
-#define CREATE_FUNC_GEOM(A) (void *)(SYM_OR_NULL(A)), &sym_group_geom
+#define CREATE_FUNC_GEOM(A) (void (*)())(SYM_OR_NULL(A)), &sym_group_geom
 #else
 #define CREATE_FUNC_GEOM(A) 0, &sym_group_geom
 #endif

--- 1.95/sql/lock.cc	2007-04-03 15:05:19 +02:00
+++ 1.96/sql/lock.cc	2007-04-19 17:59:55 +02:00
@@ -544,7 +544,7 @@
     goto end;
 
   /* A temporary table does not have locks. */
-  if (table->s->tmp_table == TMP_TABLE)
+  if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
     goto end;
 
   /* Get command lock or LOCK TABLES lock. Maybe empty for INSERT DELAYED. */
@@ -569,7 +569,7 @@
     if (haystack->placeholder())
       continue;
     table2= haystack->table;
-    if (table2->s->tmp_table == TMP_TABLE)
+    if (table2->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
       continue;
 
     /* All tables in list must be in lock. */
@@ -655,7 +655,7 @@
   *write_lock_used=0;
   for (i=tables=lock_count=0 ; i < count ; i++)
   {
-    if (table_ptr[i]->s->tmp_table != TMP_TABLE)
+    if (table_ptr[i]->s->tmp_table != NON_TRANSACTIONAL_TMP_TABLE)
     {
       tables+=table_ptr[i]->file->lock_count();
       lock_count++;
@@ -697,7 +697,7 @@
     TABLE *table;
     enum thr_lock_type lock_type;
 
-    if ((table=table_ptr[i])->s->tmp_table == TMP_TABLE)
+    if ((table=table_ptr[i])->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
       continue;
     lock_type= table->reginfo.lock_type;
     if (lock_type >= TL_WRITE_ALLOW_WRITE)

--- 1.230/sql/log_event.cc	2007-03-23 19:00:33 +01:00
+++ 1.231/sql/log_event.cc	2007-04-19 17:59:55 +02:00
@@ -4412,7 +4412,7 @@
   bzero((char*)&file, sizeof(file));
   fname_buf= strmov(proc_info, "Making temp file ");
   ext= slave_load_file_stem(fname_buf, file_id, server_id, ".info");
-  thd->proc_info= proc_info;
+  thd_proc_info(thd, proc_info);
   my_delete(fname_buf, MYF(0)); // old copy may exist already
   if ((fd= my_create(fname_buf, CREATE_MODE,
 		     O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
@@ -4466,7 +4466,7 @@
     end_io_cache(&file);
   if (fd >= 0)
     my_close(fd, MYF(0));
-  thd->proc_info= 0;
+  thd_proc_info(thd, 0);
   return error ? 1 : Log_event::exec_event(rli);
 }
 #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -4586,7 +4586,7 @@
 
   fname= strmov(proc_info, "Making temp file ");
   slave_load_file_stem(fname, file_id, server_id, ".data");
-  thd->proc_info= proc_info;
+  thd_proc_info(thd, proc_info);
   if (get_create_or_append())
   {
     my_delete(fname, MYF(0)); // old copy may exist already
@@ -4620,7 +4620,7 @@
 err:
   if (fd >= 0)
     my_close(fd, MYF(0));
-  thd->proc_info= 0;
+  thd_proc_info(thd, 0);
   DBUG_RETURN(error ? error : Log_event::exec_event(rli));
 }
 #endif

--- 1.441/sql/mysql_priv.h	2007-04-05 08:29:08 +02:00
+++ 1.442/sql/mysql_priv.h	2007-04-19 17:59:56 +02:00
@@ -195,6 +195,8 @@
 #define BDB_LOG_ALLOC_BLOCK_SIZE	1024
 #define WARN_ALLOC_BLOCK_SIZE		2048
 #define WARN_ALLOC_PREALLOC_SIZE	1024
+#define PROFILE_ALLOC_BLOCK_SIZE  2048
+#define PROFILE_ALLOC_PREALLOC_SIZE 1024
 
 /*
   The following parameters is to decide when to use an extra cache to
@@ -367,6 +369,8 @@
   fulltext functions when reading from it.
 */
 #define TMP_TABLE_FORCE_MYISAM          (ULL(1) << 32)
+#define OPTION_PROFILING                (ULL(1) << 33)
+
 
 
 /*
@@ -569,6 +573,8 @@
 #include "field.h"				/* Field definitions */
 #include "protocol.h"
 #include "sql_udf.h"
+#include "sql_profile.h"
+
 class user_var_entry;
 class Security_context;
 enum enum_var_type
@@ -1240,7 +1246,7 @@
   External variables
 */
 
-extern time_t server_start_time;
+extern time_t server_start_time, flush_status_time;
 extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
 	    mysql_real_data_home[], *opt_mysql_tmpdir, mysql_charsets_dir[],
             def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];

--- 1.602/sql/mysqld.cc	2007-03-31 00:15:14 +02:00
+++ 1.603/sql/mysqld.cc	2007-04-19 17:59:56 +02:00
@@ -435,7 +435,7 @@
 
 double log_10[32];			/* 10 potences */
 double log_01[32];
-time_t server_start_time;
+time_t server_start_time, flush_status_time;
 
 char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30];
 char *default_tz_name;
@@ -1667,7 +1667,7 @@
       ! abort_loop && !kill_cached_threads)
   {
     /* Don't kill the thread, just put it in cache for reuse */
-    DBUG_PRINT("info", ("Adding thread to cache"))
+    DBUG_PRINT("info", ("Adding thread to cache"));
     cached_thread_count++;
     while (!abort_loop && ! wake_thread && ! kill_cached_threads)
       (void) pthread_cond_wait(&COND_thread_cache, &LOCK_thread_count);
@@ -2633,7 +2633,7 @@
   tzset();			// Set tzname
 
   max_system_variables.pseudo_thread_id= (ulong)~0;
-  server_start_time= time((time_t*) 0);
+  server_start_time= flush_status_time= time((time_t*) 0);
   if (init_thread_environment())
     return 1;
   mysql_init_variables();
@@ -4771,6 +4771,7 @@
   OPT_TABLE_LOCK_WAIT_TIMEOUT,
   OPT_PORT_OPEN_TIMEOUT,
   OPT_MERGE,
+  OPT_PROFILING,
   OPT_INNODB_ROLLBACK_ON_TIMEOUT,
   OPT_SECURE_FILE_PRIV
 };
@@ -5344,6 +5345,12 @@
    "Maximum time in seconds to wait for the port to become free. "
    "(Default: no wait)", (gptr*) &mysqld_port_timeout,
    (gptr*) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef ENABLED_PROFILING
+  {"profiling_history_size", OPT_PROFILING, "Limit of query profiling memory",
+   (gptr*) &global_system_variables.profiling_history_size,
+   (gptr*) &max_system_variables.profiling_history_size,
+   0, GET_ULONG, REQUIRED_ARG, 15, 0, 100, 0, 0, 0},
+#endif
   {"relay-log", OPT_RELAY_LOG,
    "The location and name to use for relay logs.",
    (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0,
@@ -6370,6 +6377,7 @@
   {"Threads_created",	       (char*) &thread_created,		SHOW_LONG_CONST},
   {"Threads_running",          (char*) &thread_running,         SHOW_INT_CONST},
   {"Uptime",                   (char*) 0,                       SHOW_STARTTIME},
+  {"Uptime_since_flush_status",(char*) 0,                       SHOW_FLUSHTIME},
   {NullS, NullS, SHOW_LONG}
 };
 
@@ -7676,6 +7684,7 @@
 
   /* Reset the counters of all key caches (default and named). */
   process_key_caches(reset_key_cache_counters);
+  flush_status_time= time((time_t*) 0);
   pthread_mutex_unlock(&LOCK_status);
 
   /*

--- 1.296/sql/slave.cc	2007-03-20 15:27:45 +01:00
+++ 1.297/sql/slave.cc	2007-04-19 17:59:56 +02:00
@@ -1560,8 +1560,8 @@
 
   /* Create the table. We do not want to log the "create table" statement */
   save_options = thd->options;
-  thd->options &= ~(ulong) (OPTION_BIN_LOG);
-  thd->proc_info = "Creating table from master dump";
+  thd->options &= ~ (OPTION_BIN_LOG);
+  thd_proc_info(thd, "Creating table from master dump");
   // save old db in case we are creating in a different database
   save_db = thd->db;
   save_db_length= thd->db_length;
@@ -1575,7 +1575,7 @@
   if (thd->query_error)
     goto err;			// mysql_parse took care of the error send
 
-  thd->proc_info = "Opening master dump table";
+  thd_proc_info(thd, "Opening master dump table");
   tables.lock_type = TL_WRITE;
   if (!open_ltable(thd, &tables, TL_WRITE))
   {
@@ -1584,7 +1584,7 @@
   }
   
   file = tables.table->file;
-  thd->proc_info = "Reading master dump table data";
+  thd_proc_info(thd, "Reading master dump table data");
   /* Copy the data file */
   if (file->net_read_dump(net))
   {
@@ -1596,7 +1596,7 @@
 
   check_opt.init();
   check_opt.flags|= T_VERY_SILENT | T_CALC_CHECKSUM | T_QUICK;
-  thd->proc_info = "Rebuilding the index on master dump table";
+  thd_proc_info(thd, "Rebuilding the index on master dump table");
   /*
     We do not want repair() to spam us with messages
     just send them to the error log, and report the failure in case of
@@ -2926,9 +2926,9 @@
 #endif
 
   if (thd_type == SLAVE_THD_SQL)
-    thd->proc_info= "Waiting for the next event in relay log";
+    thd_proc_info(thd, "Waiting for the next event in relay log");
   else
-    thd->proc_info= "Waiting for master update";
+    thd_proc_info(thd, "Waiting for master update");
   thd->version=refresh_version;
   thd->set_time();
   DBUG_RETURN(0);
@@ -3488,7 +3488,7 @@
     goto err;
   }
 
-  thd->proc_info = "Connecting to master";
+  thd_proc_info(thd, "Connecting to master");
   // we can get killed during safe_connect
   if (!safe_connect(thd, mysql, mi))
   {
@@ -3515,7 +3515,7 @@
   // TODO: the assignment below should be under mutex (5.0)
   mi->slave_running= MYSQL_SLAVE_RUN_CONNECT;
   thd->slave_net = &mysql->net;
-  thd->proc_info = "Checking master version";
+  thd_proc_info(thd, "Checking master version");
   if (get_master_version_and_clock(mysql, mi))
     goto err;
 
@@ -3526,7 +3526,7 @@
       If fails, this is not fatal - we just print the error message and go
       on with life.
     */
-    thd->proc_info = "Registering slave on master";
+    thd_proc_info(thd, "Registering slave on master");
     if (register_slave_on_master(mysql) ||  update_slave_list(mysql, mi))
       goto err;
   }
@@ -3535,7 +3535,7 @@
   while (!io_slave_killed(thd,mi))
   {
     bool suppress_warnings= 0;
-    thd->proc_info = "Requesting binlog dump";
+    thd_proc_info(thd, "Requesting binlog dump");
     if (request_dump(mysql, mi, &suppress_warnings))
     {
       sql_print_error("Failed on request_dump()");
@@ -3547,7 +3547,7 @@
       }
 
       mi->slave_running= MYSQL_SLAVE_RUN_NOT_CONNECT;
-      thd->proc_info= "Waiting to reconnect after a failed binlog dump request";
+      thd_proc_info(thd, "Waiting to reconnect after a failed binlog dump request");
 #ifdef SIGNAL_WITH_VIO_CLOSE
       thd->clear_active_vio();
 #endif
@@ -3571,7 +3571,7 @@
 	goto err;
       }
 
-      thd->proc_info = "Reconnecting after a failed binlog dump request";
+      thd_proc_info(thd, "Reconnecting after a failed binlog dump request");
       if (!suppress_warnings)
 	sql_print_error("Slave I/O thread: failed dump request, \
 reconnecting to try again, log '%s' at postion %s", IO_RPL_LOG_NAME,
@@ -3598,7 +3598,7 @@
          important thing is to not confuse users by saying "reading" whereas
          we're in fact receiving nothing.
       */
-      thd->proc_info= "Waiting for master to send event";
+      thd_proc_info(thd, "Waiting for master to send event");
       event_len= read_event(mysql, mi, &suppress_warnings);
       if (io_slave_killed(thd,mi))
       {
@@ -3626,7 +3626,7 @@
 	  goto err;
 	}
         mi->slave_running= MYSQL_SLAVE_RUN_NOT_CONNECT;
-	thd->proc_info = "Waiting to reconnect after a failed master event read";
+	thd_proc_info(thd, "Waiting to reconnect after a failed master event read");
 #ifdef SIGNAL_WITH_VIO_CLOSE
         thd->clear_active_vio();
 #endif
@@ -3645,7 +3645,7 @@
 reconnect after a failed read");
 	  goto err;
 	}
-	thd->proc_info = "Reconnecting after a failed master event read";
+	thd_proc_info(thd, "Reconnecting after a failed master event read");
 	if (!suppress_warnings)
 	  sql_print_information("Slave I/O thread: Failed reading log event, \
 reconnecting to retry, log '%s' position %s", IO_RPL_LOG_NAME,
@@ -3662,7 +3662,7 @@
       } // if (event_len == packet_error)
 
       retry_count=0;			// ok event, reset retry counter
-      thd->proc_info = "Queueing master event to the relay log";
+      thd_proc_info(thd, "Queueing master event to the relay log");
       if (queue_event(mi,(const char*)mysql->net.read_pos + 1,
 		      event_len))
       {
@@ -3744,7 +3744,7 @@
     mi->mysql=0;
   }
   write_ignored_events_info_to_relay_log(thd, mi);
-  thd->proc_info = "Waiting for slave mutex on exit";
+  thd_proc_info(thd, "Waiting for slave mutex on exit");
   pthread_mutex_lock(&mi->run_lock);
 
   /* Forget the relay log's format */
@@ -3921,7 +3921,7 @@
 
   while (!sql_slave_killed(thd,rli))
   {
-    thd->proc_info = "Reading event from the relay log";
+    thd_proc_info(thd, "Reading event from the relay log");
     DBUG_ASSERT(rli->sql_thd == thd);
     THD_CHECK_SENTRY(thd);
     if (exec_relay_log_event(thd,rli))
@@ -3953,7 +3953,7 @@
   thd->query= 0; 
   thd->query_length= 0;
   VOID(pthread_mutex_unlock(&LOCK_thread_count));
-  thd->proc_info = "Waiting for slave mutex on exit";
+  thd_proc_info(thd, "Waiting for slave mutex on exit");
   pthread_mutex_lock(&rli->run_lock);
   /* We need data_lock, at least to wake up any waiting master_pos_wait() */
   pthread_mutex_lock(&rli->data_lock);

--- 1.365/sql/sql_base.cc	2007-04-03 15:05:20 +02:00
+++ 1.366/sql/sql_base.cc	2007-04-19 17:59:56 +02:00
@@ -1640,6 +1640,9 @@
   table->used_keys= table->s->keys_for_keyread;
   table->fulltext_searched= 0;
   table->file->ft_handler= 0;
+  /* Catch wrong handling of the auto_increment_field_not_null. */
+  DBUG_ASSERT(!table->auto_increment_field_not_null);
+  table->auto_increment_field_not_null= FALSE;
   if (table->timestamp_field)
     table->timestamp_field_type= table->timestamp_field->get_auto_set_type();
   table->pos_in_table_list= table_list;
@@ -2950,7 +2953,7 @@
   share= tmp_table->s;
   tmp_table->reginfo.lock_type=TL_WRITE;	 // Simulate locked
   share->tmp_table= (tmp_table->file->has_transactions() ? 
-                     TRANSACTIONAL_TMP_TABLE : TMP_TABLE);
+                     TRANSACTIONAL_TMP_TABLE : NON_TRANSACTIONAL_TMP_TABLE);
   share->table_cache_key= (char*) (tmp_table+1);
   share->db= share->table_cache_key;
   share->key_length= (uint) (strmov(((char*) (share->table_name=
@@ -4582,7 +4585,8 @@
 
           Item_int do not need fix_fields() because it is basic constant.
         */
-        it.replace(new Item_int("Not_used", (longlong) 1, 21));
+        it.replace(new Item_int("Not_used", (longlong) 1,
+                                MY_INT64_NUM_DECIMAL_DIGITS));
       }
       else if (insert_fields(thd, ((Item_field*) item)->context,
                              ((Item_field*) item)->db_name,
@@ -5271,6 +5275,11 @@
     values        values to fill with
     ignore_errors TRUE if we should ignore errors
 
+  NOTE
+    fill_record() may set table->auto_increment_field_not_null and a
+    caller should make sure that it is reset after their last call to this
+    function.
+
   RETURN
     FALSE   OK
     TRUE    error occured
@@ -5283,27 +5292,52 @@
   List_iterator_fast<Item> f(fields),v(values);
   Item *value, *fld;
   Item_field *field;
+  TABLE *table= 0;
   DBUG_ENTER("fill_record");
 
+  /*
+    Reset the table->auto_increment_field_not_null as it is valid for
+    only one row.
+  */
+  if (fields.elements)
+  {
+    /*
+      On INSERT or UPDATE fields are checked to be from the same table,
+      thus we safely can take table from the first field.
+    */
+    fld= (Item_field*)f++;
+    if (!(field= fld->filed_for_view_update()))
+    {
+      my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
+      goto err;
+    }
+    table= field->field->table;
+    table->auto_increment_field_not_null= FALSE;
+    f.rewind();
+  }
   while ((fld= f++))
   {
     if (!(field= fld->filed_for_view_update()))
     {
       my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
-      DBUG_RETURN(TRUE);
+      goto err;
     }
     value=v++;
     Field *rfield= field->field;
-    TABLE *table= rfield->table;
+    table= rfield->table;
     if (rfield == table->next_number_field)
       table->auto_increment_field_not_null= TRUE;
     if ((value->save_in_field(rfield, 0) < 0) && !ignore_errors)
     {
       my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
-      DBUG_RETURN(TRUE);
+      goto err;
     }
   }
   DBUG_RETURN(thd->net.report_error);
+err:
+  if (table)
+    table->auto_increment_field_not_null= FALSE;
+  DBUG_RETURN(TRUE);
 }
 
 
@@ -5352,6 +5386,11 @@
     values        list of fields
     ignore_errors TRUE if we should ignore errors
 
+  NOTE
+    fill_record() may set table->auto_increment_field_not_null and a
+    caller should make sure that it is reset after their last call to this
+    function.
+
   RETURN
     FALSE   OK
     TRUE    error occured
@@ -5362,19 +5401,38 @@
 {
   List_iterator_fast<Item> v(values);
   Item *value;
+  TABLE *table= 0;
   DBUG_ENTER("fill_record");
 
   Field *field;
+  /*
+    Reset the table->auto_increment_field_not_null as it is valid for
+    only one row.
+  */
+  if (*ptr)
+  {
+    /*
+      On INSERT or UPDATE fields are checked to be from the same table,
+      thus we safely can take table from the first field.
+    */
+    table= (*ptr)->table;
+    table->auto_increment_field_not_null= FALSE;
+  }
   while ((field = *ptr++))
   {
     value=v++;
-    TABLE *table= field->table;
+    table= field->table;
     if (field == table->next_number_field)
       table->auto_increment_field_not_null= TRUE;
     if (value->save_in_field(field, 0) == -1)
-      DBUG_RETURN(TRUE);
+      goto err;
   }
   DBUG_RETURN(thd->net.report_error);
+
+err:
+  if (table)
+    table->auto_increment_field_not_null= FALSE;
+  DBUG_RETURN(TRUE);
 }
 
 

--- 1.260/sql/sql_class.cc	2007-04-03 15:05:20 +02:00
+++ 1.261/sql/sql_class.cc	2007-04-19 17:59:56 +02:00
@@ -616,6 +616,18 @@
     clear_next_insert_id= 0;
     next_insert_id= 0;
   }
+  /*
+    Reset rand_used so that detection of calls to rand() will save random 
+    seeds if needed by the slave.
+
+    Do not reset rand_used if inside a stored function or trigger because 
+    only the call to these operations is logged. Thus only the calling 
+    statement needs to detect rand() calls made by its substatements. These
+    substatements must not set rand_used to 0 because it would remove the
+    detection of rand() by the calling statement. 
+  */
+  if (!in_sub_stmt)
+    rand_used= 0;
   /* Free Items that were created during this execution */
   free_items();
   /* Reset where. */

--- 1.318/sql/sql_class.h	2007-04-03 15:05:20 +02:00
+++ 1.319/sql/sql_class.h	2007-04-19 17:59:56 +02:00
@@ -356,13 +356,25 @@
   inline uint32 get_open_count() { return open_count; }
 };
 
-
+/*
+  The COPY_INFO structure is used by INSERT/REPLACE code.
+  The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY
+  UPDATE code:
+    If a row is inserted then the copied variable is incremented.
+    If a row is updated by the INSERT ... ON DUPLICATE KEY UPDATE and the
+      new data differs from the old one then the copied and the updated
+      variables are incremented.
+    The touched variable is incremented if a row was touched by the update part
+      of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row
+      was actually changed or not.
+*/
 typedef struct st_copy_info {
-  ha_rows records;
-  ha_rows deleted;
-  ha_rows updated;
-  ha_rows copied;
+  ha_rows records; /* Number of processed records */
+  ha_rows deleted; /* Number of deleted records */
+  ha_rows updated; /* Number of updated records */
+  ha_rows copied;  /* Number of copied records */
   ha_rows error_count;
+  ha_rows touched; /* Number of touched records */
   enum enum_duplicates handle_duplicates;
   int escape_char, last_errno;
   bool ignore;

--- 1.192/sql/sql_delete.cc	2007-04-03 15:05:20 +02:00
+++ 1.193/sql/sql_delete.cc	2007-04-19 17:59:56 +02:00
@@ -60,6 +60,27 @@
   if (mysql_prepare_delete(thd, table_list, &conds))
     DBUG_RETURN(TRUE);
 
+  /* check ORDER BY even if it can be ignored */
+  if (order && order->elements)
+  {
+    TABLE_LIST   tables;
+    List<Item>   fields;
+    List<Item>   all_fields;
+
+    bzero((char*) &tables,sizeof(tables));
+    tables.table = table;
+    tables.alias = table_list->alias;
+
+      if (select_lex->setup_ref_array(thd, order->elements) ||
+	  setup_order(thd, select_lex->ref_pointer_array, &tables,
+                    fields, all_fields, (ORDER*) order->first))
+    {
+      delete select;
+      free_underlaid_joins(thd, &thd->lex->select_lex);
+      DBUG_RETURN(TRUE);
+    }
+  }
+
   const_cond= (!conds || conds->const_item());
   safe_update=test(thd->options & OPTION_SAFE_UPDATES);
   if (safe_update && const_cond)
@@ -148,23 +169,7 @@
   {
     uint         length= 0;
     SORT_FIELD  *sortorder;
-    TABLE_LIST   tables;
-    List<Item>   fields;
-    List<Item>   all_fields;
     ha_rows examined_rows;
-
-    bzero((char*) &tables,sizeof(tables));
-    tables.table = table;
-    tables.alias = table_list->alias;
-
-      if (select_lex->setup_ref_array(thd, order->elements) ||
-	  setup_order(thd, select_lex->ref_pointer_array, &tables,
-                    fields, all_fields, (ORDER*) order->first))
-    {
-      delete select;
-      free_underlaid_joins(thd, &thd->lex->select_lex);
-      DBUG_RETURN(TRUE);
-    }
     
     if ((!select || table->quick_keys.is_clear_all()) && limit !=
HA_POS_ERROR)
       usable_index= get_index_for_order(table, (ORDER*)(order->first), limit);
@@ -212,7 +217,19 @@
   thd_proc_info(thd, "updating");
 
   if (table->triggers)
+  {
     table->triggers->mark_fields_used(thd, TRG_EVENT_DELETE);
+    if (table->triggers->has_triggers(TRG_EVENT_DELETE,
+                                      TRG_ACTION_AFTER))
+    {
+      /*
+	The table has AFTER DELETE triggers that might access to subject table
+	and therefore might need delete to be done immediately. So we turn-off
+	the batching.
+      */
+      (void) table->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+    }
+  }
 
   while (!(error=info.read_record(&info)) && !thd->killed &&
 	 !thd->net.report_error)
@@ -535,7 +552,19 @@
       else
 	normal_tables= 1;
       if (tbl->triggers)
+      {
         tbl->triggers->mark_fields_used(thd, TRG_EVENT_DELETE);
+	if (tbl->triggers->has_triggers(TRG_EVENT_DELETE,
+                                      TRG_ACTION_AFTER))
+	{
+	  /*
+	    The table has AFTER DELETE triggers that might access to subject 
+	    table and therefore might need delete to be done immediately. 
+	    So we turn-off the batching.
+	  */
+	  (void) tbl->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+	}
+      }
     }
     else if ((tab->type != JT_SYSTEM && tab->type != JT_CONST) &&
              walk == delete_tables)

--- 1.215/sql/sql_insert.cc	2007-04-03 15:05:20 +02:00
+++ 1.216/sql/sql_insert.cc	2007-04-19 17:59:56 +02:00
@@ -330,6 +330,51 @@
 
 
 /*
+  Prepare triggers  for INSERT-like statement.
+
+  SYNOPSIS
+    prepare_triggers_for_insert_stmt()
+      thd     The current thread
+      table   Table to which insert will happen
+      duplic  Type of duplicate handling for insert which will happen
+
+  NOTE
+    Prepare triggers for INSERT-like statement by marking fields
+    used by triggers and inform handlers that batching of UPDATE/DELETE 
+    cannot be done if there are BEFORE UPDATE/DELETE triggers.
+*/
+
+void prepare_triggers_for_insert_stmt(THD *thd, TABLE *table,
+                                      enum_duplicates duplic)
+{
+  if (table->triggers)
+  {
+    if (table->triggers->has_triggers(TRG_EVENT_DELETE,
+                                      TRG_ACTION_AFTER))
+    {
+      /*
+        The table has AFTER DELETE triggers that might access to 
+        subject table and therefore might need delete to be done 
+        immediately. So we turn-off the batching.
+      */ 
+      (void) table->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+    }
+    if (table->triggers->has_triggers(TRG_EVENT_UPDATE,
+                                      TRG_ACTION_AFTER))
+    {
+      /*
+        The table has AFTER UPDATE triggers that might access to subject 
+        table and therefore might need update to be done immediately. 
+        So we turn-off the batching.
+      */ 
+      (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+    }
+    mark_fields_used_by_triggers_for_insert_stmt(thd, table, duplic);
+  }
+}
+
+
+/*
   Mark fields used by triggers for INSERT-like statement.
 
   SYNOPSIS
@@ -473,10 +518,15 @@
   thd_proc_info(thd, "init");
   thd->used_tables=0;
   values= its++;
+  value_count= values->elements;
 
   if (mysql_prepare_insert(thd, table_list, table, fields, values,
 			   update_fields, update_values, duplic, &unused_conds,
-                           FALSE))
+                           FALSE,
+                           (fields.elements || !value_count),
+                           !ignore && (thd->variables.sql_mode &
+                                       (MODE_STRICT_TRANS_TABLES |
+                                        MODE_STRICT_ALL_TABLES))))
     goto abort;
 
   /* mysql_prepare_insert set table_list->table if it was not set */
@@ -502,7 +552,6 @@
   table_list->next_local= 0;
   context->resolve_in_table_list_only(table_list);
 
-  value_count= values->elements;
   while ((values= its++))
   {
     counter++;
@@ -522,7 +571,7 @@
   /*
     Fill in the given fields and dump it to the table file
   */
-  info.records= info.deleted= info.copied= info.updated= 0;
+  info.records= info.deleted= info.copied= info.updated= info.touched= 0;
   info.ignore= ignore;
   info.handle_duplicates=duplic;
   info.update_fields= &update_fields;
@@ -581,19 +630,11 @@
     table->file->start_bulk_insert(values_list.elements);
 
   thd->no_trans_update= 0;
-  thd->abort_on_warning= (!ignore &&
-                          (thd->variables.sql_mode &
-                           (MODE_STRICT_TRANS_TABLES |
-                            MODE_STRICT_ALL_TABLES)));
-
-  if ((fields.elements || !value_count) &&
-      check_that_all_fields_are_given_values(thd, table, table_list))
-  {
-    /* thd->net.report_error is now set, which will abort the next loop */
-    error= 1;
-  }
+  thd->abort_on_warning= (!ignore && (thd->variables.sql_mode &
+                                       (MODE_STRICT_TRANS_TABLES |
+                                        MODE_STRICT_ALL_TABLES)));
 
-  mark_fields_used_by_triggers_for_insert_stmt(thd, table, duplic);
+  prepare_triggers_for_insert_stmt(thd, table, duplic);
 
   if (table_list->prepare_where(thd, 0, TRUE) ||
       table_list->prepare_check_option(thd))
@@ -761,14 +802,15 @@
   table->next_number_field=0;
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;
   thd->next_insert_id=0;			// Reset this if wrongly used
+  table->auto_increment_field_not_null= FALSE;
   if (duplic != DUP_ERROR || ignore)
     table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
   if (duplic == DUP_REPLACE &&
       (!table->triggers || !table->triggers->has_delete_triggers()))
     table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
 
-  /* Reset value of LAST_INSERT_ID if no rows where inserted */
-  if (!info.copied && thd->insert_id_used)
+  /* Reset value of LAST_INSERT_ID if no rows were inserted or touched */
+  if (!info.copied && !info.touched && thd->insert_id_used)
   {
     thd->insert_id(0);
     id=0;
@@ -963,6 +1005,10 @@
 			be taken from table_list->table)    
     where		Where clause (for insert ... select)
     select_insert	TRUE if INSERT ... SELECT statement
+    check_fields        TRUE if need to check that all INSERT fields are 
+                        given values.
+    abort_on_warning    whether to report if some INSERT field is not 
+                        assigned as an error (TRUE) or as a warning (FALSE).
 
   TODO (in far future)
     In cases of:
@@ -983,7 +1029,8 @@
                           TABLE *table, List<Item> &fields, List_item *values,
                           List<Item> &update_fields, List<Item>
&update_values,
                           enum_duplicates duplic,
-                          COND **where, bool select_insert)
+                          COND **where, bool select_insert,
+                          bool check_fields, bool abort_on_warning)
 {
   SELECT_LEX *select_lex= &thd->lex->select_lex;
   Name_resolution_context *context= &select_lex->context;
@@ -1046,10 +1093,22 @@
     table_list->next_local= 0;
     context->resolve_in_table_list_only(table_list);
 
-    if (!(res= check_insert_fields(thd, context->table_list, fields, *values,
-                                 !insert_into_view, &map) ||
-          setup_fields(thd, 0, *values, 0, 0, 0)) 
-        && duplic == DUP_UPDATE)
+    res= check_insert_fields(thd, context->table_list, fields, *values,
+                             !insert_into_view, &map) ||
+      setup_fields(thd, 0, *values, 0, 0, 0);
+
+    if (!res && check_fields)
+    {
+      bool saved_abort_on_warning= thd->abort_on_warning;
+      thd->abort_on_warning= abort_on_warning;
+      res= check_that_all_fields_are_given_values(thd, 
+                                                  table ? table : 
+                                                  context->table_list->table,
+                                                  context->table_list);
+      thd->abort_on_warning= saved_abort_on_warning;
+    }
+
+    if (!res && duplic == DUP_UPDATE)
     {
       select_lex->no_wrap_view_item= TRUE;
       res= check_update_fields(thd, context->table_list, update_fields, &map);
@@ -1221,21 +1280,23 @@
           }
           goto err;
         }
+
+        if (table->next_number_field)
+          table->file->adjust_next_insert_id_after_explicit_value(
+            table->next_number_field->val_int());
+        info->touched++;
+
         if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) ||
             compare_record(table, thd->query_id))
         {
           info->updated++;
-
-          if (table->next_number_field)
-            table->file->adjust_next_insert_id_after_explicit_value(
-              table->next_number_field->val_int());
-
           trg_error= (table->triggers &&
                       table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
                                                         TRG_ACTION_AFTER,
                                                         TRUE));
           info->copied++;
         }
+
         goto ok_or_after_trg_err;
       }
       else /* DUP_REPLACE */
@@ -2324,7 +2385,7 @@
                            lex->query_tables->table, lex->field_list, 0,
                            lex->update_list, lex->value_list,
                            lex->duplicates,
-                           &select_lex->where, TRUE))
+                           &select_lex->where, TRUE, FALSE, FALSE))
     DBUG_RETURN(TRUE);
 
   /*
@@ -2386,7 +2447,18 @@
                            !insert_into_view, &map) ||
        setup_fields(thd, 0, values, 0, 0, 0);
 
-  if (info.handle_duplicates == DUP_UPDATE)
+  if (!res && fields->elements)
+  {
+    bool saved_abort_on_warning= thd->abort_on_warning;
+    thd->abort_on_warning= !info.ignore && (thd->variables.sql_mode &
+                                            (MODE_STRICT_TRANS_TABLES |
+                                             MODE_STRICT_ALL_TABLES));
+    res= check_that_all_fields_are_given_values(thd, table_list->table, 
+                                                table_list);
+    thd->abort_on_warning= saved_abort_on_warning;
+  }
+
+  if (info.handle_duplicates == DUP_UPDATE && !res)
   {
     Name_resolution_context *context= &lex->select_lex.context;
     Name_resolution_context_state ctx_state;
@@ -2497,14 +2569,12 @@
                           (thd->variables.sql_mode &
                            (MODE_STRICT_TRANS_TABLES |
                             MODE_STRICT_ALL_TABLES)));
-  res= ((fields->elements &&
-         check_that_all_fields_are_given_values(thd, table, table_list)) ||
-        table_list->prepare_where(thd, 0, TRUE) ||
+  res= (table_list->prepare_where(thd, 0, TRUE) ||
         table_list->prepare_check_option(thd));
 
   if (!res)
-    mark_fields_used_by_triggers_for_insert_stmt(thd, table,
-                                                 info.handle_duplicates);
+    prepare_triggers_for_insert_stmt(thd, table,
+                                     info.handle_duplicates);
   DBUG_RETURN(res);
 }
 
@@ -2547,6 +2617,7 @@
   if (table)
   {
     table->next_number_field=0;
+    table->auto_increment_field_not_null= FALSE;
     table->file->reset();
   }
   thd->count_cuted_fields= CHECK_FIELD_IGNORE;

--- 1.598/sql/sql_parse.cc	2007-04-03 15:20:19 +02:00
+++ 1.599/sql/sql_parse.cc	2007-04-19 17:59:57 +02:00
@@ -5438,7 +5438,7 @@
 {
   uint found=0;
   ulong found_access=0;
-#ifndef EMBEDDED_LIBRARY
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
   TABLE_LIST *org_tables= tables;
 #endif
   TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();

--- 1.509/sql/sql_select.cc	2007-04-15 06:34:13 +02:00
+++ 1.510/sql/sql_select.cc	2007-04-19 17:59:57 +02:00
@@ -742,6 +742,7 @@
   if (thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS)
     thd->status_var.last_query_cost= 0.0;
 
+  thd_proc_info(thd, "optimizing");
   row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
 	      unit->select_limit_cnt);
   /* select_limit is used to decide if we are likely to scan the whole table */
@@ -857,7 +858,14 @@
         thd->fatal_error();
         error= res;
         DBUG_PRINT("error",("Error from opt_sum_query"));
-	DBUG_RETURN(1);
+        DBUG_RETURN(1);
+      }
+      if (res < 0)
+      {
+        DBUG_PRINT("info",("No matching min/max row"));
+        zero_result_cause= "No matching min/max row";
+        error=0;
+        DBUG_RETURN(0);
       }
       DBUG_PRINT("info",("Select tables optimized away"));
       zero_result_cause= "Select tables optimized away";
@@ -893,7 +901,7 @@
   sort_by_table= get_sort_by_table(order, group_list, select_lex->leaf_tables);
 
   /* Calculate how to do the join */
-  thd->proc_info= "statistics";
+  thd_proc_info(thd, "statistics");
   if (make_join_statistics(this, select_lex->leaf_tables, conds, &keyuse) ||
       thd->is_fatal_error)
   {
@@ -903,7 +911,7 @@
 
   /* Remove distinct if only const tables */
   select_distinct= select_distinct && (const_tables != tables);
-  thd->proc_info= "preparing";
+  thd_proc_info(thd, "preparing");
   if (result->initialize_tables(this))
   {
     DBUG_PRINT("error",("Error: initialize_tables() failed"));
@@ -1267,8 +1275,9 @@
         join_tab[const_tables].type != JT_REF_OR_NULL &&
         (order && simple_order || group_list && simple_group))
     {
-      if (add_ref_to_table_cond(thd,&join_tab[const_tables]))
+      if (add_ref_to_table_cond(thd,&join_tab[const_tables])) {
         DBUG_RETURN(1);
+      }
     }
     
     if (!(select_options & SELECT_BIG_RESULT) &&
@@ -1326,7 +1335,7 @@
   if (need_tmp)
   {
     DBUG_PRINT("info",("Creating tmp table"));
-    thd->proc_info="Creating tmp table";
+    thd_proc_info(thd, "Creating tmp table");
 
     init_items_ref_array();
 
@@ -1355,7 +1364,9 @@
 			   select_options,
                            tmp_rows_limit,
 			   (char *) "")))
+		{
       DBUG_RETURN(1);
+    }
 
     /*
       We don't have to store rows in temp table that doesn't match HAVING if:
@@ -1375,28 +1386,34 @@
     if (group_list && simple_group)
     {
       DBUG_PRINT("info",("Sorting for group"));
-      thd->proc_info="Sorting for group";
+      thd_proc_info(thd, "Sorting for group");
       if (create_sort_index(thd, this, group_list,
 			    HA_POS_ERROR, HA_POS_ERROR) ||
 	  alloc_group_fields(this, group_list) ||
           make_sum_func_list(all_fields, fields_list, 1) ||
           setup_sum_funcs(thd, sum_funcs))
-	DBUG_RETURN(1);
+      {
+        DBUG_RETURN(1);
+      }
       group_list=0;
     }
     else
     {
       if (make_sum_func_list(all_fields, fields_list, 0) ||
           setup_sum_funcs(thd, sum_funcs))
-	DBUG_RETURN(1);
+      {
+        DBUG_RETURN(1);
+      }
+
       if (!group_list && ! exec_tmp_table1->distinct && order
&& simple_order)
       {
-	DBUG_PRINT("info",("Sorting for order"));
-	thd->proc_info="Sorting for order";
-	if (create_sort_index(thd, this, order,
+        thd_proc_info(thd, "Sorting for order");
+        if (create_sort_index(thd, this, order,
                               HA_POS_ERROR, HA_POS_ERROR))
-	  DBUG_RETURN(1);
-	order=0;
+        {
+          DBUG_RETURN(1);
+        }
+        order=0;
       }
     }
     
@@ -1519,6 +1536,7 @@
   int      tmp_error;
   DBUG_ENTER("JOIN::exec");
 
+  thd_proc_info(thd, "executing");
   error= 0;
   if (procedure)
   {
@@ -1658,7 +1676,7 @@
     curr_tmp_table= exec_tmp_table1;
 
     /* Copy data to the temporary table */
-    thd->proc_info= "Copying to tmp table";
+    thd_proc_info(thd, "Copying to tmp table");
     DBUG_PRINT("info", ("%s", thd->proc_info));
     if ((tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0)))
     {
@@ -1781,7 +1799,7 @@
       }
       if (curr_join->group_list)
       {
-	thd->proc_info= "Creating sort index";
+	thd_proc_info(thd, "Creating sort index");
 	if (curr_join->join_tab == join_tab && save_join_tab())
 	{
 	  DBUG_VOID_RETURN;
@@ -1795,7 +1813,7 @@
         sortorder= curr_join->sortorder;
       }
       
-      thd->proc_info="Copying to group table";
+      thd_proc_info(thd, "Copying to group table");
       DBUG_PRINT("info", ("%s", thd->proc_info));
       tmp_error= -1;
       if (curr_join != this)
@@ -1851,7 +1869,7 @@
     curr_join->join_free();			/* Free quick selects */
     if (curr_join->select_distinct && ! curr_join->group_list)
     {
-      thd->proc_info="Removing duplicates";
+      thd_proc_info(thd, "Removing duplicates");
       if (curr_join->tmp_having)
 	curr_join->tmp_having->update_used_tables();
       if (remove_duplicates(curr_join, curr_tmp_table,
@@ -1912,7 +1930,7 @@
   if (curr_join->group_list || curr_join->order)
   {
     DBUG_PRINT("info",("Sorting for send_fields"));
-    thd->proc_info="Sorting result";
+    thd_proc_info(thd, "Sorting result");
     /* If we have already done the group, add HAVING to sorted table */
     if (curr_join->tmp_having && ! curr_join->group_list && 
 	! curr_join->sort_and_group)
@@ -2036,7 +2054,7 @@
   }
   else
   {
-    thd->proc_info="Sending data";
+    thd_proc_info(thd, "Sending data");
     DBUG_PRINT("info", ("%s", thd->proc_info));
     result->send_fields((procedure ? curr_join->procedure_fields_list :
                          *curr_fields_list),
@@ -2184,7 +2202,7 @@
   {
     if (!(join= new JOIN(thd, fields, select_options, result)))
 	DBUG_RETURN(TRUE);
-    thd->proc_info="init";
+    thd_proc_info(thd, "init");
     thd->used_tables=0;                         // Updated by setup_fields
     if (err= join->prepare(rref_pointer_array, tables, wild_num,
                            conds, og_num, order, group, having, proc_param,
@@ -2229,8 +2247,9 @@
 err:
   if (free_join)
   {
-    thd->proc_info="end";
+    thd_proc_info(thd, "end");
     err|= select_lex->cleanup();
+    thd_proc_info(thd, "end");
     DBUG_RETURN(err || thd->net.report_error);
   }
   DBUG_RETURN(join->error);
@@ -10001,7 +10020,7 @@
   DBUG_PRINT("enter",("table: %s",entry->alias));
 
   save_proc_info=thd->proc_info;
-  thd->proc_info="removing tmp table";
+  thd_proc_info(thd, "removing tmp table");
 
   if (entry->file)
   {
@@ -10029,7 +10048,7 @@
     bitmap_clear_bit(&temp_pool, entry->temp_pool_slot);
 
   free_root(&own_root, MYF(0)); /* the table is allocated in its own root */
-  thd->proc_info=save_proc_info;
+  thd_proc_info(thd, save_proc_info);
 
   DBUG_VOID_RETURN;
 }
@@ -10059,7 +10078,7 @@
     DBUG_RETURN(1);				// End of memory
 
   save_proc_info=thd->proc_info;
-  thd->proc_info="converting HEAP to MyISAM";
+  thd_proc_info(thd, "converting HEAP to MyISAM");
 
   if (create_myisam_tmp_table(&new_table,param,
 			      thd->lex->select_lex.options | thd->options))
@@ -10112,8 +10131,8 @@
   table->s= &table->share_not_to_be_used;
   table->file->change_table_ptr(table);
   if (save_proc_info)
-    thd->proc_info= (!strcmp(save_proc_info,"Copying to tmp table") ?
-                     "Copying to tmp table on disk" : save_proc_info);
+    thd_proc_info(thd, (!strcmp(save_proc_info,"Copying to tmp table") ?
+                  "Copying to tmp table on disk" : save_proc_info));
   DBUG_RETURN(0);
 
  err:
@@ -10125,7 +10144,7 @@
   new_table.file->delete_table(new_table.s->table_name);
   delete new_table.file;
  err2:
-  thd->proc_info=save_proc_info;
+  thd_proc_info(thd, save_proc_info);
   DBUG_RETURN(1);
 }
 

--- 1.345/sql/sql_show.cc	2007-03-27 17:34:13 +02:00
+++ 1.346/sql/sql_show.cc	2007-04-19 17:59:57 +02:00
@@ -44,7 +44,7 @@
 append_algorithm(TABLE_LIST *table, String *buff);
 static int
 view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
-static bool schema_table_store_record(THD *thd, TABLE *table);
+bool schema_table_store_record(THD *thd, TABLE *table);
 
 
 /***************************************************************************
@@ -1354,7 +1354,7 @@
 
 #if !defined(DONT_USE_THR_ALARM) && ! defined(SCO)
         if (pthread_kill(tmp->real_id,0))
-          tmp->proc_info="*** DEAD ***";        // This shouldn't happen
+          thd_proc_info(tmp, "*** DEAD ***");        // This shouldn't happen
 #endif
 #ifdef EXTRA_DEBUG
         thd_info->start_time= tmp->time_after_lock;
@@ -1497,6 +1497,10 @@
           nr= (long) (thd->query_start() - server_start_time);
           end= int10_to_str(nr, buff, 10);
           break;
+        case SHOW_FLUSHTIME:
+          nr= (long) (thd->query_start() - flush_status_time);
+          end= int10_to_str(nr, buff, 10);
+          break;
         case SHOW_QUESTION:
           end= int10_to_str((long) thd->query_id, buff, 10);
           break;
@@ -1848,7 +1852,7 @@
     1	                  error
 */
 
-static bool schema_table_store_record(THD *thd, TABLE *table)
+bool schema_table_store_record(THD *thd, TABLE *table)
 {
   int error;
   if ((error= table->file->write_row(table->record[0])))
@@ -4339,6 +4343,8 @@
     get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
   {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
    fill_open_tables, make_old_format, 0, -1, -1, 1},
+  {"PROFILING", query_profile_statistics_info, create_schema_table,
+    fill_query_profile_statistics_info, NULL, NULL, -1, -1, false},
   {"ROUTINES", proc_fields_info, create_schema_table, 
     fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
   {"SCHEMATA", schema_fields_info, create_schema_table,

--- 1.340/sql/sql_table.cc	2007-04-10 12:02:02 +02:00
+++ 1.341/sql/sql_table.cc	2007-04-19 17:59:58 +02:00
@@ -1770,7 +1770,7 @@
     }
   }
 
-  thd->proc_info="creating table";
+  thd_proc_info(thd, "creating table");
   create_info->table_existed= 0;		// Mark that table is created
 
   if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
@@ -1801,7 +1801,7 @@
 
 end:
   VOID(pthread_mutex_unlock(&LOCK_open));
-  thd->proc_info="After create";
+  thd_proc_info(thd, "After create");
   DBUG_RETURN(error);
 
 warn:
@@ -2931,7 +2931,7 @@
     ALTER TABLE
   */
 
-  thd->proc_info="discard_or_import_tablespace";
+  thd_proc_info(thd, "discard_or_import_tablespace");
 
   discard= test(tablespace_op == DISCARD_TABLESPACE);
 
@@ -2948,7 +2948,7 @@
 
   error=table->file->discard_or_import_tablespace(discard);
 
-  thd->proc_info="end";
+  thd_proc_info(thd, "end");
 
   if (error)
     goto err;
@@ -3065,7 +3065,7 @@
   frm_type_enum frm_type;
   DBUG_ENTER("mysql_alter_table");
 
-  thd->proc_info="init";
+  thd_proc_info(thd, "init");
   table_name=table_list->table_name;
   alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
 
@@ -3202,7 +3202,7 @@
     DBUG_RETURN(TRUE);
   }
   
-  thd->proc_info="setup";
+  thd_proc_info(thd, "setup");
   if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) &&
       !table->s->tmp_table) // no need to touch frm
   {
@@ -3253,7 +3253,7 @@
 
     if (!error && (new_name != table_name || new_db != db))
     {
-      thd->proc_info="rename";
+      thd_proc_info(thd, "rename");
       /* Then do a 'simple' rename of the table */
       if (!access(new_name_buff,F_OK))
       {
@@ -3718,7 +3718,7 @@
   /* We don't want update TIMESTAMP fields during ALTER TABLE. */
   thd->count_cuted_fields= CHECK_FIELD_WARN;	// calc cuted fields
   thd->cuted_fields=0L;
-  thd->proc_info="copy to tmp table";
+  thd_proc_info(thd, "copy to tmp table");
   next_insert_id=thd->next_insert_id;		// Remember for logging
   copied=deleted=0;
   if (new_table && !new_table->s->is_view)
@@ -3802,7 +3802,7 @@
     from the cache, free all locks, close the old table and remove it.
   */
 
-  thd->proc_info="rename result table";
+  thd_proc_info(thd, "rename result table");
   my_snprintf(old_name, sizeof(old_name), "%s2-%lx-%lx", tmp_file_prefix,
 	      current_pid, thd->thread_id);
   if (lower_case_table_names)
@@ -3913,7 +3913,7 @@
     broadcast_refresh();
     goto err;
   }
-  thd->proc_info="end";
+  thd_proc_info(thd, "end");
   if (mysql_bin_log.is_open())
   {
     thd->clear_error();

--- 1.213/sql/sql_update.cc	2007-04-03 15:05:22 +02:00
+++ 1.214/sql/sql_update.cc	2007-04-19 17:59:58 +02:00
@@ -436,7 +436,19 @@
                                 MODE_STRICT_ALL_TABLES)));
 
   if (table->triggers)
+  {
     table->triggers->mark_fields_used(thd, TRG_EVENT_UPDATE);
+    if (table->triggers->has_triggers(TRG_EVENT_UPDATE,
+                                      TRG_ACTION_AFTER))
+    {
+      /*
+	The table has AFTER UPDATE triggers that might access to subject 
+	table and therefore might need update to be done immediately. 
+	So we turn-off the batching.
+      */ 
+      (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+    }
+  }
 
   /*
     We can use compare_record() to optimize away updates if
@@ -1001,6 +1013,20 @@
       table->no_keyread=1;
       table->used_keys.clear_all();
       table->pos_in_table_list= tl;
+      if (table->triggers)
+      {
+	table->triggers->mark_fields_used(thd, TRG_EVENT_UPDATE);
+	if (table->triggers->has_triggers(TRG_EVENT_UPDATE,
+					  TRG_ACTION_AFTER))
+	{
+	  /*
+	    The table has AFTER UPDATE triggers that might access to subject 
+	    table and therefore might need update to be done immediately. 
+	    So we turn-off the batching.
+	  */ 
+	  (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+	}
+      }
     }
   }
 

--- 1.514/sql/sql_yacc.yy	2007-04-02 10:50:17 +02:00
+++ 1.515/sql/sql_yacc.yy	2007-04-19 17:59:58 +02:00
@@ -500,6 +500,7 @@
 %token  BIT_SYM
 %token  BIT_XOR
 %token  BLOB_SYM
+%token  BLOCK_SYM
 %token  BOOLEAN_SYM
 %token  BOOL_SYM
 %token  BOTH
@@ -540,10 +541,12 @@
 %token  CONSISTENT_SYM
 %token  CONSTRAINT
 %token  CONTAINS_SYM
+%token  CONTEXT_SYM
 %token  CONTINUE_SYM
 %token  CONVERT_SYM
 %token  CONVERT_TZ_SYM
 %token  COUNT_SYM
+%token  CPU_SYM
 %token  CREATE
 %token  CROSS
 %token  CUBE_SYM
@@ -617,6 +620,7 @@
 %token  EXTRACT_SYM
 %token  FALSE_SYM
 %token  FAST_SYM
+%token  FAULTS_SYM
 %token  FETCH_SYM
 %token  FIELD_FUNC
 %token  FILE_SYM
@@ -686,6 +690,8 @@
 %token  INT_SYM
 %token  INVOKER_SYM
 %token  IN_SYM
+%token  IO_SYM
+%token  IPC_SYM
 %token  IS
 %token  ISOLATION
 %token  ISSUER_SYM
@@ -754,6 +760,7 @@
 %token  MEDIUMINT
 %token  MEDIUMTEXT
 %token  MEDIUM_SYM
+%token  MEMORY_SYM
 %token  MERGE_SYM
 %token  MICROSECOND_SYM
 %token  MIGRATE_SYM
@@ -812,6 +819,7 @@
 %token  OUTFILE
 %token  OUT_SYM
 %token  PACK_KEYS_SYM
+%token  PAGE_SYM
 %token  PARTIAL
 %token  PASSWORD
 %token  PARAM_MARKER
@@ -829,6 +837,8 @@
 %token  PROCEDURE
 %token  PROCESS
 %token  PROCESSLIST_SYM
+%token  PROFILE_SYM
+%token  PROFILES_SYM
 %token  PURGE
 %token  QUARTER_SYM
 %token  QUERY_SYM
@@ -899,6 +909,7 @@
 %token  SMALLINT
 %token  SNAPSHOT_SYM
 %token  SOUNDS_SYM
+%token  SOURCE_SYM
 %token  SPATIAL_SYM
 %token  SPECIFIC_SYM
 %token  SQLEXCEPTION_SYM
@@ -929,6 +940,8 @@
 %token  SUM_SYM
 %token  SUPER_SYM
 %token  SUSPEND_SYM
+%token  SWAPS_SYM
+%token  SWITCHES_SYM
 %token  SYSDATE
 %token  TABLES
 %token  TABLESPACE
@@ -6835,6 +6848,64 @@
 	/* empty */
 	| TABLE_SYM;
 
+opt_profile_defs:
+  /* empty */
+  | profile_defs
+
+profile_defs:
+  profile_def
+  | profile_defs ',' profile_def
+
+profile_def:
+  CPU_SYM
+    {
+      Lex->profile_options|= PROFILE_CPU;
+    }
+  | MEMORY_SYM
+    {
+      Lex->profile_options|= PROFILE_MEMORY;
+    }
+  | BLOCK_SYM IO_SYM
+    {
+      Lex->profile_options|= PROFILE_BLOCK_IO;
+    }
+  | CONTEXT_SYM SWITCHES_SYM
+    {
+      Lex->profile_options|= PROFILE_CONTEXT;
+    }
+  | PAGE_SYM FAULTS_SYM
+    {
+      Lex->profile_options|= PROFILE_PAGE_FAULTS;
+    }
+  | IPC_SYM
+    {
+      Lex->profile_options|= PROFILE_IPC;
+    }
+  | SWAPS_SYM
+    {
+      Lex->profile_options|= PROFILE_SWAPS;
+    }
+  | SOURCE_SYM
+    {
+      Lex->profile_options|= PROFILE_SOURCE;
+    }
+  | ALL
+    {
+      Lex->profile_options|= PROFILE_ALL;
+    }
+  ;
+
+opt_profile_args:
+  /* empty */
+    {
+      Lex->profile_query_id= 0;
+    }
+  | FOR_SYM QUERY_SYM NUM
+    {
+      Lex->profile_query_id= atoi($3.str);
+    }
+  ;
+
 /* Show things */
 
 show:	SHOW
@@ -6970,6 +7041,10 @@
           { Lex->sql_command = SQLCOM_SHOW_WARNS;}
         | ERRORS opt_limit_clause_init
           { Lex->sql_command = SQLCOM_SHOW_ERRORS;}
+        | PROFILES_SYM
+          { Lex->sql_command = SQLCOM_SHOW_PROFILES; }
+        | PROFILE_SYM opt_profile_defs opt_profile_args opt_limit_clause_init
+          { Lex->sql_command = SQLCOM_SHOW_PROFILE; }
         | opt_var_type STATUS_SYM wild_and_where
           {
             LEX *lex= Lex;
@@ -8063,6 +8138,7 @@
 	| BERKELEY_DB_SYM	{}
 	| BINLOG_SYM		{}
 	| BIT_SYM		{}
+	| BLOCK_SYM             {}
 	| BOOL_SYM		{}
 	| BOOLEAN_SYM		{}
 	| BTREE_SYM		{}
@@ -8080,6 +8156,8 @@
 	| CONCURRENT		{}
 	| CONNECTION_SYM	{}
 	| CONSISTENT_SYM	{}
+	| CONTEXT_SYM           {}
+	| CPU_SYM               {}
 	| CUBE_SYM		{}
 	| DATA_SYM		{}
 	| DATETIME		{}
@@ -8102,6 +8180,7 @@
         | EXPANSION_SYM         {}
 	| EXTENDED_SYM		{}
 	| FAST_SYM		{}
+	| FAULTS_SYM            {}
 	| FOUND_SYM		{}
 	| DISABLE_SYM		{}
 	| ENABLE_SYM		{}
@@ -8126,6 +8205,8 @@
 	| ISSUER_SYM		{}
 	| INNOBASE_SYM		{}
 	| INSERT_METHOD		{}
+	| IO_SYM                {}
+	| IPC_SYM               {}
 	| RELAY_THREAD		{}
 	| LAST_SYM		{}
 	| LEAVES                {}
@@ -8155,6 +8236,7 @@
 	| MAX_UPDATES_PER_HOUR	{}
 	| MAX_USER_CONNECTIONS_SYM {}
 	| MEDIUM_SYM		{}
+	| MEMORY_SYM            {}
 	| MERGE_SYM		{}
 	| MICROSECOND_SYM	{}
         | MIGRATE_SYM           {}
@@ -8181,6 +8263,7 @@
 	| ONE_SHOT_SYM		{}
         | ONE_SYM               {}
 	| PACK_KEYS_SYM		{}
+	| PAGE_SYM              {}
 	| PARTIAL		{}
 	| PASSWORD		{}
         | PHASE_SYM             {}
@@ -8190,6 +8273,8 @@
         | PRIVILEGES            {}
 	| PROCESS		{}
 	| PROCESSLIST_SYM	{}
+	| PROFILE_SYM           {}
+	| PROFILES_SYM          {}
 	| QUARTER_SYM		{}
 	| QUERY_SYM		{}
 	| QUICK			{}
@@ -8223,6 +8308,7 @@
 	| SHUTDOWN		{}
 	| SNAPSHOT_SYM		{}
 	| SOUNDS_SYM		{}
+	| SOURCE_SYM            {}
 	| SQL_CACHE_SYM		{}
 	| SQL_BUFFER_RESULT	{}
 	| SQL_NO_CACHE_SYM	{}
@@ -8234,6 +8320,8 @@
 	| SUBJECT_SYM		{}
 	| SUPER_SYM		{}
         | SUSPEND_SYM           {}
+        | SWAPS_SYM             {}
+	| SWITCHES_SYM          {}
         | TABLES                {}
 	| TABLESPACE		{}
 	| TEMPORARY		{}

--- 1.140/sql/table.h	2007-04-03 15:05:22 +02:00
+++ 1.141/sql/table.h	2007-04-19 17:59:58 +02:00
@@ -55,7 +55,8 @@
   ulong orig_want_privilege;
 } GRANT_INFO;
 
-enum tmp_table_type {NO_TMP_TABLE=0, TMP_TABLE=1, TRANSACTIONAL_TMP_TABLE=2,
+enum tmp_table_type {NO_TMP_TABLE=0,
+                     NON_TRANSACTIONAL_TMP_TABLE=1, TRANSACTIONAL_TMP_TABLE=2,
                      SYSTEM_TMP_TABLE=3};
 
 enum frm_type_enum
@@ -273,6 +274,11 @@
   my_bool no_cache;
   /* To signal that we should reset query_id for tables and cols */
   my_bool clear_query_id;
+  /*
+    To indicate that a non-null value of the auto_increment field
+    was provided by the user or retrieved from the current record.
+    Used only in the MODE_NO_AUTO_VALUE_ON_ZERO mode.
+  */
   my_bool auto_increment_field_not_null;
   my_bool insert_or_update;             /* Can be used by the handler */
   my_bool alias_name_used;		/* true if table_name is alias */

--- 1.172/support-files/mysql.spec.sh	2007-04-07 04:14:27 +02:00
+++ 1.173/support-files/mysql.spec.sh	2007-04-19 18:01:28 +02:00
@@ -481,6 +481,12 @@
 # Allow safe_mysqld to start mysqld and print a message before we exit
 sleep 2
 
+echo "Thank you for installing the MySQL Community Server! For Production
+systems, we recommend MySQL Enterprise, which contains enterprise-ready
+software, intelligent advisory services, and full production support with
+scheduled service packs and more.  Visit www.mysql.com/enterprise for more
+information." 
+
 %post ndb-storage
 mysql_clusterdir=/var/lib/mysql-cluster
 

--- 1.107/sql/sql_view.cc	2007-03-22 21:12:41 +01:00
+++ 1.108/sql/sql_view.cc	2007-04-19 17:59:58 +02:00
@@ -592,7 +592,7 @@
   DBUG_RETURN(0);
 
 err:
-  thd->proc_info= "end";
+  thd_proc_info(thd, "end");
   lex->link_first_table_back(view, link_to_local);
   unit->cleanup();
   DBUG_RETURN(res || thd->net.report_error);

--- 1.84/sql/ha_archive.cc	2007-03-30 10:00:20 +02:00
+++ 1.85/sql/ha_archive.cc	2007-04-19 17:59:55 +02:00
@@ -1209,7 +1209,7 @@
   ha_rows count= share->rows_recorded;
   DBUG_ENTER("ha_archive::check");
 
-  thd->proc_info= "Checking table";
+  thd_proc_info(thd, "Checking table");
   /* Flush any waiting data */
   gzflush(share->archive_write, Z_SYNC_FLUSH);
 
@@ -1233,7 +1233,7 @@
 
   my_free((char*)buf, MYF(0));
 
-  thd->proc_info= old_proc_info;
+  thd_proc_info(thd, old_proc_info);
 
   if ((rc && rc != HA_ERR_END_OF_FILE) || count)  
   {

--- 1.123/mysql-test/r/information_schema.result	2007-04-03 19:26:17 +02:00
+++ 1.124/mysql-test/r/information_schema.result	2007-04-19 17:59:55 +02:00
@@ -688,7 +688,7 @@
 Warning	1356	View 'test.v2' references invalid table(s) or column(s) or function(s) or
definer/invoker of view lack rights to use them
 show create table v3;
 View	Create View
-v3	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3`
AS select `test`.`sub1`(1) AS `c`
+v3	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3`
AS select `sub1`(1) AS `c`
 Warnings:
 Warning	1356	View 'test.v3' references invalid table(s) or column(s) or function(s) or
definer/invoker of view lack rights to use them
 drop view v2;

--- 1.21/ndb/src/ndbapi/DictCache.cpp	2007-02-22 16:03:02 +01:00
+++ 1.22/ndb/src/ndbapi/DictCache.cpp	2007-04-19 17:59:55 +02:00
@@ -141,7 +141,7 @@
 }
 
 NdbTableImpl *
-GlobalDictCache::get(const char * name)
+GlobalDictCache::get(const char * name, int *error)
 {
   DBUG_ENTER("GlobalDictCache::get");
   DBUG_PRINT("enter", ("name: %s", name));
@@ -151,6 +151,11 @@
   versions = m_tableHash.getData(name, len);
   if(versions == 0){
     versions = new Vector<TableVersion>(2);
+    if (versions == NULL)
+    {
+      *error = -1;
+      DBUG_RETURN(0);
+    }
     m_tableHash.insertKey(name, len, 0, versions);
   }
 
@@ -180,7 +185,11 @@
   tmp.m_impl = 0;
   tmp.m_status = RETREIVING;
   tmp.m_refCount = 1; // The one retreiving it
-  versions->push_back(tmp);
+  if (versions->push_back(tmp))
+  {
+    *error = -1;
+    DBUG_RETURN(0);
+  }
   DBUG_RETURN(0);
 }
 

--- 1.310/sql/ha_ndbcluster.cc	2007-04-18 16:41:33 +02:00
+++ 1.311/sql/ha_ndbcluster.cc	2007-04-19 17:59:55 +02:00
@@ -5971,14 +5971,14 @@
 
   if (!is_autocommit)
   {
-    DBUG_PRINT("exit", ("Can't register table during transaction"))
+    DBUG_PRINT("exit", ("Can't register table during transaction"));
     DBUG_RETURN(FALSE);
   }
 
   if (ndb_get_commitcount(thd, m_dbname, m_tabname, &commit_count))
   {
     *engine_data= 0;
-    DBUG_PRINT("exit", ("Error, could not get commitcount"))
+    DBUG_PRINT("exit", ("Error, could not get commitcount"));
     DBUG_RETURN(FALSE);
   }
   *engine_data= commit_count;

--- 1.240/sql/sp_head.cc	2007-04-06 18:21:28 +02:00
+++ 1.241/sql/sp_head.cc	2007-04-19 17:59:56 +02:00
@@ -2408,9 +2408,9 @@
 
   m_lex->unit.cleanup();
 
-  thd->proc_info="closing tables";
+  thd_proc_info(thd, "closing tables");
   close_thread_tables(thd);
-  thd->proc_info= 0;
+  thd_proc_info(thd, 0);
 
   if (m_lex->query_tables_own_last)
   {

--- 1.197/sql/sql_prepare.cc	2007-03-16 09:47:51 +01:00
+++ 1.198/sql/sql_prepare.cc	2007-04-19 17:59:57 +02:00
@@ -2231,6 +2231,9 @@
   if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
     DBUG_VOID_RETURN;
 
+#ifdef ENABLED_PROFILING
+  thd->profiling.set_query_source(stmt->query, stmt->query_length);
+#endif
   DBUG_PRINT("exec_query", ("%s", stmt->query));
   DBUG_PRINT("info",("stmt: %p", stmt));
 
Thread
bk commit into 5.0-community tree (df:1.2464)Daniel Fischer19 Apr