List:Internals« Previous MessageNext Message »
From:Stewart Smith Date:April 14 2005 2:43pm
Subject:bk commit into 5.1 tree (stewart:1.1796)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart 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
  1.1796 05/04/14 22:43:12 stewart@stripped +56 -0
  manual merge
  
  5.1-ndb 5.1-wl2325

  sql/sql_insert.cc
    1.140 05/04/14 22:42:59 stewart@stripped +0 -0
    manual merge

  sql/log.cc
    1.161 05/04/14 22:42:59 stewart@stripped +0 -0
    manual merge

  sql/handler.cc
    1.161 05/04/14 22:42:59 stewart@stripped +0 -0
    manual merge

  sql/field.cc
    1.256 05/04/14 22:42:59 stewart@stripped +5 -2
    manual merge

  ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
    1.73 05/04/14 22:42:58 stewart@stripped +0 -7
    manual merge

  mysql-test/t/user_var.test
    1.27 05/04/14 22:42:58 stewart@stripped +1 -0
    manual merge

  mysql-test/t/ctype_ucs.test
    1.30 05/04/14 22:42:58 stewart@stripped +0 -0
    manual merge

  mysql-test/r/user_var.result
    1.34 05/04/14 22:42:58 stewart@stripped +0 -5
    manual merge

  mysql-test/r/mix_innodb_myisam_binlog.result
    1.27 05/04/14 22:42:58 stewart@stripped +0 -7
    manual merge

  mysql-test/r/ctype_ucs.result
    1.37 05/04/14 22:42:58 stewart@stripped +0 -1
    manual merge

  sql/sql_update.cc
    1.154 05/04/14 22:19:49 stewart@stripped +0 -0
    Auto merged

  sql/sql_udf.cc
    1.46 05/04/14 22:19:49 stewart@stripped +0 -0
    Auto merged

  sql/sql_table.cc
    1.239 05/04/14 22:19:49 stewart@stripped +0 -0
    Auto merged

  sql/sql_show.cc
    1.228 05/04/14 22:19:48 stewart@stripped +0 -0
    Auto merged

  sql/sql_select.cc
    1.312 05/04/14 22:19:47 stewart@stripped +0 -0
    Auto merged

  sql/sql_delete.cc
    1.145 05/04/14 22:19:46 stewart@stripped +0 -0
    Auto merged

  sql/sql_class.h
    1.232 05/04/14 22:19:46 stewart@stripped +0 -0
    Auto merged

  sql/sql_class.cc
    1.177 05/04/14 22:19:46 stewart@stripped +0 -0
    Auto merged

  sql/sql_acl.h
    1.36 05/04/14 22:19:45 stewart@stripped +0 -0
    Auto merged

  sql/sql_acl.cc
    1.137 05/04/14 22:19:45 stewart@stripped +0 -0
    Auto merged

  sql/sp.cc
    1.74 05/04/14 22:19:45 stewart@stripped +0 -0
    Auto merged

  sql/set_var.cc
    1.104 05/04/14 22:19:45 stewart@stripped +0 -0
    Auto merged

  sql/mysqld.cc
    1.448 05/04/14 22:19:44 stewart@stripped +0 -0
    Auto merged

  sql/mysql_priv.h
    1.290 05/04/14 22:19:43 stewart@stripped +0 -0
    Auto merged

  sql/item_sum.cc
    1.139 05/04/14 22:19:43 stewart@stripped +0 -0
    Auto merged

  sql/handler.h
    1.137 05/04/14 22:19:43 stewart@stripped +0 -0
    Auto merged

  sql/ha_ndbcluster.h
    1.88 05/04/14 22:19:42 stewart@stripped +0 -0
    Auto merged

  sql/ha_ndbcluster.cc
    1.205 05/04/14 22:19:42 stewart@stripped +0 -0
    Auto merged

  sql/field.h
    1.153 05/04/14 22:19:41 stewart@stripped +0 -0
    Auto merged

  sql/Makefile.am
    1.108 05/04/14 22:19:40 stewart@stripped +0 -1
    Auto merged

  scripts/mysql_fix_privilege_tables.sql
    1.18 05/04/14 22:19:40 stewart@stripped +0 -0
    Auto merged

  scripts/mysql_create_system_tables.sh
    1.21 05/04/14 22:19:40 stewart@stripped +0 -0
    Auto merged

  ndb/test/src/HugoTransactions.cpp
    1.26 05/04/14 22:19:40 stewart@stripped +0 -0
    Auto merged

  ndb/test/src/HugoOperations.cpp
    1.19 05/04/14 22:19:39 stewart@stripped +0 -0
    Auto merged

  ndb/test/include/HugoTransactions.hpp
    1.9 05/04/14 22:19:39 stewart@stripped +0 -0
    Auto merged

  ndb/src/ndbapi/NdbTransaction.cpp
    1.44 05/04/14 22:19:39 stewart@stripped +0 -1
    Auto merged

  ndb/src/ndbapi/NdbDictionaryImpl.cpp
    1.80 05/04/14 22:19:39 stewart@stripped +0 -0
    Auto merged

  ndb/src/ndbapi/Ndb.cpp
    1.55 05/04/14 22:19:38 stewart@stripped +0 -0
    Auto merged

  ndb/src/mgmsrv/MgmtSrvr.cpp
    1.75 05/04/14 22:19:38 stewart@stripped +0 -0
    Auto merged

  ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp
    1.15 05/04/14 22:19:37 stewart@stripped +0 -0
    Auto merged

  ndb/src/kernel/blocks/dbtup/Dbtup.hpp
    1.22 05/04/14 22:19:35 stewart@stripped +0 -0
    Auto merged

  ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
    1.26 05/04/14 22:19:34 stewart@stripped +0 -0
    Auto merged

  ndb/include/kernel/signaldata/TcCommit.hpp
    1.5 05/04/14 22:19:33 stewart@stripped +0 -2
    Auto merged

  mysql-test/t/mysqlbinlog2.test
    1.9 05/04/14 22:19:33 stewart@stripped +0 -0
    Auto merged

  mysql-test/t/mysqlbinlog.test
    1.20 05/04/14 22:19:33 stewart@stripped +0 -0
    Auto merged

  mysql-test/t/mix_innodb_myisam_binlog.test
    1.16 05/04/14 22:19:32 stewart@stripped +0 -0
    Auto merged

  mysql-test/r/show_check.result
    1.66 05/04/14 22:19:32 stewart@stripped +0 -0
    Auto merged

  mysql-test/r/ps_1general.result
    1.33 05/04/14 22:19:31 stewart@stripped +0 -0
    Auto merged

  mysql-test/r/insert_select.result
    1.31 05/04/14 22:19:31 stewart@stripped +0 -0
    Auto merged

  mysql-test/r/innodb.result
    1.107 05/04/14 22:19:31 stewart@stripped +0 -0
    Auto merged

  mysql-test/r/information_schema.result
    1.43 05/04/14 22:19:30 stewart@stripped +0 -0
    Auto merged

  mysql-test/r/drop.result
    1.27 05/04/14 22:19:30 stewart@stripped +0 -0
    Auto merged

  mysql-test/mysql-test-run.sh
    1.259 05/04/14 22:19:30 stewart@stripped +0 -0
    Auto merged

  client/Makefile.am
    1.47 05/04/14 22:19:30 stewart@stripped +0 -0
    Auto merged

  configure.in
    1.257 05/04/14 22:19:29 stewart@stripped +0 -0
    Auto merged

  BitKeeper/etc/logging_ok
    1.284 05/04/14 22:19:03 stewart@stripped +0 -0
    auto-union

# 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:	stewart
# Host:	kennedy.(none)
# Root:	/home/stewart/Documents/MySQL/5.1/wl2325/RESYNC

--- 1.46/client/Makefile.am	2005-03-22 05:24:54 +11:00
+++ 1.47/client/Makefile.am	2005-04-14 22:19:30 +10:00
@@ -23,7 +23,8 @@
 LDADD=				@CLIENT_EXTRA_LDFLAGS@ \
                                 $(top_builddir)/libmysql/libmysqlclient.la
 bin_PROGRAMS =			mysql mysqladmin mysqlcheck mysqlshow \
- mysqldump mysqlimport mysqltest mysqlbinlog mysqlmanagerc mysqlmanager-pwgen
+				mysqldump mysqlimport mysqltest mysqlbinlog \
+				mysqltestmanagerc mysqltestmanager-pwgen
 noinst_HEADERS =		sql_string.h completion_hash.h my_readline.h \
 				client_priv.h
 mysql_SOURCES =			mysql.cc readline.cc sql_string.cc completion_hash.cc
@@ -33,7 +34,8 @@
 mysqltest_SOURCES=		mysqltest.c $(top_srcdir)/mysys/my_getsystime.c
 mysqltest_LDADD =		$(top_builddir)/regex/libregex.a $(LDADD)
 mysqlbinlog_SOURCES =   mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c
-mysqlmanagerc_SOURCES =   mysqlmanagerc.c 
+mysqltestmanagerc_SOURCES =   mysqlmanagerc.c 
+mysqltestmanager_pwgen_SOURCES =   mysqlmanager-pwgen.c 
 sql_src=bitvector.h log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc
 strings_src=decimal.c
 

--- 1.256/configure.in	2005-04-08 21:30:48 +10:00
+++ 1.257/configure.in	2005-04-14 22:19:29 +10:00
@@ -19,6 +19,7 @@
 NDB_VERSION_MAJOR=5
 NDB_VERSION_MINOR=1
 NDB_VERSION_BUILD=0
+NDB_VERSION_STATUS="alpha"
 
 # 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
@@ -41,7 +42,6 @@
 sinclude(config/ac-macros/ha_example.m4)
 sinclude(config/ac-macros/ha_federated.m4)
 sinclude(config/ac-macros/ha_innodb.m4)
-sinclude(config/ac-macros/ha_isam.m4)
 sinclude(config/ac-macros/ha_ndbcluster.m4)
 sinclude(config/ac-macros/ha_tina.m4)
 sinclude(config/ac-macros/large_file.m4)
@@ -351,11 +351,30 @@
 
   if echo $CXX | grep gcc > /dev/null 2>&1
   then
-    if $CXX -v 2>&1 | grep 'version 3' > /dev/null 2>&1
-    then
-     # Statically link the language support function's found in libsupc++.a
-     LIBS="$LIBS -lsupc++"
-    fi
+    GCC_VERSION=`gcc -v 2>&1 | grep version | sed -e 's/[[^0-9. ]]//g; s/^ *//g;
s/ .*//g'`
+    case $SYSTEM_TYPE in
+      *freebsd*)
+        # The libsupc++ library on freebsd with gcc 3.4.2 is dependent on 
+        # libstdc++, disable it  since other solution works fine
+        GCC_VERSION="NOSUPCPP_$GCC_VERSION"
+      ;;
+      *) 
+      ;;
+    esac
+    echo "Using gcc version '$GCC_VERSION'"
+    case "$GCC_VERSION" in
+      3.4.*|3.5.*)
+        # Statically link the language support function's found in libsupc++.a
+        LIBS="$LIBS -lsupc++"
+	echo "Using -libsupc++ for static linking with gcc"
+      ;;
+      *)
+        # Using -lsupc++ doesn't work in gcc 3.3 on SuSE 9.2
+        # (causes link failures when linking things staticly)
+        CXXFLAGS="$CXXFLAGS -DUSE_MYSYS_NEW -DDEFINE_CXA_PURE_VIRTUAL"
+	echo "Using MYSYS_NEW for static linking with gcc"
+      ;;
+    esac
   fi
 fi
 

--- 1.258/mysql-test/mysql-test-run.sh	2005-04-14 18:19:27 +10:00
+++ 1.259/mysql-test/mysql-test-run.sh	2005-04-14 22:19:30 +10:00
@@ -249,7 +249,6 @@
 MYSQL_TEST_SSL_OPTS=""
 USE_TIMER=""
 USE_EMBEDDED_SERVER=""
-RESULT_EXT=""
 TEST_MODE=""
 
 NDB_MGM_EXTRA_OPTS=
@@ -262,7 +261,6 @@
       USE_EMBEDDED_SERVER=1
       USE_MANAGER=0 NO_SLAVE=1
       USE_RUNNING_SERVER=0
-      RESULT_EXT=".es"
       TEST_MODE="$TEST_MODE embedded" ;;
     --purify)
       USE_PURIFY=1
@@ -422,7 +420,7 @@
       fi
       # >=2.1.2 requires the --tool option, some versions write to stdout, some to
stderr
       valgrind --help 2>&1 | grep "\-\-tool" > /dev/null &&
VALGRIND="$VALGRIND --tool=memcheck"
-      VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16"
+      VALGRIND="$VALGRIND --alignment=8 --leak-check=yes --num-callers=16
--suppressions=$CWD/valgrind.supp"
       EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb"
       EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
       SLEEP_TIME_AFTER_RESTART=10
@@ -586,9 +584,9 @@
  CLIENT_BINDIR="$BASEDIR/client"
  MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
  WAIT_PID="$BASEDIR/extra/mysql_waitpid"
- MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc"
- MYSQL_MANAGER="$BASEDIR/tools/mysqlmanager"
- MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen"
+ MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqltestmanagerc"
+ MYSQL_MANAGER="$BASEDIR/tools/mysqltestmanager"
+ MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqltestmanager-pwgen"
  MYSQL="$CLIENT_BINDIR/mysql"
  LANGUAGE="$BASEDIR/sql/share/english/"
  CHARSETSDIR="$BASEDIR/sql/share/charsets"
@@ -649,9 +647,9 @@
  MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog"
  MYSQLADMIN="$CLIENT_BINDIR/mysqladmin"
  WAIT_PID="$CLIENT_BINDIR/mysql_waitpid"
- MYSQL_MANAGER="$CLIENT_BINDIR/mysqlmanager"
- MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqlmanagerc"
- MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqlmanager-pwgen"
+ MYSQL_MANAGER="$CLIENT_BINDIR/mysqltestmanager"
+ MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqltestmanagerc"
+ MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqltestmanager-pwgen"
  MYSQL="$CLIENT_BINDIR/mysql"
  INSTALL_DB="./install_test_db --bin"
  MYSQL_FIX_SYSTEM_TABLES="$CLIENT_BINDIR/mysql_fix_privilege_tables"
@@ -773,13 +771,6 @@
   result_file=r/$1.result
   eval_file=r/$1.eval
 
-  # If we have an special externsion for result files we use it if we are recording
-  # or a result file with that extension exists.
-  if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ]
-  then
-    result_file="$result_file$RESULT_EXT"
-  fi
-
   if [ -f $eval_file ]
   then
     result_file=$eval_file
@@ -1201,7 +1192,7 @@
           --default-character-set=$CHARACTER_SET \
           --tmpdir=$MYSQL_TMP_DIR \
           --language=$LANGUAGE \
-          --innodb_data_file_path=ibdata1:50M \
+          --innodb_data_file_path=ibdata1:128M:autoextend \
 	  --open-files-limit=1024 \
 	   $MASTER_40_ARGS \
            $SMALL_SERVER \
@@ -1223,7 +1214,7 @@
           $USE_NDBCLUSTER \
           --tmpdir=$MYSQL_TMP_DIR \
           --language=$LANGUAGE \
-          --innodb_data_file_path=ibdata1:50M \
+          --innodb_data_file_path=ibdata1:128M:autoextend \
 	   $MASTER_40_ARGS \
            $SMALL_SERVER \
            $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT \
@@ -1551,9 +1542,6 @@
  result_file="r/$tname.result"
  echo $tname > $CURRENT_TEST
  SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0 \& \( $tname : federated \) = 0`
- if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then
-   result_file="$result_file$RESULT_EXT"
- fi
  if [ "$USE_MANAGER" = 1 ] ; then
   many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname :
rpl_chain_temp_table \) != 0 \)`
  fi
@@ -1611,33 +1599,8 @@
  # script soon anyway so it is not worth it spending the time
  if [ "x$USE_EMBEDDED_SERVER" = "x1" -a -z "$DO_TEST" ] ; then
    for t in \
-        "alter_table" \
-	"bdb-deadlock" \
-	"connect" \
-        "ctype_latin1_de" \
-        "ctype_ucs" \
-	"flush_block_commit" \
-	"grant2" \
-	"grant_cache" \
-	"grant" \
-	"init_connect" \
-	"init_file" \
-        "innodb" \
-	"innodb-deadlock" \
-	"innodb-lock" \
-	"mix_innodb_myisam_binlog" \
-	"mysqlbinlog2" \
-	"mysqlbinlog" \
-	"mysqldump" \
-	"mysql_protocols" \
-        "packet" \
-	"ps_1general" \
-	"rename" \
-	"show_check" \
-        "system_mysql_db_fix" \
-        "timezone2" \
-	"user_var" \
-	"variables"
+       "init_connect" \
+       "init_file"
    do
      if [ "$tname" = "$t" ] ; then
        skip_test $tname
@@ -1661,10 +1624,8 @@
        --result-file=*)
          result_file=`$ECHO "$EXTRA_MASTER_OPT" | $SED -e "s;--result-file=;;"`
          result_file="r/$result_file.result"
-         if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ;
then
-	   result_file="$result_file$RESULT_EXT"
-	 fi
-	 # Note that this must be set to space, not "" for test-reset to work
+         # Note that this must be set to space, not "" for test-reset to
+# work
 	 EXTRA_MASTER_OPT=" "
          ;;
      esac

--- 1.107/sql/Makefile.am	2005-04-08 22:24:18 +10:00
+++ 1.108/sql/Makefile.am	2005-04-14 22:19:40 +10:00
@@ -49,7 +49,7 @@
 			mysql_priv.h item_geofunc.h sql_bitmap.h \
 			procedure.h sql_class.h sql_lex.h sql_list.h \
 			sql_manager.h sql_map.h sql_string.h unireg.h \
-			field.h handler.h mysqld_suffix.h \
+			sql_error.h field.h handler.h mysqld_suffix.h \
 			ha_myisammrg.h\
 	                rpl_tblmap.h rpl_injector.h \
 			ha_heap.h ha_myisam.h ha_berkeley.h ha_innodb.h \

--- 1.255/sql/field.cc	2005-04-13 00:36:04 +10:00
+++ 1.256/sql/field.cc	2005-04-14 22:42:59 +10:00
@@ -8141,6 +8141,7 @@
 		  const char *field_name,
 		  struct st_table *table)
 {
+  DBUG_ENTER("Field::make_field");
   uchar *bit_ptr;
   uchar bit_offset;
   LINT_INIT(bit_ptr);
@@ -8177,6 +8178,8 @@
     default: break;
   }
 
+  DBUG_PRINT("info",("pack_flag: %x, f_is_alpha(pack_flag): %d, f_is_packed(pack_flag):
%d",
+		     pack_flag, f_is_alpha(pack_flag), f_is_packed(pack_flag)));
   if (f_is_alpha(pack_flag))
   {
     if (!f_is_packed(pack_flag))
@@ -8184,16 +8187,21 @@
       if (field_type == MYSQL_TYPE_STRING ||
           field_type == FIELD_TYPE_DECIMAL ||   // 3.23 or 4.0 string
           field_type == MYSQL_TYPE_VAR_STRING)
-        return new Field_string(ptr,field_length,null_pos,null_bit,
-                                unireg_check, field_name, table,
-                                field_charset);
+      {
+        DBUG_RETURN(new Field_string(ptr,field_length,null_pos,null_bit,
+				     unireg_check, field_name, table,
+				     field_charset));
+      }
       if (field_type == MYSQL_TYPE_VARCHAR)
-        return new Field_varstring(ptr,field_length,
-                                   HA_VARCHAR_PACKLENGTH(field_length),
-                                   null_pos,null_bit,
-                                   unireg_check, field_name, table,
-                                   field_charset);
-      return 0;                                 // Error
+      {
+	DBUG_RETURN(new Field_varstring(ptr,field_length,
+					HA_VARCHAR_PACKLENGTH(field_length),
+					null_pos,null_bit,
+					unireg_check, field_name, table,
+					field_charset));
+      }
+      DBUG_PRINT("error",("pack_flag error for field_type: %d", field_type));
+      DBUG_RETURN(0);                                 // Error
     }
 
     uint pack_length=calc_pack_length((enum_field_types)
@@ -8202,117 +8210,137 @@
 
 #ifdef HAVE_SPATIAL
     if (f_is_geom(pack_flag))
-      return new Field_geom(ptr,null_pos,null_bit,
-			    unireg_check, field_name, table,
-			    pack_length, geom_type);
+    {
+      DBUG_RETURN(new Field_geom(ptr,null_pos,null_bit,
+				 unireg_check, field_name, table,
+				 pack_length, geom_type));
+    }
 #endif
     if (f_is_blob(pack_flag))
-      return new Field_blob(ptr,null_pos,null_bit,
-			    unireg_check, field_name, table,
-			    pack_length, field_charset);
+    {
+      DBUG_RETURN(new Field_blob(ptr,null_pos,null_bit,
+				 unireg_check, field_name, table,
+				 pack_length, field_charset));
+    }
     if (interval)
     {
       if (f_is_enum(pack_flag))
-	return new Field_enum(ptr,field_length,null_pos,null_bit,
-				  unireg_check, field_name, table,
-				  pack_length, interval, field_charset);
+      {
+	DBUG_RETURN(new Field_enum(ptr,field_length,null_pos,null_bit,
+				   unireg_check, field_name, table,
+				   pack_length, interval, field_charset));
+      }
       else
-	return new Field_set(ptr,field_length,null_pos,null_bit,
-			     unireg_check, field_name, table,
-			     pack_length, interval, field_charset);
+      {
+	DBUG_RETURN(new Field_set(ptr,field_length,null_pos,null_bit,
+				  unireg_check, field_name, table,
+				  pack_length, interval, field_charset));
+      }
     }
   }
 
   switch (field_type) {
   case FIELD_TYPE_DECIMAL:
-    return new Field_decimal(ptr,field_length,null_pos,null_bit,
-			     unireg_check, field_name, table,
-			     f_decimals(pack_flag),
-			     f_is_zerofill(pack_flag) != 0,
-			     f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_decimal(ptr,field_length,null_pos,null_bit,
+				  unireg_check, field_name, table,
+				  f_decimals(pack_flag),
+				  f_is_zerofill(pack_flag) != 0,
+				  f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_NEWDECIMAL:
-    return new Field_new_decimal(ptr,field_length,null_pos,null_bit,
-                                 unireg_check, field_name, table,
-                                 f_decimals(pack_flag),
-                                 f_is_zerofill(pack_flag) != 0,
-                                 f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_new_decimal(ptr,field_length,null_pos,null_bit,
+				      unireg_check, field_name, table,
+				      f_decimals(pack_flag),
+				      f_is_zerofill(pack_flag) != 0,
+				      f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_FLOAT:
-    return new Field_float(ptr,field_length,null_pos,null_bit,
-			   unireg_check, field_name, table,
-			   f_decimals(pack_flag),
-			   f_is_zerofill(pack_flag) != 0,
-			   f_is_dec(pack_flag)== 0);
+    DBUG_RETURN(new Field_float(ptr,field_length,null_pos,null_bit,
+				unireg_check, field_name, table,
+				f_decimals(pack_flag),
+				f_is_zerofill(pack_flag) != 0,
+				f_is_dec(pack_flag)== 0));
   case FIELD_TYPE_DOUBLE:
-    return new Field_double(ptr,field_length,null_pos,null_bit,
-			    unireg_check, field_name, table,
-			    f_decimals(pack_flag),
-			    f_is_zerofill(pack_flag) != 0,
-			    f_is_dec(pack_flag)== 0);
+    DBUG_RETURN(new Field_double(ptr,field_length,null_pos,null_bit,
+				 unireg_check, field_name, table,
+				 f_decimals(pack_flag),
+				 f_is_zerofill(pack_flag) != 0,
+				 f_is_dec(pack_flag)== 0));
   case FIELD_TYPE_TINY:
-    return new Field_tiny(ptr,field_length,null_pos,null_bit,
-			  unireg_check, field_name, table,
-			  f_is_zerofill(pack_flag) != 0,
-			  f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_tiny(ptr,field_length,null_pos,null_bit,
+			       unireg_check, field_name, table,
+			       f_is_zerofill(pack_flag) != 0,
+			       f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_SHORT:
-    return new Field_short(ptr,field_length,null_pos,null_bit,
-			   unireg_check, field_name, table,
-			   f_is_zerofill(pack_flag) != 0,
-			   f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_short(ptr,field_length,null_pos,null_bit,
+				unireg_check, field_name, table,
+				f_is_zerofill(pack_flag) != 0,
+				f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_INT24:
-    return new Field_medium(ptr,field_length,null_pos,null_bit,
-			    unireg_check, field_name, table,
-			    f_is_zerofill(pack_flag) != 0,
-			    f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_medium(ptr,field_length,null_pos,null_bit,
+				 unireg_check, field_name, table,
+				 f_is_zerofill(pack_flag) != 0,
+				 f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_LONG:
-    return new Field_long(ptr,field_length,null_pos,null_bit,
-			   unireg_check, field_name, table,
-			   f_is_zerofill(pack_flag) != 0,
-			   f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_long(ptr,field_length,null_pos,null_bit,
+			       unireg_check, field_name, table,
+			       f_is_zerofill(pack_flag) != 0,
+			       f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_LONGLONG:
-    return new Field_longlong(ptr,field_length,null_pos,null_bit,
-			      unireg_check, field_name, table,
-			      f_is_zerofill(pack_flag) != 0,
-			      f_is_dec(pack_flag) == 0);
+    DBUG_RETURN(new Field_longlong(ptr,field_length,null_pos,null_bit,
+				   unireg_check, field_name, table,
+				   f_is_zerofill(pack_flag) != 0,
+				   f_is_dec(pack_flag) == 0));
   case FIELD_TYPE_TIMESTAMP:
-    return new Field_timestamp(ptr,field_length, null_pos, null_bit,
-                               unireg_check, field_name, table,
-                               field_charset);
+    DBUG_RETURN(new Field_timestamp(ptr,field_length, null_pos, null_bit,
+				    unireg_check, field_name, table,
+				    field_charset));
   case FIELD_TYPE_YEAR:
-    return new Field_year(ptr,field_length,null_pos,null_bit,
-			  unireg_check, field_name, table);
+    DBUG_RETURN(new Field_year(ptr,field_length,null_pos,null_bit,
+			       unireg_check, field_name, table));
   case FIELD_TYPE_DATE:
-    return new Field_date(ptr,null_pos,null_bit,
-			  unireg_check, field_name, table, field_charset);
+    DBUG_RETURN(new Field_date(ptr,null_pos,null_bit,
+			       unireg_check, field_name, table, field_charset));
   case FIELD_TYPE_NEWDATE:
-    return new Field_newdate(ptr,null_pos,null_bit,
-			     unireg_check, field_name, table, field_charset);
+    DBUG_RETURN(new Field_newdate(ptr,null_pos,null_bit,
+				  unireg_check, field_name, table, field_charset));
   case FIELD_TYPE_TIME:
-    return new Field_time(ptr,null_pos,null_bit,
-			  unireg_check, field_name, table, field_charset);
+    DBUG_RETURN(new Field_time(ptr,null_pos,null_bit,
+			       unireg_check, field_name, table, field_charset));
   case FIELD_TYPE_DATETIME:
-    return new Field_datetime(ptr,null_pos,null_bit,
-			      unireg_check, field_name, table, field_charset);
+    DBUG_RETURN(new Field_datetime(ptr,null_pos,null_bit,
+				   unireg_check, field_name, table, field_charset));
   case FIELD_TYPE_NULL:
-    return new Field_null(ptr,field_length,unireg_check,field_name,table, field_charset);
+    DBUG_RETURN(new Field_null(ptr,field_length,
+			       unireg_check,field_name,table, field_charset));
   case FIELD_TYPE_BIT:
-    return f_bit_as_char(pack_flag) ?
+    DBUG_RETURN(f_bit_as_char(pack_flag) ?
            new Field_bit_as_char(ptr, field_length, null_pos, null_bit, bit_ptr,
                                  bit_offset, unireg_check, field_name, table) :
            new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr,
-                         bit_offset, unireg_check, field_name, table);
+                         bit_offset, unireg_check, field_name, table));
   default:					// Impossible (Wrong version)
+    DBUG_PRINT("error",("wrong field_type: %d", field_type));
     break;
   }
-  return 0;
+  DBUG_RETURN(0);
 }
 
 
 /* Create a field suitable for create of table */
 
-create_field::create_field(Field *old_field,Field *orig_field)
+TYPELIB *DUMMY_TYPELIB=(TYPELIB*)&DUMMY_TYPELIB;
+
+create_field::create_field(Field *old_field,Field *orig_field,int unlink_from_old_field)
 {
-  field=      old_field;
-  field_name=change=old_field->field_name;
+  if (unlink_from_old_field)
+  {
+    field= 0;
+    field_name=change=0;
+  }
+  else
+  {
+    field=    old_field;
+    field_name=change=old_field->field_name;
+  }
   length=     old_field->field_length;
   flags=      old_field->flags;
   unireg_check=old_field->unireg_check;
@@ -8365,7 +8393,12 @@
   }
 
   if (flags & (ENUM_FLAG | SET_FLAG))
-    interval= ((Field_enum*) old_field)->typelib;
+  {
+    if (unlink_from_old_field)
+      interval= DUMMY_TYPELIB;
+    else
+      interval= ((Field_enum*) old_field)->typelib;
+  }
   else
     interval=0;
   def=0;

--- 1.152/sql/field.h	2005-04-13 04:11:55 +10:00
+++ 1.153/sql/field.h	2005-04-14 22:19:41 +10:00
@@ -1354,7 +1354,7 @@
   uint8 row,col,sc_length,interval_id;	// For rea_create_table
   uint	offset,pack_flag;
   create_field() :after(0) {}
-  create_field(Field *field, Field *orig_field);
+  create_field(Field *field, Field *orig_field, int unlink_from_old_field=0);
   void create_length_to_internal_length(void);
 
   /* Init for a tmp table field. To be extended if need be. */

--- 1.160/sql/handler.cc	2005-04-13 01:22:02 +10:00
+++ 1.161/sql/handler.cc	2005-04-14 22:42:59 +10:00
@@ -25,6 +25,7 @@
 #include "ha_heap.h"
 #include "ha_myisam.h"
 #include "ha_myisammrg.h"
+#include "bitvector.h"
 #ifdef HAVE_BERKELEY_DB
 #include "ha_berkeley.h"
 #endif
@@ -1759,7 +1760,6 @@
   return error;
 }
 
-
 int handler::rename_table(const char * from, const char * to)
 {
   DBUG_ENTER("handler::rename_table");
@@ -2400,4 +2400,124 @@
     *ext= 0;
   }
   return &known_extensions;
+}
+
+int handler::
+ha_write_row(byte *buf) 
+{
+  DBUG_ENTER("ha_write_row");
+  DBUG_PRINT("enter", ("row: 0x%0x", buf));
+#ifndef DBUG_OFF
+  DBUG_PRINT("info", ("thd->query_id=%lu", current_thd->query_id));
+  for (size_t i = 0 ; i < table->s->fields ; ++i) 
+  {
+    DBUG_PRINT("info", ("Field '%s': query_id=%lu, offset=%d, ptr=%p",
+			table->field[i]->field_name,
+			table->field[i]->query_id,
+			table->field[i]->offset(),
+			table->field[i]->ptr));
+  }
+#endif
+  DBUG_PRINT("info", ("Writing row to actual handler"));
+  if (int error = write_row(buf)) {
+    DBUG_PRINT("exit", ("error = %d", error));
+    DBUG_RETURN(error);
+  }
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  DBUG_PRINT("info", ("Writing row to THD"));
+  if (table->s->tmp_table == NO_TMP_TABLE 
+      && !this->is_injective()) 
+  {
+    bitvector const cols(table->s->fields, true);
+    current_thd->write_row(table, table->file->has_transactions(), cols, buf);
+  }
+#endif
+  DBUG_PRINT("exit", ("error = %d", 0));
+  DBUG_RETURN(0);
+}
+  
+int handler::
+ha_update_row(const byte *old_data, byte *new_data) 
+{
+  DBUG_ENTER("ha_update_row");
+  DBUG_PRINT("enter", ("before: 0x%0x; after: 0x%0x", old_data, new_data));
+#ifndef DBUG_OFF
+  DBUG_PRINT("info", ("thd->query_id=%lu", current_thd->query_id));
+  for (size_t i = 0 ; i < table->s->fields ; ++i) 
+  {
+    DBUG_PRINT("info", ("Field '%s': query_id=%lu, offset=%d, ptr=%p",
+			table->field[i]->field_name,
+			table->field[i]->query_id,
+			table->field[i]->offset(),
+			table->field[i]->ptr));
+  }
+#endif
+  if (int error = update_row(old_data, new_data)) {
+    DBUG_PRINT("exit", ("error = %d", error));
+    DBUG_RETURN(error);
+  }
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  if (table->s->tmp_table == NO_TMP_TABLE
+      && !this->is_injective()) 
+  {
+    bitvector const cols(table->s->fields, true);
+    current_thd->update_row(table, table->file->has_transactions(), 
+		    cols, old_data, new_data);
+  }
+#endif
+  DBUG_PRINT("exit", ("error = %d", 0));
+  DBUG_RETURN(0);
+}
+  
+int handler::
+ha_delete_row(const byte *buf) 
+{
+  DBUG_ENTER("ha_delete_row");
+  DBUG_PRINT("enter", ("row: 0x%0x", buf));
+#ifndef DBUG_OFF
+  DBUG_PRINT("info", ("thd->query_id=%lu", current_thd->query_id));
+  for (size_t i = 0 ; i < table->s->fields ; ++i) 
+  {
+    DBUG_PRINT("info", ("Field '%s': query_id=%lu, offset=%d, ptr=%p",
+			table->field[i]->field_name,
+			table->field[i]->query_id,
+			table->field[i]->offset(),
+			table->field[i]->ptr));
+  }
+#endif
+  if (int error = delete_row(buf)) {
+    DBUG_PRINT("exit", ("error = %d", error));
+    DBUG_RETURN(error);
+  }
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  if (table->s->tmp_table == NO_TMP_TABLE
+      && !this->is_injective()) 
+  {
+    bitvector const cols(table->s->fields, true);
+    current_thd->delete_row(table, table->file->has_transactions(),
+		    cols, buf);
+  }
+#endif
+  DBUG_PRINT("exit", ("error = %d", 0));
+  DBUG_RETURN(0);
+}    
+  
+int handler::
+ha_stmt_begin() 
+{ 
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  return current_thd->transaction_begin(); 
+#else
+  return 0;
+#endif
+}
+
+int handler::
+ha_stmt_end()
+{ 
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  return current_thd->transaction_end(); 
+#else
+  return 0;
+#endif
 }

--- 1.136/sql/handler.h	2005-04-11 20:08:58 +10:00
+++ 1.137/sql/handler.h	2005-04-14 22:19:43 +10:00
@@ -160,6 +160,9 @@
 /* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
 #define MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
 
+// Forward declarations
+class bitvector;
+
 enum db_type
 {
   DB_TYPE_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1,
@@ -425,6 +428,7 @@
 } HANDLER_BUFFER;
 
 
+
 class handler :public Sql_alloc
 {
  protected:
@@ -562,11 +566,21 @@
   uint get_index(void) const { return active_index; }
   virtual int open(const char *name, int mode, uint test_if_locked)=0;
   virtual int close(void)=0;
-  virtual int write_row(byte * buf) { return  HA_ERR_WRONG_COMMAND; }
-  virtual int update_row(const byte * old_data, byte * new_data)
-   { return  HA_ERR_WRONG_COMMAND; }
-  virtual int delete_row(const byte * buf)
-   { return  HA_ERR_WRONG_COMMAND; }
+
+  int ha_write_row(byte *buf);  
+  int ha_update_row(const byte *old_data, byte *new_data);
+  int ha_delete_row(const byte *buf);
+  
+  int ha_stmt_begin();
+  int ha_stmt_end();
+
+  /*
+    If the handler does it's own injection of the rows, this member function
+    should return 'true'. An alternative would be to use a set of replication
+    flags, which might be implemented to be faster.
+  */
+  virtual bool is_injective() const { return false; }
+
   virtual int index_read(byte * buf, const byte * key,
 			 uint key_len, enum ha_rkey_function find_flag)
    { return  HA_ERR_WRONG_COMMAND; }
@@ -719,9 +733,9 @@
     default rename_table() and delete_table() rename/delete files with a
     given name and extensions from bas_ext()
   */
-  virtual int rename_table(const char *from, const char *to);
+  virtual int rename_table(const char *from, const char *to);  
   virtual int delete_table(const char *name);
-  
+
   virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0;
 
   /* lock_count() can be more than one if the table is a MERGE */
@@ -753,7 +767,7 @@
  {
    return memcmp(ref1, ref2, ref_length);
  }
- 
+
  /*
    Condition pushdown to storage engines
  */
@@ -787,6 +801,18 @@
      Pops the top if condition stack, if stack is not empty
  */
  virtual void cond_pop() { return; };
+
+private:
+  /*
+    Row-level primitives for storage engines. 
+    These should be overridden by the storage engine class. To call
+    these methods, use the corresponding 'ha_*' method above.
+  */
+  virtual int write_row(byte * buf) { return  HA_ERR_WRONG_COMMAND; }
+  virtual int update_row(const byte * old_data, byte * new_data)
+  { return  HA_ERR_WRONG_COMMAND; }
+  virtual int delete_row(const byte * buf)
+  { return  HA_ERR_WRONG_COMMAND; }
 };
 
 	/* Some extern variables used with handlers */

--- 1.138/sql/item_sum.cc	2005-04-09 11:00:34 +10:00
+++ 1.139/sql/item_sum.cc	2005-04-14 22:19:43 +10:00
@@ -2370,7 +2370,7 @@
     */
     return tree->unique_add(table->record[0] + table->s->null_bytes);
   }
-  if ((error= table->file->write_row(table->record[0])) &&
+  if ((error= table->file->ha_write_row(table->record[0])) &&
       error != HA_ERR_FOUND_DUPP_KEY &&
       error != HA_ERR_FOUND_DUPP_UNIQUE)
     return TRUE;

--- 1.160/sql/log.cc	2005-04-08 21:30:51 +10:00
+++ 1.161/sql/log.cc	2005-04-14 22:42:59 +10:00
@@ -1534,18 +1534,20 @@
   return 0;
 }
 
-
-inline bool sync_binlog(IO_CACHE *cache)
+bool MYSQL_LOG::flush_and_sync()
 {
-  if (sync_binlog_period == ++sync_binlog_counter && sync_binlog_period)
+  int err=0, fd=log_file.file;
+  safe_mutex_assert_owner(&LOCK_log);
+  if (flush_io_cache(&log_file))
+    return 1;
+  if (++sync_binlog_counter >= sync_binlog_period && sync_binlog_period)
   {
     sync_binlog_counter= 0;
-    return my_sync(cache->file, MYF(MY_WME));
+    err=my_sync(fd, MYF(MY_WME));
   }
-  return 0;
+  return err;
 }
 
-
 /*
   Write an event to the binary log
 */
@@ -1691,8 +1693,8 @@
       }
     }
 
-    /* 
-       Write the SQL command 
+    /*
+       Write the SQL command
      */
 
     if (event_info->write(file))
@@ -1701,8 +1703,10 @@
     if (file == &log_file) // we are writing to the real log (disk)
     {
       DBUG_PRINT("info", ("Flushing cache %p", file));
-      if (flush_io_cache(file) || sync_binlog(file))
+      if (flush_and_sync())
 	goto err;
+      signal_update();
+      rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
     }
     error=0;
 
@@ -1715,15 +1719,9 @@
 	my_error(ER_ERROR_ON_WRITE, MYF(0), name, errno);
       write_error=1;
     }
-    if (file == &log_file)
-    {
-      signal_update();
-      rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
-    }
   }
 
   pthread_mutex_unlock(&LOCK_log);
-
   DBUG_RETURN(error);
 }
 
@@ -1830,7 +1828,7 @@
     if (commit_event->write(&log_file))
       goto err;
 DBUG_skip_commit:
-    if (flush_io_cache(&log_file) || sync_binlog(&log_file))
+    if (flush_and_sync())
       goto err;
     DBUG_EXECUTE_IF("half_binlogged_transaction", abort(););
     if (cache->error)				// Error on read
@@ -2000,26 +1998,26 @@
   SYNOPSIS
     wait_for_update()
     thd			Thread variable
-    master_or_slave     If 0, the caller is the Binlog_dump thread from master;
+    is_slave            If 0, the caller is the Binlog_dump thread from master;
                         if 1, the caller is the SQL thread from the slave. This
                         influences only thd->proc_info.
 
   NOTES
     One must have a lock on LOCK_log before calling this function.
-    This lock will be freed before return! That's required by
+    This lock will be released before return! That's required by
     THD::enter_cond() (see NOTES in sql_class.h).
 */
 
-void MYSQL_LOG::wait_for_update(THD* thd, bool master_or_slave)
+void MYSQL_LOG::wait_for_update(THD* thd, bool is_slave)
 {
   const char *old_msg;
   DBUG_ENTER("wait_for_update");
   old_msg= thd->enter_cond(&update_cond, &LOCK_log,
-                           master_or_slave ?
+                           is_slave ?
                            "Has read all relay log; waiting for the slave I/O "
-                           "thread to update it" : 
+                           "thread to update it" :
                            "Has sent all binlog to slave; waiting for binlog "
-                           "to be updated"); 
+                           "to be updated");
   pthread_cond_wait(&update_cond, &LOCK_log);
   thd->exit_cond(old_msg);
   DBUG_VOID_RETURN;
@@ -2068,7 +2066,12 @@
       my_pwrite(log_file.file, &flags, 1, offset, MYF(0));
     }
 
-    if (my_close(log_file.file,MYF(0)) < 0 && ! write_error)
+    if (my_sync(log_file.file,MYF(MY_WME)) && ! write_error)
+    {
+      write_error=1;
+      sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
+    }
+    if (my_close(log_file.file,MYF(MY_WME)) && ! write_error)
     {
       write_error=1;
       sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
@@ -3017,8 +3020,10 @@
 
 void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid)
 {
-  if (thread_safe_dec_and_test(prepared_xids, &LOCK_prep_xids))
+  pthread_mutex_lock(&LOCK_prep_xids);
+  if (--prepared_xids == 0)
     pthread_cond_signal(&COND_prep_xids);
+  pthread_mutex_unlock(&LOCK_prep_xids);
   rotate_and_purge(0);     // as ::write() did not rotate
 }
 

--- 1.289/sql/mysql_priv.h	2005-04-14 19:55:19 +10:00
+++ 1.290/sql/mysql_priv.h	2005-04-14 22:19:43 +10:00
@@ -1064,6 +1064,9 @@
 extern ulong query_buff_size, thread_stack,thread_stack_min;
 extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
 extern ulong max_binlog_size, max_relay_log_size;
+extern my_bool opt_binlog_row_level;
+extern const char * opt_binlog_format;
+extern ulong opt_binlog_row_event_max_size; 
 extern ulong rpl_recovery_rank, thread_cache_size;
 extern ulong back_log;
 extern ulong specialflag, current_pid;

--- 1.447/sql/mysqld.cc	2005-04-14 16:48:39 +10:00
+++ 1.448/sql/mysqld.cc	2005-04-14 22:19:44 +10:00
@@ -31,9 +31,6 @@
 #include "ha_innodb.h"
 #endif
 #include "ha_myisam.h"
-#ifdef HAVE_ISAM
-#include "ha_isam.h"
-#endif
 #ifdef HAVE_NDBCLUSTER_DB
 #include "ha_ndbcluster.h"
 #endif
@@ -48,11 +45,6 @@
 #else
 #define OPT_BDB_DEFAULT 0
 #endif
-#ifdef HAVE_ISAM_DB
-#define OPT_ISAM_DEFAULT 1
-#else
-#define OPT_ISAM_DEFAULT 0
-#endif
 #ifdef HAVE_NDBCLUSTER_DB
 #define OPT_NDBCLUSTER_DEFAULT 0
 #if defined(NOT_ENOUGH_TESTED) \
@@ -65,7 +57,6 @@
 #define OPT_NDBCLUSTER_DEFAULT 0
 #endif
 
-#include <nisam.h>
 #include <thr_alarm.h>
 #include <ft_global.h>
 #include <errmsg.h>
@@ -802,15 +793,6 @@
       CloseHandle(hEvent);
     */
   }
-#ifdef HAVE_SMEM
-    /*
-     Send event to smem_event_connect_request for aborting
-    */
-    if (!SetEvent(smem_event_connect_request))
-    {
-      DBUG_PRINT("error",("Got error: %ld from SetEvent of
smem_event_connect_request",GetLastError()));
-    }
-#endif  
 #endif
 #elif defined(OS2)
   pthread_cond_signal(&eventShutdown);		// post semaphore
@@ -864,6 +846,18 @@
   else
     sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
 
+#if defined(HAVE_SMEM) && defined(__WIN__)    
+  /*    
+   Send event to smem_event_connect_request for aborting    
+   */    
+  if (!SetEvent(smem_event_connect_request))    
+  {      
+	  DBUG_PRINT("error",
+		("Got error: %ld from SetEvent of smem_event_connect_request",
+		 GetLastError()));    
+  }
+#endif  
+  
 #if defined(__NETWARE__) || (defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__)
&& !defined(OS2))
   my_thread_init();				// If this is a new thread
 #endif
@@ -1038,8 +1032,8 @@
     (void) my_delete(pidfile_name,MYF(0));	// This may not always exist
 #endif
   finish_client_errs();
-  const char **errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
-  x_free((gptr) errmsgs);	/* Free messages */
+  my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST),
+          MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
   DBUG_PRINT("quit", ("Error messages freed"));
   /* Tell main we are ready */
   (void) pthread_mutex_lock(&LOCK_thread_count);
@@ -1521,6 +1515,7 @@
       thd=thread_cache.get();
       thd->real_id=pthread_self();
       (void) thd->store_globals();
+      thd->thr_create_time= time(NULL);
       threads.append(thd);
       pthread_mutex_unlock(&LOCK_thread_count);
       DBUG_VOID_RETURN;
@@ -4351,7 +4346,7 @@
    "Don't try to recover Berkeley DB tables on start.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {"bdb-no-sync", OPT_BDB_NOSYNC,
-   "Disable synchronously flushing logs. This option is deprecated, use
--skip-sync-bdb-logs or sync-bdb-logs=0 instead",
+   "This option is deprecated, use --skip-sync-bdb-logs instead",
    //   (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL,
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"bdb-shared-data", OPT_BDB_SHARED,
@@ -4575,9 +4570,8 @@
    (gptr*) &global_system_variables.innodb_support_xa,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
 #endif /* End HAVE_INNOBASE_DB */
-  {"isam", OPT_ISAM, "Enable ISAM (if this version of MySQL supports it). \
-Disable with --skip-isam.",
-   (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, OPT_ISAM_DEFAULT,
0, 0,
+  {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
+   (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,
    0, 0, 0},
   {"language", 'L',
    "Client error messages in given language. May be given as a full path.",
@@ -4737,7 +4731,7 @@
    "Specify number of autoincrement values that are prefetched.",
    (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
    (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
-   0, GET_INT, REQUIRED_ARG, 32, 1, 256, 0, 0, 0},
+   0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0},
   {"ndb-force-send", OPT_NDB_FORCE_SEND,
    "Force send of buffers to ndb immediately without waiting for "
    "other threads.",
@@ -5204,7 +5198,7 @@
    (gptr*) &dflt_key_cache_var.param_buff_size,
    (gptr*) 0,
    0, (GET_ULL | GET_ASK_ADDR),
-   REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, UINT_MAX32, MALLOC_OVERHEAD,
+   REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD,
    IO_SIZE, 0},
   {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
    "This characterizes the number of hits a hot block has to be untouched until it is
considered aged enough to be downgraded to a warm block. This specifies the percentage
ratio of that number of hits to the total number of blocks in key cache",
@@ -5493,36 +5487,35 @@
    1, 0},
 #ifdef HAVE_BERKELEY_DB
   {"sync-bdb-logs", OPT_BDB_SYNC,
-   "Synchronously flush logs. Enabled by default",
+   "Synchronously flush Berkeley DB logs. Enabled by default",
    (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL,
    NO_ARG, 1, 0, 0, 0, 0, 0},
 #endif /* HAVE_BERKELEY_DB */
   {"sync-binlog", OPT_SYNC_BINLOG,
-   "Sync the binlog to disk after every #th event. \
-#=0 (the default) does no sync. Syncing slows MySQL down",
-   (gptr*) &sync_binlog_period,
-   (gptr*) &sync_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1,
-   0},
+   "Synchronously flush binary log to disk after every #th event. "
+   "Use 0 (default) to disable synchronous flushing.",
+   (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG,
+   REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
+  {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.",
+   (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
+   0, 0, 0, 0},
 #ifdef DOES_NOTHING_YET
   {"sync-replication", OPT_SYNC_REPLICATION,
-   "Enable synchronous replication",
+   "Enable synchronous replication.",
    (gptr*) &global_system_variables.sync_replication,
    (gptr*) &global_system_variables.sync_replication,
    0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
   {"sync-replication-slave-id", OPT_SYNC_REPLICATION_SLAVE_ID,
-   "Synchronous replication is wished for this slave",
+   "Synchronous replication is wished for this slave.",
    (gptr*) &global_system_variables.sync_replication_slave_id,
    (gptr*) &global_system_variables.sync_replication_slave_id,
    0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0},
   {"sync-replication-timeout", OPT_SYNC_REPLICATION_TIMEOUT,
-   "Synchronous replication timeout",
+   "Synchronous replication timeout.",
    (gptr*) &global_system_variables.sync_replication_timeout,
    (gptr*) &global_system_variables.sync_replication_timeout,
    0, GET_ULONG, REQUIRED_ARG, 10, 0, ~0L, 0, 1, 0},
 #endif
-  {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default",
-   (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0,
-   0, 0, 0, 0},
   {"table_cache", OPT_TABLE_CACHE,
    "The number of open tables for all threads.", (gptr*) &table_cache_size,
    (gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L,
@@ -5979,11 +5972,7 @@
 #else
   have_innodb=SHOW_OPTION_NO;
 #endif
-#ifdef HAVE_ISAM
-  have_isam=SHOW_OPTION_YES;
-#else
   have_isam=SHOW_OPTION_NO;
-#endif
 #ifdef HAVE_EXAMPLE_DB
   have_example_db= SHOW_OPTION_YES;
 #else
@@ -6133,16 +6122,6 @@
     sf_malloc_mem_limit = atoi(argument);
 #endif
     break;
-#ifdef EMBEDDED_LIBRARY
-  case OPT_MAX_ALLOWED_PACKET:
-    max_allowed_packet= atoi(argument);
-    global_system_variables.max_allowed_packet= max_allowed_packet;
-    break;
-  case OPT_NET_BUFFER_LENGTH:
-    net_buffer_length=  atoi(argument);
-    global_system_variables.net_buffer_length= net_buffer_length;
-    break;
-#endif
 #include <sslopt-case.h>
   case 'V':
     print_version();
@@ -6400,9 +6379,6 @@
       opt_error_log= 0;			// Force logs to stdout
     break;
   case (int) OPT_FLUSH:
-#ifdef HAVE_ISAM
-    nisam_flush=1;
-#endif
     myisam_flush=1;
     flush_time=0;			// No auto flush
     break;
@@ -6509,14 +6485,6 @@
       have_berkeley_db= SHOW_OPTION_DISABLED;
 #endif
     break;
-  case OPT_ISAM:
-#ifdef HAVE_ISAM
-    if (opt_isam)
-      have_isam= SHOW_OPTION_YES;
-    else
-      have_isam= SHOW_OPTION_DISABLED;
-#endif
-    break;
   case OPT_NDBCLUSTER:
 #ifdef HAVE_NDBCLUSTER_DB
     if (opt_ndbcluster)
@@ -6742,6 +6710,9 @@
 #ifndef EMBEDDED_LIBRARY
   if (mysqld_chroot)
     set_root(mysqld_chroot);
+#else
+  max_allowed_packet= global_system_variables.max_allowed_packet;
+  net_buffer_length= global_system_variables.net_buffer_length;
 #endif
   fix_paths();
 

--- 1.176/sql/sql_class.cc	2005-04-13 03:19:47 +10:00
+++ 1.177/sql/sql_class.cc	2005-04-14 22:19:46 +10:00
@@ -161,7 +161,8 @@
   :user_time(0), global_read_lock(0), is_fatal_error(0),
    rand_used(0), time_zone_used(0),
    last_insert_id_used(0), insert_id_used(0), clear_next_insert_id(0),
-   in_lock_tables(0), bootstrap(0), spcont(NULL)
+   in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE),
+   spcont(NULL)
 {
   current_arena= this;
 #ifndef DBUG_OFF
@@ -201,10 +202,11 @@
 #ifndef DBUG_OFF
   dbug_sentry=THD_SENTRY_MAGIC;
 #endif
-#ifndef EMBEDDED_LIBRARY  
+#ifndef EMBEDDED_LIBRARY
   net.vio=0;
 #endif
-  net.last_error[0]=0;				// If error on boot
+  net.last_error[0]=0;                          // If error on boot
+  net.query_cache_query=0;                      // If error on boot
   ull=0;
   system_thread= cleanup_done= abort_on_warning= no_warnings_for_error= 0;
   peer_port= 0;					// For SHOW PROCESSLIST
@@ -214,7 +216,7 @@
 #endif
 #ifdef SIGNAL_WITH_VIO_CLOSE
   active_vio = 0;
-#endif  
+#endif
   pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST);
 
   /* Variables with default values */
@@ -343,7 +345,10 @@
 void THD::cleanup(void)
 {
   DBUG_ENTER("THD::cleanup");
-  ha_rollback(this);
+#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
+  if (transaction.xa_state != XA_PREPARED)
+#endif
+    ha_rollback(this);
   if (locked_tables)
   {
     lock=locked_tables; locked_tables=0;
@@ -385,17 +390,17 @@
   add_to_status(&global_status_var, &status_var);
 
   /* Close connection */
-#ifndef EMBEDDED_LIBRARY  
+#ifndef EMBEDDED_LIBRARY
   if (net.vio)
   {
     vio_delete(net.vio);
-    net_end(&net); 
+    net_end(&net);
   }
 #endif
   if (!cleanup_done)
     cleanup();
 
-    ha_close_connection(this);
+  ha_close_connection(this);
 
   sp_cache_clear(&sp_proc_cache);
   sp_cache_clear(&sp_func_cache);

--- 1.231/sql/sql_class.h	2005-04-14 19:55:20 +10:00
+++ 1.232/sql/sql_class.h	2005-04-14 22:19:46 +10:00
@@ -23,12 +23,15 @@
 
 // TODO: create log.h and move all the log header stuff there
 
+#include "rpl_tblmap.h"
+
 class Query_log_event;
 class Load_log_event;
 class Slave_log_event;
 class Format_description_log_event;
 class sp_rcontext;
 class sp_cache;
+class Rows_log_event;
 
 enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
 enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
@@ -54,6 +57,9 @@
 #define TC_HEURISTIC_RECOVER_ROLLBACK 2
 extern uint tc_heuristic_recover;
 
+// Forward declaration
+class THD;
+
 /*
   Transaction Coordinator log - a base abstract class
   for two different implementations
@@ -234,6 +240,11 @@
   pthread_cond_t  COND_prep_xids;
   friend class Log_event;
 
+  // 'Mutable' needed since this class can not be initialized in the
+  // constructor.  
+  mutable table_mapping* m_table_map;
+  ulong m_next_table_id;
+
 public:
   MYSQL_LOG();
   /*
@@ -248,6 +259,18 @@
   void unlog(ulong cookie, my_xid xid);
   int recover(IO_CACHE *log, Format_description_log_event *fdle);
 
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  // This will return a table id for the table. If the table is not known, a
+  // new table id will be invented and returned. 
+  ulong get_table_id(TABLE* table);
+
+  // This will check if the given table is mapped to any table id
+  int is_table_mapped(TABLE* table) const;
+
+  // This will clear all table mappings
+  void clear_table_mappings();
+
+#endif // !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
   /*
      These describe the log's format. This is used only for relay logs.
      _for_exec is used by the SQL thread, _for_queue by the I/O thread. It's
@@ -1058,6 +1081,57 @@
   my_bool    tablespace_op;	/* This is TRUE in DISCARD/IMPORT TABLESPACE */
   /* container for handler's private per-connection data */
   void *ha_data[MAX_HA];
+
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+
+  /*
+    Public interface to write rows to the binlog
+  */
+  int write_row(TABLE* table, bool is_transactional,
+		bitvector const& cols, const byte *buf);
+  int delete_row(TABLE* table, bool is_transactional,
+		 bitvector const& cols, const byte *buf);
+  int update_row(TABLE* table, bool is_transactional,
+		 bitvector const& cols, 
+		 const byte *old_data, const byte *new_data);
+
+  void set_server_id(uint32 sid) { server_id = sid; }
+
+  int transaction_begin() { 
+    this->options |= OPTION_BEGIN;
+    return 0;
+  }
+
+  int transaction_end() { 
+    int error = flush_pending_event(true); 
+    this->options &= ~OPTION_BEGIN;
+    return error;
+  }
+
+private:
+  /*
+    Member functions to handle pending event for row-level logging.
+  */
+  Rows_log_event* get_pending_event() const;
+  int             set_pending_event(Rows_log_event* ev);
+  int             flush_and_set_pending_event(Rows_log_event*);
+
+  template <class RowsEventT>
+    Rows_log_event* 
+      prepare_pending(TABLE* table, uint32 server_id, 
+		      bitvector const& cols, size_t needed, 
+		      bool is_transactional);
+
+  size_t max_row_length(TABLE* table, const byte *data) const;
+  size_t pack_row(TABLE* table, byte *row_data, 
+		  size_t max_len, const byte *data) const;
+
+  int flush_pending_event(bool stmt_end);
+  int write_table_map(TABLE*,bool);
+
+#endif
+
+public:
   struct st_transactions {
     SAVEPOINT *savepoints;
     THD_TRANS all;			// Trans since BEGIN WORK
@@ -1065,6 +1139,9 @@
     bool on;                            // see ha_enable_transaction()
     XID  xid;                           // transaction identifier
     enum xa_states xa_state;            // used by external XA only
+
+    Rows_log_event* m_pending_rows_event;
+
     /*
        Tables changed in transaction (that must be invalidated in query cache).
        List contain only transactional tables, that not invalidated in query

--- 1.144/sql/sql_delete.cc	2005-04-01 21:32:31 +10:00
+++ 1.145/sql/sql_delete.cc	2005-04-14 22:19:46 +10:00
@@ -362,12 +362,28 @@
                    &lex->select_lex.leaf_tables, FALSE, FALSE))
     DBUG_RETURN(TRUE);
 
+
+  /*
+    Multi-delete can't be constructed over-union => we always have
+    single SELECT on top and have to check underlying SELECTs of it
+  */
+  lex->select_lex.exclude_from_table_unique_test= TRUE;
   /* Fix tables-to-be-deleted-from list to point at opened tables */
   for (target_tbl= (TABLE_LIST*) aux_tables;
        target_tbl;
        target_tbl= target_tbl->next_local)
   {
-    target_tbl->table= target_tbl->correspondent_table->table;
+    if (!(target_tbl->table= target_tbl->correspondent_table->table))
+    {
+      DBUG_ASSERT(target_tbl->correspondent_table->view &&
+                  target_tbl->correspondent_table->ancestor &&
+                  target_tbl->correspondent_table->ancestor->next_local);
+      my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
+               target_tbl->correspondent_table->view_db.str,
+               target_tbl->correspondent_table->view_name.str);
+      DBUG_RETURN(TRUE);
+    }
+
     if (!target_tbl->correspondent_table->updatable ||
         check_key_in_view(thd, target_tbl->correspondent_table))
     {
@@ -376,23 +392,14 @@
       DBUG_RETURN(TRUE);
     }
     /*
-      Check are deleted table used somewhere inside subqueries.
-
-      Multi-delete can't be constructed over-union => we always have
-      single SELECT on top and have to check underlying SELECTs of it
+      Check that table from which we delete is not used somewhere
+      inside subqueries/view.
     */
-    for (SELECT_LEX_UNIT *un= lex->select_lex.first_inner_unit();
-         un;
-         un= un->next_unit())
+    if (unique_table(target_tbl->correspondent_table, lex->query_tables))
     {
-      if (un->first_select()->linkage != DERIVED_TABLE_TYPE &&
-          un->check_updateable(target_tbl->correspondent_table->db,
-                               target_tbl->correspondent_table->table_name))
-      {
-        my_error(ER_UPDATE_TABLE_USED, MYF(0),
-                 target_tbl->correspondent_table->table_name);
-        DBUG_RETURN(TRUE);
-      }
+      my_error(ER_UPDATE_TABLE_USED, MYF(0),
+               target_tbl->correspondent_table->table_name);
+      DBUG_RETURN(TRUE);
     }
   }
   DBUG_RETURN(FALSE);

--- 1.139/sql/sql_insert.cc	2005-04-06 12:45:08 +10:00
+++ 1.140/sql/sql_insert.cc	2005-04-14 22:42:59 +10:00
@@ -313,6 +313,8 @@
                            (MODE_STRICT_TRANS_TABLES |
                             MODE_STRICT_ALL_TABLES)));
 
+  table->file->ha_stmt_begin();
+
   if ((fields.elements || !value_count) &&
       check_that_all_fields_are_given_values(thd, table))
   {
@@ -405,6 +407,8 @@
       table->triggers->process_triggers(thd, TRG_EVENT_INSERT, TRG_ACTION_AFTER);
   }
 
+  table->file->ha_stmt_end();
+
   /*
     Now all rows are inserted.  Time to update logs and sends response to
     user
@@ -448,7 +452,7 @@
     if ((info.copied || info.deleted || info.updated) &&
 	(error <= 0 || !transactional_table))
     {
-      if (mysql_bin_log.is_open())
+      if (!opt_binlog_row_level && mysql_bin_log.is_open())
       {
         if (error <= 0)
           thd->clear_error();
@@ -744,10 +748,11 @@
   DBUG_ENTER("write_record");
 
   info->records++;
+
   if (info->handle_duplicates == DUP_REPLACE ||
       info->handle_duplicates == DUP_UPDATE)
   {
-    while ((error=table->file->write_row(table->record[0])))
+    while ((error=table->file->ha_write_row(table->record[0])))
     {
       uint key_nr;
       if (error != HA_WRITE_SKIP)
@@ -821,7 +826,7 @@
         if (res == VIEW_CHECK_ERROR)
           goto err;
 
-        if
((error=table->file->update_row(table->record[1],table->record[0])))
+        if
((error=table->file->ha_update_row(table->record[1],table->record[0])))
           goto err;
         info->updated++;
         break;
@@ -841,13 +846,13 @@
             (table->timestamp_field_type == TIMESTAMP_NO_AUTO_SET ||
              table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
         {
-          if ((error=table->file->update_row(table->record[1],
-					     table->record[0])))
+          if ((error=table->file->ha_update_row(table->record[1],
+						table->record[0])))
             goto err;
           info->deleted++;
           break;				/* Update logfile and count */
         }
-        else if ((error=table->file->delete_row(table->record[1])))
+        else if ((error=table->file->ha_delete_row(table->record[1])))
           goto err;
         info->deleted++;
         if (!table->file->has_transactions())
@@ -856,7 +861,7 @@
     }
     info->copied++;
   }
-  else if ((error=table->file->write_row(table->record[0])))
+  else if ((error=table->file->ha_write_row(table->record[0])))
   {
     if (!info->ignore ||
 	(error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE))

--- 1.311/sql/sql_select.cc	2005-04-13 15:43:01 +10:00
+++ 1.312/sql/sql_select.cc	2005-04-14 22:19:47 +10:00
@@ -8524,6 +8524,7 @@
 
 TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list)
 {
+  DBUG_ENTER("create_virtual_tmp_table");
   uint field_count= field_list.elements;
   Field **field;
   create_field *cdef;                           /* column definition */
@@ -8535,7 +8536,7 @@
   TABLE *table= (TABLE*) thd->calloc(sizeof(*table));
   field= (Field**) thd->alloc((field_count + 1) * sizeof(Field*));
   if (!table || !field)
-    return 0;
+    DBUG_RETURN(0);
 
   table->field= field;
   table->s= s= &table->share_not_to_be_used;
@@ -8553,6 +8554,10 @@
                        cdef->interval, cdef->field_name, table);
     if (!*field)
       goto error;
+
+    DBUG_ASSERT( (f_maybe_null(cdef->pack_flag) && !((**field).flags &
NOT_NULL_FLAG)) ||
+		 (!f_maybe_null(cdef->pack_flag) && ((**field).flags & NOT_NULL_FLAG)));
+
     record_length+= (**field).pack_length();
     if (! ((**field).flags & NOT_NULL_FLAG))
       ++null_count;
@@ -8585,7 +8590,7 @@
     {
       Field *cur_field= *field;
       if ((cur_field->flags & NOT_NULL_FLAG))
-        cur_field->move_field((char*) field_pos);
+        cur_field->move_field((char*) field_pos,0,0);
       else
       {
         cur_field->move_field((char*) field_pos, (uchar*) null_pos, null_bit);
@@ -8601,11 +8606,11 @@
       field_pos+= cur_field->pack_length();
     }
   }
-  return table;
+  DBUG_RETURN(table);
 error:
   for (field= table->field; *field; ++field)
     delete *field;                         /* just invokes field destructor */
-  return 0;
+  DBUG_RETURN(0);
 }
 
 
@@ -8831,11 +8836,11 @@
   /* copy all old rows */
   while (!table->file->rnd_next(new_table.record[1]))
   {
-    if ((write_err=new_table.file->write_row(new_table.record[1])))
+    if ((write_err=new_table.file->ha_write_row(new_table.record[1])))
       goto err;
   }
   /* copy row that filled HEAP table */
-  if ((write_err=new_table.file->write_row(table->record[0])))
+  if ((write_err=new_table.file->ha_write_row(table->record[0])))
   {
     if (write_err != HA_ERR_FOUND_DUPP_KEY &&
 	write_err != HA_ERR_FOUND_DUPP_UNIQUE || !ignore_last_dupp_key_error)
@@ -10117,7 +10122,7 @@
     if (!join->having || join->having->val_int())
     {
       join->found_records++;
-      if ((error=table->file->write_row(table->record[0])))
+      if ((error=table->file->ha_write_row(table->record[0])))
       {
 	if (error == HA_ERR_FOUND_DUPP_KEY ||
 	    error == HA_ERR_FOUND_DUPP_UNIQUE)
@@ -10179,8 +10184,8 @@
   {						/* Update old record */
     restore_record(table,record[1]);
     update_tmptable_sum_func(join->sum_funcs,table);
-    if ((error=table->file->update_row(table->record[1],
-				       table->record[0])))
+    if ((error=table->file->ha_update_row(table->record[1],
+					  table->record[0])))
     {
       table->file->print_error(error,MYF(0));	/* purecov: inspected */
       DBUG_RETURN(-1);				/* purecov: inspected */
@@ -10203,7 +10208,7 @@
   }
   init_tmptable_sum_functions(join->sum_funcs);
   copy_funcs(join->tmp_table_param.items_to_copy);
-  if ((error=table->file->write_row(table->record[0])))
+  if ((error=table->file->ha_write_row(table->record[0])))
   {
     if (create_myisam_from_heap(join->thd, table, &join->tmp_table_param,
 				error, 0))
@@ -10239,7 +10244,7 @@
   copy_fields(&join->tmp_table_param);		// Groups are copied twice.
   copy_funcs(join->tmp_table_param.items_to_copy);
 
-  if (!(error=table->file->write_row(table->record[0])))
+  if (!(error=table->file->ha_write_row(table->record[0])))
     join->send_records++;			// New group
   else
   {
@@ -10255,8 +10260,8 @@
     }
     restore_record(table,record[1]);
     update_tmptable_sum_func(join->sum_funcs,table);
-    if ((error=table->file->update_row(table->record[1],
-				       table->record[0])))
+    if ((error=table->file->ha_update_row(table->record[1],
+					  table->record[0])))
     {
       table->file->print_error(error,MYF(0));	/* purecov: inspected */
       DBUG_RETURN(-1);				/* purecov: inspected */
@@ -10300,7 +10305,7 @@
                        join->sum_funcs_end[send_group_parts]);
 	if (join->having && join->having->val_int() == 0)
           error= -1;
-        else if ((error= table->file->write_row(table->record[0])))
+        else if ((error= table->file->ha_write_row(table->record[0])))
 	{
 	  if (create_myisam_from_heap(join->thd, table,
 				      &join->tmp_table_param,
@@ -11156,7 +11161,7 @@
     }
     if (having && !having->val_int())
     {
-      if ((error=file->delete_row(record)))
+      if ((error=file->ha_delete_row(record)))
 	goto err;
       error=file->rnd_next(record);
       continue;
@@ -11183,7 +11188,7 @@
       }
       if (compare_record(table, first_field) == 0)
       {
-	if ((error=file->delete_row(record)))
+	if ((error=file->ha_delete_row(record)))
 	  goto err;
       }
       else if (!found)
@@ -11280,7 +11285,7 @@
     }
     if (having && !having->val_int())
     {
-      if ((error=file->delete_row(record)))
+      if ((error=file->ha_delete_row(record)))
 	goto err;
       continue;
     }
@@ -11297,7 +11302,7 @@
     if (hash_search(&hash, org_key_pos, key_length))
     {
       /* Duplicated found ; Remove the row */
-      if ((error=file->delete_row(record)))
+      if ((error=file->ha_delete_row(record)))
 	goto err;
     }
     else
@@ -12966,7 +12971,7 @@
           item->save_in_result_field(1);
       }
       copy_sum_funcs(sum_funcs_end[i+1], sum_funcs_end[i]);
-      if ((error= table->file->write_row(table->record[0])))
+      if ((error= table->file->ha_write_row(table->record[0])))
       {
 	if (create_myisam_from_heap(thd, table, &tmp_table_param,
 				      error, 0))

--- 1.227/sql/sql_show.cc	2005-04-09 02:40:59 +10:00
+++ 1.228/sql/sql_show.cc	2005-04-14 22:19:48 +10:00
@@ -1704,6 +1704,8 @@
                                strlen(item_field->field_name), 0)))
       return 0;
   }
+  else if (item->type() == Item::REF_ITEM)
+    return uses_only_table_name_fields(item->real_item(), table);
   if (item->type() == Item::SUBSELECT_ITEM &&
       !item->const_item())
     return 0;
@@ -2290,8 +2292,32 @@
       char tmp[MAX_FIELD_WIDTH];
       char tmp1[MAX_FIELD_WIDTH];
       String type(tmp,sizeof(tmp), system_charset_info);
+      char *end= tmp;
       count++;
       restore_record(table, s->default_values);
+
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+      uint col_access;
+      check_access(thd,SELECT_ACL | EXTRA_ACL, base_name,
+                   &tables->grant.privilege, 0, 0);
+      col_access= get_column_grant(thd, &tables->grant, tables->db,
+                                   tables->table_name,
+                                   field->field_name) & COL_ACLS;
+      if (lex->orig_sql_command != SQLCOM_SHOW_FIELDS  && !col_access)
+        continue;
+      for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
+      {
+        if (col_access & 1)
+        {
+          *end++=',';
+          end=strmov(end,grant_types.type_names[bitnr]);
+        }
+      }
+#else
+      *end= 0;
+#endif
+      table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
+
       table->field[1]->store(base_name, strlen(base_name), cs);
       table->field[2]->store(file_name, strlen(file_name), cs);
       table->field[3]->store(field->field_name, strlen(field->field_name),
@@ -2335,11 +2361,13 @@
       table->field[6]->store((const char*) pos,
                              strlen((const char*) pos), cs);
       if (field->has_charset())
+      {
         table->field[8]->store((longlong) field->representation_length()/
                                field->charset()->mbmaxlen);
-      else
-        table->field[8]->store((longlong) field->representation_length());
-      table->field[9]->store((longlong) field->representation_length());
+        table->field[8]->set_notnull();
+        table->field[9]->store((longlong) field->representation_length());
+        table->field[9]->set_notnull();
+      }
 
       {
         uint dec =field->decimals();
@@ -2396,31 +2424,12 @@
                    (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
       table->field[15]->store((const char*) pos,
                               strlen((const char*) pos), cs);
-      char *end= tmp;
+      end= tmp;
       if (field->unireg_check == Field::NEXT_NUMBER)
         end=strmov(tmp,"auto_increment");
       table->field[16]->store(tmp, (uint) (end-tmp), cs);
 
       end=tmp;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
-      uint col_access;
-      check_access(thd,SELECT_ACL | EXTRA_ACL, base_name,
-                   &tables->grant.privilege, 0, 0);
-      col_access= get_column_grant(thd, &tables->grant, tables->db,
-                                   tables->table_name,
-                                   field->field_name) & COL_ACLS;
-      for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
-      {
-        if (col_access & 1)
-        {
-          *end++=',';
-          end=strmov(end,grant_types.type_names[bitnr]);
-        }
-      }
-#else
-      end=strmov(end,"");
-#endif
-      table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs);
       table->field[18]->store(field->comment.str, field->comment.length, cs);
       if (schema_table_store_record(thd, table))
         DBUG_RETURN(1);
@@ -3435,12 +3444,11 @@
     TABLE_LIST *table_list= tab->table->pos_in_table_list;
     if (table_list->schema_table && thd->fill_derived_tables())
     {
-      TABLE_LIST *save_next_global= table_list->next_global;
       TABLE_LIST **query_tables_last= lex->query_tables_last;
       TABLE *old_derived_tables= thd->derived_tables;
       MYSQL_LOCK *sql_lock= thd->lock;
       lex->sql_command= SQLCOM_SHOW_FIELDS;
-
+      DBUG_ASSERT(!*query_tables_last);
       if (&lex->unit != lex->current_select->master_unit()) // is subselect
       {
         table_list->table->file->extra(HA_EXTRA_RESET_STATE);
@@ -3459,8 +3467,8 @@
       thd->lock= sql_lock;
       lex->sql_command= SQLCOM_SELECT;
       thd->derived_tables= old_derived_tables;
-      table_list->next_global= save_next_global;
       lex->query_tables_last= query_tables_last;
+      *query_tables_last= 0;
     }
   }
   thd->no_warnings_for_error= 0;
@@ -3515,8 +3523,8 @@
   {"COLUMN_DEFAULT", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Default"},
   {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null"},
   {"DATA_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
-  {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
-  {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 0, 0},
+  {"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
+  {"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
   {"NUMERIC_PRECISION", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
   {"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0},
   {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0},

--- 1.238/sql/sql_table.cc	2005-04-13 04:11:55 +10:00
+++ 1.239/sql/sql_table.cc	2005-04-14 22:19:49 +10:00
@@ -463,6 +463,7 @@
    1	Error
 */
 
+extern TYPELIB *DUMMY_TYPELIB;
 int prepare_create_field(create_field *sql_field, 
 			 uint *blob_columns, 
 			 int *timestamps, int *timestamps_with_niladic,
@@ -541,9 +542,10 @@
     if (sql_field->charset->state & MY_CS_BINSORT)
       sql_field->pack_flag|=FIELDFLAG_BINARY;
     sql_field->unireg_check=Field::INTERVAL_FIELD;
-    check_duplicates_in_interval("ENUM",sql_field->field_name,
-                                 sql_field->interval,
-                                 sql_field->charset);
+    if (sql_field->interval != DUMMY_TYPELIB)
+      check_duplicates_in_interval("ENUM",sql_field->field_name,
+				   sql_field->interval,
+				   sql_field->charset);
     break;
   case FIELD_TYPE_SET:
     sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
@@ -551,9 +553,10 @@
     if (sql_field->charset->state & MY_CS_BINSORT)
       sql_field->pack_flag|=FIELDFLAG_BINARY;
     sql_field->unireg_check=Field::BIT_FIELD;
-    check_duplicates_in_interval("SET",sql_field->field_name,
-                                 sql_field->interval,
-                                 sql_field->charset);
+    if (sql_field->interval != DUMMY_TYPELIB)
+      check_duplicates_in_interval("SET",sql_field->field_name,
+				   sql_field->interval,
+				   sql_field->charset);
     break;
   case FIELD_TYPE_DATE:			// Rest of string types
   case FIELD_TYPE_NEWDATE:
@@ -3782,7 +3785,7 @@
     {
       copy_ptr->do_copy(copy_ptr);
     }
-    if ((error=to->file->write_row((byte*) to->record[0])))
+    if ((error=to->file->ha_write_row((byte*) to->record[0])))
     {
       if ((!ignore &&
 	   handle_duplicates != DUP_REPLACE) ||

--- 1.45/sql/sql_udf.cc	2005-04-01 21:32:33 +10:00
+++ 1.46/sql/sql_udf.cc	2005-04-14 22:19:49 +10:00
@@ -525,8 +525,11 @@
   tables.table_name= tables.alias= (char*) "func";
   if (!(table = open_ltable(thd,&tables,TL_WRITE)))
     goto err;
-  if (!table->file->index_read_idx(table->record[0],0,(byte*) udf_name->str,
-				   (uint) udf_name->length,
+  table->field[0]->store(udf_name->str, udf_name->length,
system_charset_info);
+  table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
+  if (!table->file->index_read_idx(table->record[0], 0,
+				   (byte*) table->field[0]->ptr,
+				   table->key_info[0].key_length,
 				   HA_READ_KEY_EXACT))
   {
     int error;

--- 1.153/sql/sql_update.cc	2005-04-08 21:30:54 +10:00
+++ 1.154/sql/sql_update.cc	2005-04-14 22:19:49 +10:00
@@ -695,16 +695,6 @@
         DBUG_RETURN(TRUE);
       }
 
-      /*
-        Multi-update can't be constructed over-union => we always have
-        single SELECT on top and have to check underlying SELECTs of it
-      */
-      if (lex->select_lex.check_updateable_in_subqueries(tl->db,
-                                                         tl->table_name))
-      {
-        my_error(ER_UPDATE_TABLE_USED, MYF(0), tl->table_name);
-        DBUG_RETURN(TRUE);
-      }
       DBUG_PRINT("info",("setting table `%s` for update", tl->alias));
       tl->lock_type= lex->multi_lock_option;
       tl->updating= 1;
@@ -785,6 +775,11 @@
       DBUG_RETURN(TRUE);
   }
 
+  /*
+    Check that we are not using table that we are updating, but we should
+    skip all tables of UPDATE SELECT itself
+  */
+  lex->select_lex.exclude_from_table_unique_test= TRUE;
   /* We only need SELECT privilege for columns in the values list */
   for (tl= leaves; tl; tl= tl->next_leaf)
   {
@@ -798,11 +793,19 @@
     }
     DBUG_PRINT("info", ("table: %s  want_privilege: %u", tl->alias,
                         (uint) table->grant.want_privilege));
+    if (tl->lock_type != TL_READ &&
+        tl->lock_type != TL_READ_NO_INSERT &&
+        unique_table(tl, table_list))
+    {
+      my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
+      DBUG_RETURN(TRUE);
+    }
   }
 
   if (thd->fill_derived_tables() &&
       mysql_handle_derived(lex, &mysql_derived_filling))
     DBUG_RETURN(TRUE);
+
   DBUG_RETURN (FALSE);
 }
 

--- 1.36/mysql-test/r/ctype_ucs.result	2005-04-08 21:30:48 +10:00
+++ 1.37/mysql-test/r/ctype_ucs.result	2005-04-14 22:42:58 +10:00
@@ -518,28 +518,6 @@
 execute stmt1 using @ivar;
 ?
 1234
-SET TIMESTAMP=10000;
-create table t2 (c char(30)) charset=ucs2;
-set @v=convert('abc' using ucs2);
-reset master;
-insert into t2 values (@v);
-show binlog events from 102;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	User var	1	#	@`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci
-master-bin.000001	#	Query	1	#	use `test`; insert into t2 values (@v)
-/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-ROLLBACK;
-SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`;
-use test;
-SET TIMESTAMP=10000;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1,
@@session.unique_checks=1;
-SET @@session.sql_mode=0;
-SET
@@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
-insert into t2 values (@v);
-ROLLBACK;
-/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-drop table t2;
 set names latin1;
 create table t1 (a enum('x','y','z') character set ucs2);
 show create table t1;

--- 1.29/mysql-test/t/ctype_ucs.test	2005-04-08 21:30:49 +10:00
+++ 1.30/mysql-test/t/ctype_ucs.test	2005-04-14 22:42:58 +10:00
@@ -331,24 +331,7 @@
 execute stmt1 using @ivar;
 
 #
-# Check correct binlogging of UCS2 user variables (BUG#3875)
-#
-SET TIMESTAMP=10000;
-create table t2 (c char(30)) charset=ucs2;
-set @v=convert('abc' using ucs2);
-reset master;
-insert into t2 values (@v);
---replace_column 2 # 5 #
 show binlog events from 102;
-# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
-# absolutely need variables names to be quoted and strings to be
-# escaped).
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 
-drop table t2;
-
-
-#
 # Check that ucs2 works with ENUM and SET type
 #
 set names latin1;

--- 1.283/BitKeeper/etc/logging_ok	2005-04-14 16:48:45 +10:00
+++ 1.284/BitKeeper/etc/logging_ok	2005-04-14 22:19:03 +10:00
@@ -9,6 +9,7 @@
 WAX@stripped
 acurtis@stripped
 acurtis@stripped
+acurtis@stripped
 administrador@stripped
 ahlentz@stripped
 akishkin@stripped
@@ -56,8 +57,10 @@
 georg@stripped
 georg@stripped
 gerberb@stripped
+gluh@stripped
 gluh@gluh.(none)
 gluh@stripped
+gluh@stripped
 gordon@stripped
 greg@stripped
 greg@stripped

--- 1.19/mysql-test/t/mysqlbinlog.test	2005-04-09 02:40:59 +10:00
+++ 1.20/mysql-test/t/mysqlbinlog.test	2005-04-14 22:19:33 +10:00
@@ -1,5 +1,8 @@
 # We are using .opt file since we need small binlog size
 
+# Embedded server doesn't support binlogging
+-- source include/not_embedded.inc
+
 # we need this for getting fixed timestamps inside of this test
 set timestamp=1000000000;
 

--- 1.42/mysql-test/r/information_schema.result	2005-04-09 02:40:59 +10:00
+++ 1.43/mysql-test/r/information_schema.result	2005-04-14 22:19:30 +10:00
@@ -24,11 +24,11 @@
 test
 show databases where `database` = 't%';
 Database
-create database testtets;
-create table testtets.t1(a int, b VARCHAR(30), KEY string_data (b));
+create database mysqltest;
+create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b));
 create table test.t2(a int);
 create table t3(a int, KEY a_data (a));
-create table testtets.t4(a int);
+create table mysqltest.t4(a int);
 create view v1 (c) as select table_name from information_schema.TABLES;
 select * from v1;
 c
@@ -65,13 +65,13 @@
 time_zone_transition
 time_zone_transition_type
 user
+t1
+t4
 t2
 t3
 v1
-t1
-t4
 select c,table_name from v1 
-left join information_schema.TABLES v2 on (v1.c=v2.table_name)
+inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
 where v1.c like "t%";
 c	table_name
 TABLES	TABLES
@@ -83,10 +83,27 @@
 time_zone_name	time_zone_name
 time_zone_transition	time_zone_transition
 time_zone_transition_type	time_zone_transition_type
+t1	t1
+t4	t4
 t2	t2
 t3	t3
+select c,table_name from v1 
+left join information_schema.TABLES v2 on (v1.c=v2.table_name)
+where v1.c like "t%";
+c	table_name
+TABLES	TABLES
+TABLE_PRIVILEGES	TABLE_PRIVILEGES
+TABLE_CONSTRAINTS	TABLE_CONSTRAINTS
+tables_priv	tables_priv
+time_zone	time_zone
+time_zone_leap_second	time_zone_leap_second
+time_zone_name	time_zone_name
+time_zone_transition	time_zone_transition
+time_zone_transition_type	time_zone_transition_type
 t1	t1
 t4	t4
+t2	t2
+t3	t3
 select c, v2.table_name from v1
 right join information_schema.TABLES v2 on (v1.c=v2.table_name)
 where v1.c like "t%";
@@ -100,18 +117,18 @@
 time_zone_name	time_zone_name
 time_zone_transition	time_zone_transition
 time_zone_transition_type	time_zone_transition_type
-t2	t2
-t3	t3
 t1	t1
 t4	t4
+t2	t2
+t3	t3
 select table_name from information_schema.TABLES
-where table_schema = "testtets" and table_name like "t%";
+where table_schema = "mysqltest" and table_name like "t%";
 table_name
 t1
 t4
-select * from information_schema.STATISTICS where TABLE_SCHEMA = "testtets";
+select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest";
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	NON_UNIQUE	INDEX_SCHEMA	INDEX_NAME	SEQ_IN_INDEX	COLUMN_NAME	COLLATION	CARDINALITY	SUB_PART	PACKED	NULLABLE	INDEX_TYPE	COMMENT
-NULL	testtets	t1	1	testtets	string_data	1	b	A	NULL	NULL	NULL	YES	BTREE	
+NULL	mysqltest	t1	1	mysqltest	string_data	1	b	A	NULL	NULL	NULL	YES	BTREE	
 show keys from t3 where Key_name = "a_data";
 Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
 t3	1	a_data	1	a	A	NULL	NULL	NULL	YES	BTREE	
@@ -136,13 +153,22 @@
 select * from information_schema.COLUMNS where table_name="t1"
 and column_name= "a";
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION	COLUMN_DEFAULT	IS_NULLABLE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	CHARACTER_SET_NAME	COLLATION_NAME	COLUMN_TYPE	COLUMN_KEY	EXTRA	PRIVILEGES	COLUMN_COMMENT
-NULL	testtets	t1	a	1	NULL	YES	int	11	11	11	0	NULL	NULL	int(11)			select,insert,update,references	
-show columns from testtets.t1 where field like "%a%";
+NULL	mysqltest	t1	a	1	NULL	YES	int	NULL	NULL	11	0	NULL	NULL	int(11)			select,insert,update,references	
+show columns from mysqltest.t1 where field like "%a%";
 Field	Type	Null	Key	Default	Extra
 a	int(11)	YES		NULL	
+grant select (a) on mysqltest.t1 to mysqltest_2@localhost;
+select table_name, column_name, privileges from information_schema.columns 
+where table_schema = 'mysqltest' and table_name = 't1';
+table_name	column_name	privileges
+t1	a	select
+show columns from mysqltest.t1;
+Field	Type	Null	Key	Default	Extra
+a	int(11)	YES		NULL	
+b	varchar(30)	YES	MUL	NULL	
 drop view v1;
-drop tables testtets.t4, testtets.t1, t2, t3;
-drop database testtets;
+drop tables mysqltest.t4, mysqltest.t1, t2, t3;
+drop database mysqltest;
 select * from information_schema.CHARACTER_SETS
 where CHARACTER_SET_NAME like 'latin1%';
 CHARACTER_SET_NAME	DEFAULT_COLLATE_NAME	DESCRIPTION	MAXLEN
@@ -356,8 +382,8 @@
 'mysqltest_1'@'localhost'	NULL	test	t1	a	REFERENCES	NO
 delete from mysql.user where user='mysqltest_1' or user='mysqltest_2';
 delete from mysql.db where user='mysqltest_1' or user='mysqltest_2';
-delete from mysql.tables_priv where user='mysqltest_1';
-delete from mysql.columns_priv where user='mysqltest_1';
+delete from mysql.tables_priv where user='mysqltest_1' or user='mysqltest_2';
+delete from mysql.columns_priv where user='mysqltest_1' or user='mysqltest_2';
 flush privileges;
 drop table t1;
 create table t1 (a int null, primary key(a));
@@ -480,15 +506,15 @@
 CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
 from information_schema.columns where table_name= 't1';
 COLUMN_NAME	COLUMN_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE
-a	decimal(5,3)	7	7	5	3
-b	decimal(5,1)	7	7	5	1
-c	float(5,2)	5	5	5	2
-d	decimal(6,4)	8	8	6	4
-e	float	12	12	12	NULL
-f	decimal(6,3)	8	8	6	3
-g	int(11)	11	11	11	0
-h	double(10,3)	10	10	10	3
-i	double	22	22	22	NULL
+a	decimal(5,3)	NULL	NULL	5	3
+b	decimal(5,1)	NULL	NULL	5	1
+c	float(5,2)	NULL	NULL	5	2
+d	decimal(6,4)	NULL	NULL	6	4
+e	float	NULL	NULL	12	NULL
+f	decimal(6,3)	NULL	NULL	6	3
+g	int(11)	NULL	NULL	11	0
+h	double(10,3)	NULL	NULL	10	3
+i	double	NULL	NULL	22	NULL
 drop table t1;
 create table t115 as select table_name, column_name, column_type
 from information_schema.columns where table_name = 'proc';
@@ -682,3 +708,25 @@
 AND A.TABLE_NAME = B.TABLE_NAME);
 COUNT(*)
 0
+create table t1
+( x_bigint BIGINT,
+x_integer INTEGER,
+x_smallint SMALLINT,
+x_decimal DECIMAL(5,3),
+x_numeric NUMERIC(5,3),
+x_real REAL,
+x_float FLOAT,
+x_double_precision DOUBLE PRECISION );
+SELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH
+FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_NAME= 't1';
+COLUMN_NAME	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH
+x_bigint	NULL	NULL
+x_integer	NULL	NULL
+x_smallint	NULL	NULL
+x_decimal	NULL	NULL
+x_numeric	NULL	NULL
+x_real	NULL	NULL
+x_float	NULL	NULL
+x_double_precision	NULL	NULL
+drop table t1;

--- 1.32/mysql-test/r/ps_1general.result	2005-04-08 21:30:48 +10:00
+++ 1.33/mysql-test/r/ps_1general.result	2005-04-14 22:19:31 +10:00
@@ -306,10 +306,6 @@
 sql_mode	
 prepare stmt4 from ' show engine bdb logs ';
 execute stmt4;
-prepare stmt4 from ' show full processlist ';
-execute stmt4;
-Id	User	Host	db	Command	Time	State	Info
-number	root	localhost	test	Query	time	NULL	show full processlist
 prepare stmt4 from ' show grants for user ';
 prepare stmt4 from ' show create table t2 ';
 ERROR HY000: This command is not supported in the prepared statement protocol yet
@@ -415,18 +411,6 @@
 prepare stmt3 from ' drop database mysqltest ';
 ERROR HY000: This command is not supported in the prepared statement protocol yet
 drop database mysqltest ;
-prepare stmt3 from ' grant all on test.t1 to drop_user@localhost
-identified by ''looser'' ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
-grant all on test.t1 to drop_user@localhost
-identified by 'looser' ;
-prepare stmt3 from ' revoke all privileges on test.t1 from 
-drop_user@localhost ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
-revoke all privileges on test.t1 from drop_user@localhost ;
-prepare stmt3 from ' drop user drop_user@localhost ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
-drop user drop_user@localhost;
 prepare stmt3 from ' describe t2 ';
 execute stmt3;
 Field	Type	Null	Key	Default	Extra
@@ -465,17 +449,17 @@
 ab
 prepare stmt4 from ' SET sql_mode="" ';
 execute stmt4;
-select 'a' || 'b' ;
-'a' || 'b'
-0
-prepare stmt5 from ' select ''a'' || ''b'' ' ;
+select '2' || '3' ;
+'2' || '3'
+1
+prepare stmt5 from ' select ''2'' || ''3'' ' ;
 execute stmt5;
-'a' || 'b'
-0
+'2' || '3'
+1
 SET sql_mode=ansi;
 execute stmt5;
-'a' || 'b'
-0
+'2' || '3'
+1
 SET sql_mode="";
 prepare stmt1 from ' flush local privileges ' ;
 ERROR HY000: This command is not supported in the prepared statement protocol yet
@@ -577,7 +561,7 @@
 prepare stmt1 from ' rename table t5 to t6, t7 to t8 ' ;
 create table t5 (a int) ;
 execute stmt1 ;
-ERROR HY000: Can't find file: './test/t7.frm' (errno: 2)
+ERROR HY000: Can't find file: './test/t7' (errno: 2)
 create table t7 (a int) ;
 execute stmt1 ;
 execute stmt1 ;
@@ -821,81 +805,3 @@
 prepare stmt1 from ' select * from t5 ' ;
 execute stmt1 ;
 drop table t5 ;
-test_sequence
------- grant/revoke/drop affects a parallel session test ------
-show grants for second_user@localhost ;
-ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost'
-create database mysqltest;
-use mysqltest;
-use test;
-grant usage on mysqltest.* to second_user@localhost
-identified by 'looser' ;
-grant select on mysqltest.t9 to second_user@localhost
-identified by 'looser' ;
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-select current_user();
-current_user()
-second_user@localhost
-show grants for current_user();
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-prepare s_t9 from 'select c1 as my_col 
-                                 from t9 where c1= 1' ;
-execute s_t9 ;
-my_col
-1
-select a as my_col from t1;
-ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1'
-grant select on mysqltest.t1 to second_user@localhost
-identified by 'looser' ;
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-drop table mysqltest.t9 ;
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t1` TO 'second_user'@'localhost'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-prepare s_t1 from 'select a as my_col from t1' ;
-execute s_t1 ;
-my_col
-1
-2
-3
-4
-execute s_t9 ;
-ERROR 42S02: Table 'mysqltest.t9' doesn't exist
-revoke all privileges on mysqltest.t1 from second_user@localhost
-identified by 'looser' ;
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-GRANT SELECT ON `mysqltest`.`t9` TO 'second_user'@'localhost'
-execute s_t1 ;
-ERROR 42000: SELECT command denied to user 'second_user'@'localhost' for table 't1'
-revoke all privileges, grant option from second_user@localhost ;
-show grants for second_user@localhost ;
-Grants for second_user@localhost
-GRANT USAGE ON *.* TO 'second_user'@'localhost' IDENTIFIED BY PASSWORD
'*13843FE600B19A81E32AF50D4A6FED25875FF1F3'
-drop user second_user@localhost ;
-commit ;
-show grants for second_user@localhost ;
-ERROR 42000: There is no such grant defined for user 'second_user' on host 'localhost'
-drop table t1,t9 ;
-drop database mysqltest;

--- 1.15/mysql-test/t/mix_innodb_myisam_binlog.test	2005-04-01 21:32:24 +10:00
+++ 1.16/mysql-test/t/mix_innodb_myisam_binlog.test	2005-04-14 22:19:32 +10:00
@@ -5,6 +5,9 @@
 # did some tests manually on a slave; tables are replicated fine and
 # Exec_Master_Log_Pos advances as expected.
 
+# Embedded server doesn't support binlogging
+-- source include/not_embedded.inc
+
 -- source include/have_innodb.inc
 
 --disable_warnings
@@ -26,7 +29,7 @@
 commit;
 
 --replace_column 5 #
---replace_result "xid=12" "xid=7"
+--replace_result "xid=15" "xid=8"
 show binlog events from 102;
 
 delete from t1;
@@ -55,7 +58,7 @@
 commit;
 
 --replace_column 5 #
---replace_result "xid=45" "xid=24"
+--replace_result "xid=48" "xid=25"
 show binlog events from 102;
 
 delete from t1;
@@ -73,7 +76,7 @@
 select a from t1 order by a; # check that savepoints work :)
 
 --replace_column 5 #
---replace_result "xid=67" "xid=36"
+--replace_result "xid=70" "xid=37"
 show binlog events from 102;
 
 # and when ROLLBACK is not explicit?
@@ -106,7 +109,7 @@
 insert into t2 select * from t1;
 
 --replace_column 5 #
---replace_result "xid=116" "xid=59"
+--replace_result "xid=119" "xid=60"
 show binlog events from 102;
 
 # Check that when the query updat1ng the MyISAM table is the first in the
@@ -119,13 +122,13 @@
 begin;
 insert into t2 select * from t1;
 --replace_column 5 #
---replace_result "xid=130" "xid=65"
+--replace_result "xid=133" "xid=66"
 show binlog events from 102;
 insert into t1 values(11);
 commit;
 
 --replace_column 5 #
---replace_result "xid=130" "xid=65" "xid=133" "xid=67"
+--replace_result "xid=133" "xid=66" "xid=136" "xid=68"
 show binlog events from 102;
 
 
@@ -144,7 +147,7 @@
 commit;
 
 --replace_column 5 #
---replace_result "xid=152" "xid=77"
+--replace_result "xid=155" "xid=78"
 show binlog events from 102;
 
 delete from t1;
@@ -172,7 +175,7 @@
 commit;
 
 --replace_column 5 #
---replace_result "xid=184" "xid=93"
+--replace_result "xid=187" "xid=94"
 show binlog events from 102;
 
 delete from t1;
@@ -190,7 +193,7 @@
 select a from t1 order by a; # check that savepoints work :)
 
 --replace_column 5 #
---replace_result "xid=205" "xid=104"
+--replace_result "xid=208" "xid=105"
 show binlog events from 102;
 
 # Test for BUG#5714, where a MyISAM update in the transaction used to

--- 1.8/mysql-test/t/mysqlbinlog2.test	2005-04-09 02:40:59 +10:00
+++ 1.9/mysql-test/t/mysqlbinlog2.test	2005-04-14 22:19:33 +10:00
@@ -1,6 +1,9 @@
 # Test for the new options --start-datetime, stop-datetime,
 # and a few others.
 
+# Embedded server doesn't support binlogging
+-- source include/not_embedded.inc
+
 --disable_warnings
 drop table if exists t1;
 --enable_warnings

--- 1.25/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2005-04-06 02:18:05 +10:00
+++ 1.26/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2005-04-14 22:19:34 +10:00
@@ -69,6 +69,9 @@
 #include <signaldata/FsOpenReq.hpp>
 #include <DebuggerNames.hpp>
 
+#include <EventLogger.hpp>
+extern EventLogger g_eventLogger;
+
 #define SYSFILE ((Sysfile *)&sysfileData[0])
 
 #define RETURN_IF_NODE_NOT_ALIVE(node) \
@@ -13128,6 +13131,48 @@
 	}
       }
     }
+  }
+
+  if(dumpState->args[0] == 7019 && signal->getLength() == 2)
+  {
+    char buf2[8+1];
+    NodeRecordPtr nodePtr;
+    nodePtr.i = signal->theData[1];
+    ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
+    infoEvent("NF Node %d tc: %d lqh: %d dih: %d dict: %d recNODE_FAILREP: %d",
+	      nodePtr.i,
+	      nodePtr.p->dbtcFailCompleted,
+	      nodePtr.p->dblqhFailCompleted,
+	      nodePtr.p->dbdihFailCompleted,
+	      nodePtr.p->dbdictFailCompleted,
+	      nodePtr.p->recNODE_FAILREP);
+    infoEvent(" m_NF_COMPLETE_REP: %s m_nodefailSteps: %s",
+	      nodePtr.p->m_NF_COMPLETE_REP.getText(),
+	      nodePtr.p->m_nodefailSteps.getText(buf2));
+  }
+  
+  if(dumpState->args[0] == 7020 && signal->getLength() > 3)
+  {
+    Uint32 gsn= signal->theData[1];
+    Uint32 block= signal->theData[2];
+    Uint32 length= signal->length() - 3;
+    memmove(signal->theData, signal->theData+3, 4*length);
+    sendSignal(numberToRef(block, getOwnNodeId()), gsn, signal, length, JBB);
+    
+    warningEvent("-- SENDING CUSTOM SIGNAL --");
+    char buf[100], buf2[100];
+    buf2[0]= 0;
+    for(Uint32 i = 0; i<length; i++)
+    {
+      snprintf(buf, 100, "%s %.8x", buf2, signal->theData[i]);
+      snprintf(buf2, 100, "%s", buf);
+    }
+    warningEvent("gsn: %d block: %s, length: %d theData: %s", 
+		 gsn, getBlockName(block, "UNKNOWN"), length, buf);
+
+    g_eventLogger.warning("-- SENDING CUSTOM SIGNAL --");
+    g_eventLogger.warning("gsn: %d block: %s, length: %d theData: %s", 
+			  gsn, getBlockName(block, "UNKNOWN"), length, buf);
   }
   
   if(dumpState->args[0] == DumpStateOrd::DihDumpLCPState){

--- 1.72/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-04-11 22:31:10 +10:00
+++ 1.73/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-04-14 22:42:58 +10:00
@@ -4689,7 +4689,8 @@
     commitConf->transId1 = regApiPtr->transid[0];
     commitConf->transId2 = regApiPtr->transid[1];
     commitConf->gci = regApiPtr->globalcheckpointid;
-    sendSignal(regApiPtr->ndbapiBlockref, GSN_TC_COMMITCONF, signal, 
+
+    sendSignal(regApiPtr->ndbapiBlockref, GSN_TC_COMMITCONF, signal,
 	       TcCommitConf::SignalLength, JBB);
   } else if (regApiPtr->returnsignal == RS_NO_RETURN) {
     jam();

--- 1.21/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2005-03-22 07:59:41 +11:00
+++ 1.22/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2005-04-14 22:19:35 +10:00
@@ -64,6 +64,7 @@
 // DbtupSystemRestart.cpp 26000
 // DbtupIndex.cpp         28000
 // DbtupDebug.cpp         30000
+// DbtupScan.cpp          32000
 //------------------------------------------------------------------
 
 /*
@@ -512,6 +513,49 @@
 };
 typedef Ptr<Fragoperrec> FragoperrecPtr;
 
+  // Position for use by scan
+  struct PagePos {
+    Uint32 m_fragId;            // "base" fragment id
+    Uint32 m_fragBit;           // two fragments in 5.0
+    Uint32 m_pageId;
+    Uint32 m_tupleNo;
+    bool m_match;
+  };
+
+  // Tup scan op (compare Dbtux::ScanOp)
+  struct ScanOp {
+    enum {
+      Undef = 0,
+      First = 1,                // before first entry
+      Locked = 4,               // at current entry (no lock needed)
+      Next = 5,                 // looking for next extry
+      Last = 6,                 // after last entry
+      Invalid = 9               // cannot return REF to LQH currently
+    };
+    Uint16 m_state;
+    Uint16 m_lockwait;          // unused
+    Uint32 m_userPtr;           // scanptr.i in LQH
+    Uint32 m_userRef;
+    Uint32 m_tableId;
+    Uint32 m_fragId;            // "base" fragment id
+    Uint32 m_fragPtrI[2];
+    Uint32 m_transId1;
+    Uint32 m_transId2;
+    PagePos m_scanPos;
+    union {
+    Uint32 nextPool;
+    Uint32 nextList;
+    };
+    Uint32 prevList;
+  };
+  typedef Ptr<ScanOp> ScanOpPtr;
+  ArrayPool<ScanOp> c_scanOpPool;
+
+  void scanFirst(Signal* signal, ScanOpPtr scanPtr);
+  void scanNext(Signal* signal, ScanOpPtr scanPtr);
+  void scanClose(Signal* signal, ScanOpPtr scanPtr);
+  void releaseScanOp(ScanOpPtr& scanPtr);
+
 struct Fragrecord {
   Uint32 nextStartRange;
   Uint32 currentPageRange;
@@ -533,6 +577,9 @@
   Uint32 fragTableId;
   Uint32 fragmentId;
   Uint32 nextfreefrag;
+
+  DLList<ScanOp> m_scanList;
+  Fragrecord(ArrayPool<ScanOp> & scanOpPool) : m_scanList(scanOpPool) {}
 };
 typedef Ptr<Fragrecord> FragrecordPtr;
 
@@ -1084,6 +1131,11 @@
   void execBUILDINDXREQ(Signal* signal);
   void buildIndex(Signal* signal, Uint32 buildPtrI);
   void buildIndexReply(Signal* signal, const BuildIndexRec* buildRec);
+
+  // Tup scan
+  void execACC_SCANREQ(Signal* signal);
+  void execNEXT_SCANREQ(Signal* signal);
+  void execACC_CHECK_SCAN(Signal* signal);
 
 //------------------------------------------------------------------
 //------------------------------------------------------------------

--- 1.14/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp	2005-03-10 18:57:29 +11:00
+++ 1.15/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp	2005-04-14 22:19:37 +10:00
@@ -76,7 +76,6 @@
   { BACKUP_REF,  1 , 10000, 10999 },
   { DBUTIL_REF,  1 , 11000, 11999 },
   { SUMA_REF,    1 , 13000, 13999 },
-  { GREP_REF,    1 ,     0,     0 },
   { DBTUX_REF,   1 , 12000, 12999 }
 };
 
@@ -1451,9 +1450,6 @@
 	     NodeFailRep::SignalLength, JBB);
 
   sendSignal(SUMA_REF, GSN_NODE_FAILREP, signal,
-	     NodeFailRep::SignalLength, JBB);
-
-  sendSignal(GREP_REF, GSN_NODE_FAILREP, signal,
 	     NodeFailRep::SignalLength, JBB);
 
   Uint32 nodeId = 0;

--- 1.74/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-03-22 07:59:42 +11:00
+++ 1.75/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-04-14 22:19:38 +10:00
@@ -2077,7 +2077,7 @@
 }
 
 void
-MgmtSrvr::handleStatus(NodeId nodeId, bool alive)
+MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete)
 {
   DBUG_ENTER("MgmtSrvr::handleStatus");
   Uint32 theData[25];
@@ -2086,9 +2086,14 @@
     m_started_nodes.push_back(nodeId);
     theData[0] = NDB_LE_Connected;
   } else {
-    handleStopReply(nodeId, 0);
     theData[0] = NDB_LE_Disconnected;
+    if(nfComplete)
+    {
+      handleStopReply(nodeId, 0);
+      DBUG_VOID_RETURN;
+    }
   }
+  
   eventReport(_ownNodeId, theData);
   DBUG_VOID_RETURN;
 }
@@ -2113,8 +2118,7 @@
 {
   DBUG_ENTER("MgmtSrvr::nodeStatusNotification");
   DBUG_PRINT("enter",("nodeid= %d, alive= %d, nfComplete= %d", nodeId, alive,
nfComplete));
-  if(!(!alive && nfComplete))
-    ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive);
+  ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive, nfComplete);
   DBUG_VOID_RETURN;
 }
 

--- 1.54/ndb/src/ndbapi/Ndb.cpp	2005-04-07 10:31:23 +10:00
+++ 1.55/ndb/src/ndbapi/Ndb.cpp	2005-04-14 22:19:38 +10:00
@@ -757,26 +757,28 @@
 Uint64
 Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize)
 {
-  DEBUG_TRACE("getAutoIncrementValue");
+  DBUG_ENTER("getAutoIncrementValue");
   const char * internalTableName = internalizeTableName(aTableName);
   Ndb_local_table_info *info=
     theDictionary->get_local_table_info(internalTableName, false);
   if (info == 0)
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   const NdbTableImpl *table= info->m_table_impl;
   Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64
 Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize)
 {
-  DEBUG_TRACE("getAutoIncrementValue");
+  DBUG_ENTER("getAutoIncrementValue");
   if (aTable == 0)
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
   Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64 
@@ -784,46 +786,52 @@
 {
   const NdbTableImpl* table = theDictionary->getTable(aTableName);
   if (table == 0)
-    return ~0;
+    return ~(Uint64)0;
   return getTupleIdFromNdb(table->m_tableId, cacheSize);
 }
 
 Uint64
 Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize)
 {
+  DBUG_ENTER("getTupleIdFromNdb");
   if ( theFirstTupleId[aTableId] != theLastTupleId[aTableId] )
   {
     theFirstTupleId[aTableId]++;
-    return theFirstTupleId[aTableId];
+    DBUG_PRINT("info", ("next cached value %u", theFirstTupleId[aTableId]));
+    DBUG_RETURN(theFirstTupleId[aTableId]);
   }
   else // theFirstTupleId == theLastTupleId
   {
-    return opTupleIdOnNdb(aTableId, cacheSize, 0);
+    DBUG_PRINT("info",("reading %u values from database", 
+                       (cacheSize == 0) ? 1 : cacheSize));
+    DBUG_RETURN(opTupleIdOnNdb(aTableId, (cacheSize == 0) ? 1 : cacheSize, 0));
   }
 }
 
 Uint64
 Ndb::readAutoIncrementValue(const char* aTableName)
 {
-  DEBUG_TRACE("readtAutoIncrementValue");
+  DBUG_ENTER("readtAutoIncrementValue");
   const NdbTableImpl* table = theDictionary->getTable(aTableName);
   if (table == 0) {
     theError= theDictionary->getNdbError();
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   }
   Uint64 tupleId = readTupleIdFromNdb(table->m_tableId);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64
 Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
 {
-  DEBUG_TRACE("readtAutoIncrementValue");
+  DBUG_ENTER("readtAutoIncrementValue");
   if (aTable == 0)
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
   Uint64 tupleId = readTupleIdFromNdb(table->m_tableId);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64
@@ -856,7 +864,7 @@
 {
   DEBUG_TRACE("setAutoIncrementValue " << val);
   if (aTable == 0)
-    return ~0;
+    return ~(Uint64)0;
   const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
   return setTupleIdInNdb(table->m_tableId, val, increase);
 }
@@ -1011,7 +1019,7 @@
              theError.code,
              tConnection ? tConnection->theError.code : -1,
              tOperation ? tOperation->theError.code : -1));
-  DBUG_RETURN(~0);
+  DBUG_RETURN(~(Uint64)0);
 }
 
 Uint32

--- 1.8/ndb/test/include/HugoTransactions.hpp	2005-04-05 04:16:20 +10:00
+++ 1.9/ndb/test/include/HugoTransactions.hpp	2005-04-14 22:19:39 +10:00
@@ -39,7 +39,8 @@
 		      int records,
 		      int abort = 0,
 		      int parallelism = 0,
-		      NdbOperation::LockMode = NdbOperation::LM_Read);
+		      NdbOperation::LockMode = NdbOperation::LM_Read,
+                      int scan_flags = 0);
 
   int scanReadRecords(Ndb*, 
 		      const NdbDictionary::Index*,
@@ -47,7 +48,7 @@
 		      int abort = 0,
 		      int parallelism = 0,
 		      NdbOperation::LockMode = NdbOperation::LM_Read,
-		      bool sorted = false);
+                      int scan_flags = 0);
 
   int pkReadRecords(Ndb*, 
 		    int records,

--- 1.18/ndb/test/src/HugoOperations.cpp	2005-04-05 04:16:21 +10:00
+++ 1.19/ndb/test/src/HugoOperations.cpp	2005-04-14 22:19:39 +10:00
@@ -613,7 +613,7 @@
   if(!pOp)
     return -1;
 
-  if(pOp->readTuples(lm, 1, 1)){
+  if(pOp->readTuples(lm, 0, 1)){
     return -1;
   }
   

--- 1.25/ndb/test/src/HugoTransactions.cpp	2005-04-05 04:16:21 +10:00
+++ 1.26/ndb/test/src/HugoTransactions.cpp	2005-04-14 22:19:40 +10:00
@@ -36,7 +36,8 @@
 				  int records,
 				  int abortPercent,
 				  int parallelism, 
-				  NdbOperation::LockMode lm)
+				  NdbOperation::LockMode lm,
+                                  int scan_flags)
 {
   
   int                  retryAttempt = 0;
@@ -72,7 +73,7 @@
       return NDBT_FAILED;
     }
 
-    if( pOp ->readTuples(lm, 0, parallelism) ) {
+    if( pOp ->readTuples(lm, scan_flags, parallelism) ) {
       ERR(pTrans->getNdbError());
       closeTransaction(pNdb);
       return NDBT_FAILED;
@@ -187,7 +188,7 @@
 				  int abortPercent,
 				  int parallelism, 
 				  NdbOperation::LockMode lm,
-				  bool sorted)
+                                  int scan_flags)
 {
   
   int                  retryAttempt = 0;
@@ -223,7 +224,7 @@
       return NDBT_FAILED;
     }
 
-    if( pOp ->readTuples(lm, 0, parallelism, sorted) ) {
+    if( pOp ->readTuples(lm, scan_flags, parallelism) ) {
       ERR(pTrans->getNdbError());
       closeTransaction(pNdb);
       return NDBT_FAILED;

--- 1.204/sql/ha_ndbcluster.cc	2005-04-14 18:19:27 +10:00
+++ 1.205/sql/ha_ndbcluster.cc	2005-04-14 22:19:42 +10:00
@@ -217,7 +217,6 @@
   { 4244, HA_ERR_TABLE_EXIST, 1 },
 
   { 709, HA_ERR_NO_SUCH_TABLE, 0 },
-  { 284, HA_ERR_NO_SUCH_TABLE, 1 },
 
   { 266, HA_ERR_LOCK_WAIT_TIMEOUT, 1 },
   { 274, HA_ERR_LOCK_WAIT_TIMEOUT, 1 },
@@ -232,6 +231,8 @@
   { 827, HA_ERR_RECORD_FILE_FULL, 1 },
   { 832, HA_ERR_RECORD_FILE_FULL, 1 },
 
+  { 284, HA_ERR_TABLE_DEF_CHANGED, 0 },
+
   { 0, 1, 0 },
 
   { -1, -1, 1 }
@@ -542,13 +543,31 @@
 int ha_ndbcluster::ndb_err(NdbTransaction *trans)
 {
   int res;
-  const NdbError err= trans->getNdbError();
+  NdbError err= trans->getNdbError();
   DBUG_ENTER("ndb_err");
   
   ERR_PRINT(err);
   switch (err.classification) {
   case NdbError::SchemaError:
     invalidateDictionaryCache();
+
+    if (err.code==284)
+    {
+      /*
+         Check if the table is _really_ gone or if the table has
+         been alterend and thus changed table id
+       */
+      NDBDICT *dict= get_ndb()->getDictionary();
+      DBUG_PRINT("info", ("Check if table %s is really gone", m_tabname));
+      if (!(dict->getTable(m_tabname)))
+      {
+        err= dict->getNdbError();
+        DBUG_PRINT("info", ("Table not found, error: %d", err.code));
+        if (err.code != 709)
+          DBUG_RETURN(1);
+      }
+      DBUG_PRINT("info", ("Table exists but must have changed"));
+    }
     break;
   default:
     break;
@@ -2013,8 +2032,12 @@
 
     if (has_auto_increment) 
     {
+      THD *thd= table->in_use;
+
       m_skip_auto_increment= FALSE;
       update_auto_increment();
+      /* Ensure that handler is always called for auto_increment values */
+      thd->next_insert_id= 0;
       m_skip_auto_increment= !auto_increment_column_changed;
     }
 
@@ -2047,7 +2070,7 @@
   m_rows_inserted++;
   no_uncommitted_rows_update(1);
   m_bulk_insert_not_flushed= TRUE;
-  if ((m_rows_to_insert == 1) || 
+  if ((m_rows_to_insert == (ha_rows) 1) || 
       ((m_rows_inserted % m_bulk_insert_rows) == 0) ||
       set_blob_value)
   {
@@ -2147,7 +2170,11 @@
   
   statistic_increment(thd->status_var.ha_update_count, &LOCK_status);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
+  {
     table->timestamp_field->set_time();
+    // Set query_id so that field is really updated
+    table->timestamp_field->query_id= thd->query_id;
+  }
 
   /* Check for update of primary key for special handling */  
   if ((table->s->primary_key != MAX_KEY) &&
@@ -2758,7 +2785,7 @@
     m_ops_pending= 0;
   }
   
-  cursor->close(m_force_send);
+  cursor->close(m_force_send, true);
   m_active_cursor= m_multi_cursor= NULL;
   DBUG_RETURN(0);
 }
@@ -3065,8 +3092,12 @@
   DBUG_ENTER("start_bulk_insert");
   DBUG_PRINT("enter", ("rows: %d", (int)rows));
   
-  m_rows_inserted= 0;
-  m_rows_to_insert= rows; 
+  m_rows_inserted= (ha_rows) 0;
+  if (rows == (ha_rows) 0)
+    /* We don't know how many will be inserted, guess */
+    m_rows_to_insert= m_autoincrement_prefetch;
+  else
+    m_rows_to_insert= rows; 
 
   /* 
     Calculate how many rows that should be inserted
@@ -3100,7 +3131,7 @@
     // Send rows to NDB
     DBUG_PRINT("info", ("Sending inserts to NDB, "\
                         "rows_inserted:%d, bulk_insert_rows: %d", 
-                        m_rows_inserted, m_bulk_insert_rows)); 
+                        (int) m_rows_inserted, (int) m_bulk_insert_rows)); 
     m_bulk_insert_not_flushed= FALSE;
     if (execute_no_commit(this,trans) != 0) {
       no_uncommitted_rows_execute_failure();
@@ -3108,8 +3139,8 @@
     }
   }
 
-  m_rows_inserted= 0;
-  m_rows_to_insert= 1;
+  m_rows_inserted= (ha_rows) 0;
+  m_rows_to_insert= (ha_rows) 1;
   DBUG_RETURN(error);
 }
 
@@ -3291,7 +3322,8 @@
     // store thread specific data first to set the right context
     m_force_send=          thd->variables.ndb_force_send;
     m_ha_not_exact_count= !thd->variables.ndb_use_exact_count;
-    m_autoincrement_prefetch= thd->variables.ndb_autoincrement_prefetch_sz;
+    m_autoincrement_prefetch= 
+      (ha_rows) thd->variables.ndb_autoincrement_prefetch_sz;
     if (!thd->transaction.on)
       m_transaction_on= FALSE;
     else
@@ -3816,7 +3848,7 @@
 
 static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length)
 {
-  if (form->s->max_rows == 0) /* default setting, don't set fragmentation */
+  if (form->s->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation
*/
     return;
   /**
    * get the number of fragments right
@@ -4424,7 +4456,12 @@
   DBUG_ENTER("get_auto_increment");
   DBUG_PRINT("enter", ("m_tabname: %s", m_tabname));
   Ndb *ndb= get_ndb();
+   
+  if (m_rows_inserted > m_rows_to_insert)
+    /* We guessed too low */
+    m_rows_to_insert+= m_autoincrement_prefetch;
   cache_size= 
+    (int)
     (m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ?
     m_rows_to_insert - m_rows_inserted 
     : (m_rows_to_insert > m_autoincrement_prefetch) ? 
@@ -4464,10 +4501,10 @@
   m_primary_key_update(FALSE),
   m_retrieve_all_fields(FALSE),
   m_retrieve_primary_key(FALSE),
-  m_rows_to_insert(1),
-  m_rows_inserted(0),
-  m_bulk_insert_rows(1024),
-  m_rows_changed(0),
+  m_rows_to_insert((ha_rows) 1),
+  m_rows_inserted((ha_rows) 0),
+  m_bulk_insert_rows((ha_rows) 1024),
+  m_rows_changed((ha_rows) 0),
   m_bulk_insert_not_flushed(FALSE),
   m_ops_pending(0),
   m_skip_auto_increment(TRUE),
@@ -4477,7 +4514,7 @@
   m_dupkey((uint) -1),
   m_ha_not_exact_count(FALSE),
   m_force_send(TRUE),
-  m_autoincrement_prefetch(32),
+  m_autoincrement_prefetch((ha_rows) 32),
   m_transaction_on(TRUE),
   m_cond_stack(NULL),
   m_multi_cursor(NULL)
@@ -6182,7 +6219,7 @@
 close_scan:
     if (res == 1)
     {
-      m_multi_cursor->close();
+      m_multi_cursor->close(false, true);
       m_active_cursor= m_multi_cursor= 0;
       DBUG_MULTI_RANGE(8);
       continue;
@@ -6322,6 +6359,7 @@
   {
     thd->cleanup();
     delete thd;
+    delete ndb;
     DBUG_RETURN(NULL);
   }
 
@@ -6436,6 +6474,7 @@
 
   thd->cleanup();
   delete thd;
+  delete ndb;
   DBUG_PRINT("exit", ("ndb_util_thread"));
   my_thread_end();
   pthread_exit(0);

--- 1.106/mysql-test/r/innodb.result	2005-04-09 02:40:59 +10:00
+++ 1.107/mysql-test/r/innodb.result	2005-04-14 22:19:31 +10:00
@@ -1437,18 +1437,6 @@
 3524	Societe Test
 3525	Fournisseur Test
 drop table t1,t2;
-create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
-select * from t1;
-c1	c2	stamp
-replace delayed into t1 (c1, c2)  values ( "text1","11"),( "text2","12");
-ERROR HY000: Table storage engine for 't1' doesn't have this option
-select * from t1;
-c1	c2	stamp
-replace delayed into t1 (c1, c2)  values ( "text1","12"),( "text2","13"),( "text3","14",
"a" ),( "text4","15", "b" );
-ERROR HY000: Table storage engine for 't1' doesn't have this option
-select * from t1;
-c1	c2	stamp
-drop table t1;
 create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
 create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
 create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
@@ -1618,7 +1606,7 @@
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
 drop table t2;
 create table t2 (id int(11) not null, id2 int(11) not null, constraint t1_id_fk foreign
key (id2,id) references t1 (id)) engine = innodb;
-ERROR HY000: Can't create table './test/t2.frm' (errno: 150)
+ERROR HY000: Can't create table './test/t2' (errno: 150)
 create table t2 (a int auto_increment primary key, b int, index(b), foreign key (b)
references t1(id), unique(b)) engine=innodb;
 show create table t2;
 Table	Create Table
@@ -2372,7 +2360,7 @@
 65530
 drop table t1;
 create table t1 (v varchar(65530), key(v));
-ERROR HY000: Can't create table './test/t1.frm' (errno: 139)
+ERROR HY000: Can't create table './test/t1' (errno: 139)
 create table t1 (v varchar(65536));
 Warnings:
 Note	1246	Converting column 'v' from VARCHAR to TEXT
@@ -2394,5 +2382,3 @@
 set storage_engine=MyISAM;
 create table t1 (v varchar(16384)) engine=innodb;
 drop table t1;
-create table t1 (a bit, key(a)) engine=innodb;
-ERROR 42000: The storage engine for the table doesn't support BIT FIELD

--- 1.30/mysql-test/r/insert_select.result	2005-04-01 21:32:19 +10:00
+++ 1.31/mysql-test/r/insert_select.result	2005-04-14 22:19:31 +10:00
@@ -65,31 +65,6 @@
 SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2
 WHERE numeropost=9 ORDER BY numreponse ASC;
 DROP TABLE t1,t2;
-create table t1(a int, unique(a));
-insert into t1 values(2);
-create table t2(a int);
-insert into t2 values(1),(2);
-reset master;
-insert into t1 select * from t2;
-ERROR 23000: Duplicate entry '2' for key 1
-show binlog events;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Format_desc	1	#	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	#	Query	1	#	use `test`; insert into t1 select * from t2
-select * from t1;
-a
-1
-2
-drop table t1, t2;
-create table t1(a int);
-insert into t1 values(1),(1);
-reset master;
-create table t2(unique(a)) select a from t1;
-ERROR 23000: Duplicate entry '1' for key 1
-show binlog events;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Format_desc	1	#	Server ver: VERSION, Binlog ver: 4
-drop table t1;
 create table t1 (a int not null);
 create table t2 (a int not null);
 insert into t1 values (1);

--- 1.65/mysql-test/r/show_check.result	2005-04-08 21:30:49 +10:00
+++ 1.66/mysql-test/r/show_check.result	2005-04-14 22:19:32 +10:00
@@ -196,7 +196,7 @@
 i	float(3,0)	NULL	YES		NULL		select,insert,update,references	
 drop table t1;
 create table t1 (
-type_bool bool not null,
+type_bool bool not null default 0,
 type_tiny tinyint not null auto_increment primary key,
 type_short smallint(3),
 type_mediumint mediumint,
@@ -207,9 +207,9 @@
 type_char char(2),
 type_varchar varchar(10),
 type_timestamp timestamp not null,
-type_date date not null,
-type_time time not null,
-type_datetime datetime not null,
+type_date date not null default '0000-00-00',
+type_time time not null default '00:00:00',
+type_datetime datetime not null default '0000-00-00 00:00:00',
 type_year year,
 type_enum enum ('red', 'green', 'blue'),
 type_set enum ('red', 'green', 'blue'),
@@ -222,7 +222,7 @@
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `type_bool` tinyint(1) NOT NULL,
+  `type_bool` tinyint(1) NOT NULL default '0',
   `type_tiny` tinyint(4) NOT NULL auto_increment,
   `type_short` smallint(3) default NULL,
   `type_mediumint` mediumint(9) default NULL,
@@ -233,9 +233,9 @@
   `type_char` char(2) default NULL,
   `type_varchar` varchar(10) default NULL,
   `type_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
-  `type_date` date NOT NULL,
-  `type_time` time NOT NULL,
-  `type_datetime` datetime NOT NULL,
+  `type_date` date NOT NULL default '0000-00-00',
+  `type_time` time NOT NULL default '00:00:00',
+  `type_datetime` datetime NOT NULL default '0000-00-00 00:00:00',
   `type_year` year(4) default NULL,
   `type_enum` enum('red','green','blue') default NULL,
   `type_set` enum('red','green','blue') default NULL,

--- 1.103/sql/set_var.cc	2005-04-05 21:17:40 +10:00
+++ 1.104/sql/set_var.cc	2005-04-14 22:19:45 +10:00
@@ -734,6 +734,7 @@
   {"bdb_tmpdir",              (char*) &berkeley_tmpdir,             SHOW_CHAR_PTR},
 #endif
   {sys_binlog_cache_size.name,(char*) &sys_binlog_cache_size,	    SHOW_SYS},
+  {"binlog_format",           (char*) &opt_binlog_format,           SHOW_CHAR_PTR},
   {sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS},
   {sys_character_set_client.name,(char*) &sys_character_set_client, SHOW_SYS},
   {sys_character_set_connection.name,(char*) &sys_character_set_connection,SHOW_SYS},

--- 1.73/sql/sp.cc	2005-04-01 21:32:30 +10:00
+++ 1.74/sql/sp.cc	2005-04-14 22:19:45 +10:00
@@ -64,34 +64,18 @@
 		    enum thr_lock_type ltype, TABLE **tablep, bool *opened)
 {
   TABLE *table;
-  byte key[64+64+1];		// db, name, type
-  uint keylen;
+  byte key[NAME_LEN*2+4+1];	// db, name, optional key length type
   DBUG_ENTER("db_find_routine_aux");
   DBUG_PRINT("enter", ("type: %d name: %*s",
 		       type, name->m_name.length, name->m_name.str));
 
   /*
-    Speed up things if mysql.proc doesn't exists
-    mysql_proc_table_exists is set when on creates a stored procedure
-    or on flush privileges
+    Speed up things if mysql.proc doesn't exists. mysql_proc_table_exists
+    is set when we create or read stored procedure or on flush privileges.
   */
   if (!mysql_proc_table_exists && ltype == TL_READ)
     DBUG_RETURN(SP_OPEN_TABLE_FAILED);
 
-  // Put the key used to read the row together
-  keylen= name->m_db.length;
-  if (keylen > 64)
-    keylen= 64;
-  memcpy(key, name->m_db.str, keylen);
-  memset(key+keylen, (int)' ', 64-keylen); // Pad with space
-  keylen= name->m_name.length;
-  if (keylen > 64)
-    keylen= 64;
-  memcpy(key+64, name->m_name.str, keylen);
-  memset(key+64+keylen, (int)' ', 64-keylen); // Pad with space
-  key[128]= type;
-  keylen= sizeof(key);
-
   if (thd->lex->proc_table)
     table= thd->lex->proc_table->table;
   else
@@ -113,15 +97,35 @@
     if (! (table= open_ltable(thd, &tables, ltype)))
     {
       *tablep= NULL;
-      mysql_proc_table_exists= 0;
+      /*
+        Under explicit LOCK TABLES or in prelocked mode we should not
+        say that mysql.proc table does not exist if we are unable to
+        open it since this condition may be transient.
+      */
+      if (!(thd->locked_tables || thd->prelocked_mode))
+        mysql_proc_table_exists= 0;
       DBUG_RETURN(SP_OPEN_TABLE_FAILED);
     }
     *opened= TRUE;
   }
   mysql_proc_table_exists= 1;
 
+  /*
+    Create key to find row. We have to use field->store() to be able to
+    handle VARCHAR and CHAR fields.
+    Assumption here is that the three first fields in the table are
+    'db', 'name' and 'type' and the first key is the primary key over the
+    same fields.
+  */
+  table->field[0]->store(name->m_db.str, name->m_db.length,
&my_charset_bin);
+  table->field[1]->store(name->m_name.str, name->m_name.length,
+                         &my_charset_bin);
+  table->field[2]->store((longlong) type);
+  key_copy(key, table->record[0], table->key_info,
+           table->key_info->key_length);
+
   if (table->file->index_read_idx(table->record[0], 0,
-				  key, keylen,
+				  key, table->key_info->key_length,
 				  HA_READ_KEY_EXACT))
   {
     *tablep= NULL;

--- 1.26/mysql-test/r/drop.result	2005-03-22 09:26:17 +11:00
+++ 1.27/mysql-test/r/drop.result	2005-04-14 22:19:30 +10:00
@@ -24,6 +24,20 @@
 drop database if exists mysqltest;
 affected rows: 1
 create database mysqltest;
+use mysqltest;
+drop table table1, table2, table3, table4, table5, table6,
+table7, table8, table9, table10, table11, table12, table13,
+table14, table15, table16, table17, table18, table19, table20,
+table21, table22, table23, table24, table25, table26, table27,
+table28;
+ERROR 42S02: Unknown table
'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
+drop table table1, table2, table3, table4, table5, table6,
+table7, table8, table9, table10, table11, table12, table13,
+table14, table15, table16, table17, table18, table19, table20,
+table21, table22, table23, table24, table25, table26, table27,
+table28, table29, table30;
+ERROR 42S02: Unknown table
'table1,table2,table3,table4,table5,table6,table7,table8,table9,table10,table11,table12,table13,table'
+use test;
 drop database mysqltest;
 flush tables with read lock;
 create database mysqltest;

--- 1.33/mysql-test/r/user_var.result	2005-04-09 02:40:59 +10:00
+++ 1.34/mysql-test/r/user_var.result	2005-04-14 22:42:58 +10:00
@@ -168,38 +168,7 @@
 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci;
 (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci
 1
-create table t1 (a varchar(50));
-reset master;
-SET TIMESTAMP=10000;
-SET @`a b`='hello';
-INSERT INTO t1 VALUES(@`a b`);
-set @var1= "';aaa";
-SET @var2=char(ascii('a'));
-insert into t1 values (@var1),(@var2);
 show binlog events from 102;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	User var	1	#	@`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci
-master-bin.000001	#	Query	1	#	use `test`; INSERT INTO t1 VALUES(@`a b`)
-master-bin.000001	#	User var	1	#	@`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci
-master-bin.000001	#	User var	1	#	@`var2`=_latin1 0x61 COLLATE latin1_swedish_ci
-master-bin.000001	#	Query	1	#	use `test`; insert into t1 values (@var1),(@var2)
-/*!40019 SET @@session.max_insert_delayed_threads=0*/;
-/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-ROLLBACK;
-SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`;
-use test;
-SET TIMESTAMP=10000;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1,
@@session.unique_checks=1;
-SET @@session.sql_mode=0;
-SET
@@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8;
-INSERT INTO t1 VALUES(@`a b`);
-SET @`var1`:=_latin1 0x273B616161 COLLATE `latin1_swedish_ci`;
-SET @`var2`:=_latin1 0x61 COLLATE `latin1_swedish_ci`;
-SET TIMESTAMP=10000;
-insert into t1 values (@var1),(@var2);
-ROLLBACK;
-/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-drop table t1;
 set @var= NULL ;
 select FIELD( @var,'1it','Hit') as my_column;
 my_column
@@ -211,3 +180,6 @@
 select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
 coercibility(@v1)	coercibility(@v2)	coercibility(@v3)	coercibility(@v4)
 2	2	2	2
+set session @honk=99;
+set one_shot @honk=99;
+ERROR HY000: The 'SET ONE_SHOT' syntax is reserved for purposes internal to the MySQL
server

--- 1.26/mysql-test/t/user_var.test	2005-04-08 21:30:49 +10:00
+++ 1.27/mysql-test/t/user_var.test	2005-04-14 22:42:58 +10:00
@@ -99,25 +99,7 @@
 select charset(@a),collation(@a),coercibility(@a);
 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci;
 
-# Check that user variables are binlogged correctly (BUG#3875)
-create table t1 (a varchar(50));
-reset master;
-SET TIMESTAMP=10000;
-SET @`a b`='hello';
-INSERT INTO t1 VALUES(@`a b`);
-set @var1= "';aaa";
-SET @var2=char(ascii('a'));
-insert into t1 values (@var1),(@var2);
---replace_column 2 # 5 #
 show binlog events from 102;
-# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
-# absolutely need variables names to be quoted and strings to be
-# escaped).
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 
-drop table t1;
-
-
 #
 # Bug #6321 strange error:
 #   string function FIELD(<uservariable content NULL>, ...)
@@ -131,3 +113,10 @@
 select @v, coercibility(@v);
 set @v1=null, @v2=1, @v3=1.1, @v4=now();
 select coercibility(@v1),coercibility(@v2),coercibility(@v3),coercibility(@v4);
+
+#
+# Bug #9286  SESSION/GLOBAL should be disallowed for user variables
+#
+set session @honk=99;
+--error 1382
+set one_shot @honk=99;
Thread
bk commit into 5.1 tree (stewart:1.1796)Stewart Smith14 Apr