List:Internals« Previous MessageNext Message »
From:tomas Date:May 10 2005 2:16am
Subject:bk commit into 5.1 tree (tomas:1.1837)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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.1837 05/05/10 04:16:09 tomas@stripped +20 -0
  Merge

  sql/share/errmsg.txt
    1.17 05/05/10 04:16:05 tomas@stripped +0 -0
    SCCS merged

  sql/unireg.cc
    1.55 05/05/10 04:12:24 tomas@stripped +0 -0
    Auto merged

  sql/table.h
    1.89 05/05/10 04:12:24 tomas@stripped +0 -0
    Auto merged

  sql/table.cc
    1.152 05/05/10 04:12:23 tomas@stripped +0 -0
    Auto merged

  sql/sql_yacc.yy
    1.343 05/05/10 04:12:23 tomas@stripped +0 -0
    Auto merged

  sql/sql_lex.h
    1.163 05/05/10 04:12:23 tomas@stripped +0 -0
    Auto merged

  sql/sql_base.cc
    1.207 05/05/10 04:12:22 tomas@stripped +0 -0
    Auto merged

  sql/set_var.cc
    1.86 05/05/10 04:12:22 tomas@stripped +0 -0
    Auto merged

  sql/mysqld.cc
    1.421 05/05/10 04:12:21 tomas@stripped +0 -0
    Auto merged

  sql/mysql_priv.h
    1.247 05/05/10 04:12:21 tomas@stripped +0 -0
    Auto merged

  sql/handler.h
    1.131 05/05/10 04:12:21 tomas@stripped +0 -0
    Auto merged

  sql/handler.cc
    1.138 05/05/10 04:12:21 tomas@stripped +0 -0
    Auto merged

  sql/ha_ndbcluster.cc
    1.240 05/05/10 04:12:20 tomas@stripped +0 -0
    Auto merged

  sql/field.h
    1.139 05/05/10 04:12:20 tomas@stripped +0 -0
    Auto merged

  sql/field.cc
    1.224 05/05/10 04:12:20 tomas@stripped +0 -0
    Auto merged

  sql/Makefile.am
    1.104 05/05/10 04:12:19 tomas@stripped +0 -0
    Auto merged

  include/mysql_com.h
    1.96 05/05/10 04:12:19 tomas@stripped +0 -0
    Auto merged

  configure.in
    1.263 05/05/10 04:12:19 tomas@stripped +0 -0
    Auto merged

  BitKeeper/deleted/.del-errmsg.txt~f96b7055cac394e
    1.137 05/05/10 04:12:19 tomas@stripped +0 -0
    Auto merged

  BitKeeper/etc/logging_ok
    1.292 05/05/10 04:11:24 tomas@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:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/wl1354/RESYNC

--- 1.262/configure.in	2005-05-03 12:45:06 +02:00
+++ 1.263/configure.in	2005-05-10 04:12:19 +02:00
@@ -43,6 +43,7 @@
 sinclude(config/ac-macros/ha_federated.m4)
 sinclude(config/ac-macros/ha_innodb.m4)
 sinclude(config/ac-macros/ha_ndbcluster.m4)
+sinclude(config/ac-macros/ha_partition.m4)
 sinclude(config/ac-macros/ha_tina.m4)
 sinclude(config/ac-macros/large_file.m4)
 sinclude(config/ac-macros/misc.m4)
@@ -2434,6 +2435,7 @@
 MYSQL_CHECK_BLACKHOLEDB
 MYSQL_CHECK_NDBCLUSTER
 MYSQL_CHECK_FEDERATED
+MYSQL_CHECK_PARTITIONDB
 
 # If we have threads generate some library functions and test programs
 sql_server_dirs=

--- 1.95/include/mysql_com.h	2005-04-26 07:07:52 +02:00
+++ 1.96/include/mysql_com.h	2005-05-10 04:12:19 +02:00
@@ -49,7 +49,7 @@
   COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
   COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
   COM_PREPARE, COM_EXECUTE, COM_LONG_DATA, COM_CLOSE_STMT,
-  COM_RESET_STMT, COM_SET_OPTION, COM_FETCH,
+  COM_RESET_STMT, COM_SET_OPTION, COM_FETCH, COM_DAEMON,
   /* don't forget to update const char *command_name[] in sql_parse.cc */
 
   /* Must be last */

--- 1.103/sql/Makefile.am	2005-04-26 07:07:52 +02:00
+++ 1.104/sql/Makefile.am	2005-05-10 04:12:19 +02:00
@@ -29,9 +29,9 @@
 noinst_PROGRAMS =	gen_lex_hash
 bin_PROGRAMS =		mysql_tzinfo_to_sql
 gen_lex_hash_LDFLAGS =  @NOINST_LDFLAGS@
-LDADD =			$(top_builddir)/myisam/libmyisam.a \
-			$(top_builddir)/myisammrg/libmyisammrg.a \
-			$(top_builddir)/heap/libheap.a \
+LDADD =			$(top_builddir)/storage/myisam/libmyisam.a \
+			$(top_builddir)/storage/myisammrg/libmyisammrg.a \
+			$(top_builddir)/storage/heap/libheap.a \
 			$(top_builddir)/vio/libvio.a \
 			$(top_builddir)/mysys/libmysys.a \
 			$(top_builddir)/dbug/libdbug.a \
@@ -51,10 +51,12 @@
 			sql_manager.h sql_map.h sql_string.h unireg.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 \
 			ha_ndbcluster.h opt_range.h protocol.h \
 			sql_select.h structs.h table.h sql_udf.h hash_filo.h\
 			lex.h lex_symbol.h sql_acl.h sql_crypt.h  \
+	                bitvector.h \
 			log_event.h sql_repl.h slave.h rpl_filter.h \
 			stacktrace.h sql_sort.h sql_cache.h set_var.h \
 			spatial.h gstream.h client_settings.h tzfile.h \
@@ -83,6 +85,7 @@
 			unireg.cc des_key_file.cc \
 			discover.cc time.cc opt_range.cc opt_sum.cc \
 		   	records.cc filesort.cc handler.cc \
+	                rpl_tblmap.cc rpl_injector.cc \
 		        ha_heap.cc ha_myisam.cc ha_myisammrg.cc \
 	                ha_berkeley.cc ha_innodb.cc \
 			ha_ndbcluster.cc \

--- 1.223/sql/field.cc	2005-04-26 07:07:53 +02:00
+++ 1.224/sql/field.cc	2005-05-10 04:12:20 +02:00
@@ -7267,12 +7267,38 @@
 }
 
 
+int Field_geom::store(double nr)
+{
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -1;
+}
+
+
+int Field_geom::store(longlong nr)
+{
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -1;
+}
+
+
+int Field_geom::store_decimal(const my_decimal *)
+{
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+  return -1;
+}
+
+
 int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
 {
   if (!length)
     bzero(ptr, Field_blob::pack_length());
   else
   {
+    if (from == Geometry::bad_geometry_data.ptr())
+      goto err;
     // Check given WKB
     uint32 wkb_type;
     if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2)
@@ -7280,7 +7306,7 @@
     wkb_type= uint4korr(from + WKB_HEADER_SIZE);
     if (wkb_type < (uint32) Geometry::wkb_point ||
 	wkb_type > (uint32) Geometry::wkb_end)
-      return -1;
+      goto err;
     Field_blob::store_length(length);
     if (table->copy_blobs || length <= MAX_FIELD_WIDTH)
     {						// Must make a copy
@@ -7293,6 +7319,8 @@
 
 err:
   bzero(ptr, Field_blob::pack_length());  
+  my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+             ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
   return -1;
 }
 
@@ -8141,6 +8169,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 +8206,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 +8215,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 +8238,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;
@@ -8367,7 +8423,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.138/sql/field.h	2005-04-26 07:07:53 +02:00
+++ 1.139/sql/field.h	2005-05-10 04:12:20 +02:00
@@ -118,6 +118,7 @@
   String *val_int_as_str(String *val_buffer, my_bool unsigned_flag);
   virtual Item_result result_type () const=0;
   virtual Item_result cmp_type () const { return result_type(); }
+  virtual Item_result cast_to_int_type () const { return result_type(); }
   static enum_field_types field_type_merge(enum_field_types, enum_field_types);
   static Item_result result_merge_type(enum_field_types);
   bool eq(Field *field)
@@ -1189,9 +1190,9 @@
   enum_field_types type() const { return FIELD_TYPE_GEOMETRY; }
   void sql_type(String &str) const;
   int  store(const char *to, uint length, CHARSET_INFO *charset);
-  int  store(double nr) { return 1; }
-  int  store(longlong nr) { return 1; }
-  int  store_decimal(const my_decimal *) { return 1; }
+  int  store(double nr);
+  int  store(longlong nr);
+  int  store_decimal(const my_decimal *);
   void get_key_image(char *buff,uint length,imagetype type);
 };
 #endif /*HAVE_SPATIAL*/
@@ -1216,6 +1217,7 @@
   }
   enum_field_types type() const { return FIELD_TYPE_STRING; }
   enum Item_result cmp_type () const { return INT_RESULT; }
+  enum Item_result cast_to_int_type () const { return INT_RESULT; }
   enum ha_base_keytype key_type() const;
   int  store(const char *to,uint length,CHARSET_INFO *charset);
   int  store(double nr);
@@ -1353,7 +1355,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.137/sql/handler.cc	2005-04-26 07:07:54 +02:00
+++ 1.138/sql/handler.cc	2005-05-10 04:12:21 +02: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
@@ -188,9 +189,10 @@
   thd= current_thd;
   return ((enum db_type) thd->variables.table_type != DB_TYPE_UNKNOWN ?
           (enum db_type) thd->variables.table_type :
-          (enum db_type) global_system_variables.table_type !=
-          DB_TYPE_UNKNOWN ?
-          (enum db_type) global_system_variables.table_type : DB_TYPE_MYISAM);
+          ((enum db_type) global_system_variables.table_type !=
+           DB_TYPE_UNKNOWN ?
+           (enum db_type) global_system_variables.table_type : DB_TYPE_MYISAM)
+          );
 } /* ha_checktype */
 
 
@@ -602,6 +604,7 @@
   my_xid xid= thd->transaction.xid.get_my_xid();
   DBUG_ENTER("ha_commit_trans");
 #ifdef USING_TRANSACTIONS
+  thd->prepare_for_commit(all);
   if (trans->nht)
   {
     if (is_real_trans && wait_if_global_read_lock(thd, 0, 0))
@@ -696,6 +699,7 @@
   bool is_real_trans=all || thd->transaction.all.nht == 0;
   DBUG_ENTER("ha_rollback_trans");
 #ifdef USING_TRANSACTIONS
+  thd->prepare_for_rollback(all);
   if (trans->nht)
   {
     for (handlerton **ht=trans->ht; *ht; ht++)
@@ -1776,16 +1780,19 @@
   return error;
 }
 
-
 int handler::rename_table(const char * from, const char * to)
 {
-  DBUG_ENTER("handler::rename_table");
-  for (const char **ext=bas_ext(); *ext ; ext++)
+  int error= 0;
+  for (const char **ext= bas_ext(); *ext ; ext++)
   {
-    if (rename_file_ext(from,to,*ext))
-      DBUG_RETURN(my_errno);
+    if (rename_file_ext(from, to, *ext))
+    {
+      if ((error=my_errno) != ENOENT)
+	break;
+      error= 0;
+    }
   }
-  DBUG_RETURN(0);
+  return error;
 }
 
 /*
@@ -2418,3 +2425,166 @@
   }
   return &known_extensions;
 }
+
+int handler::
+ha_write_row(byte *buf) 
+{
+  DBUG_ENTER("ha_write_row");
+  DBUG_PRINT("enter", ("table=%p (%s), row=%p", 
+		       table, table->s->table_name, 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) 
+  {
+    int const offset = table->field[i]->offset();
+    DBUG_PRINT("info", ("Field '%s': offset=%d, ptr=%p, query_id=%lu",
+			table->field[i]->field_name,
+			offset,
+			table->field[i]->ptr,
+			table->field[i]->query_id));
+  }
+#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", ("table=%p (%s), before: %p; after: %p", 
+		       table, table->s->table_name, 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", ("table=%p (%s), row=%p", 
+		       table, table->s->table_name, 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);
+}    
+
+#ifdef HAVE_REPLICATION
+/*
+  Reports to table handlers up to which position we have sent the binlog
+  to a slave in replication
+
+  SYNOPSIS
+    ha_repl_report_sent_binlog()
+
+  NOTES
+    Only works for InnoDB at the moment
+
+  RETURN VALUE
+    Always 0 (= success)  
+
+  PARAMETERS
+    THD    *thd             in: thread doing the binlog communication to
+                                the slave
+    char   *log_file_name   in: binlog file name
+    my_off_t end_offset     in: the offset in the binlog file up to
+                                which we sent the contents to the slave
+*/
+
+int ha_repl_report_sent_binlog(THD *thd, char *log_file_name,
+                               my_off_t end_offset)
+{
+#ifdef HAVE_INNOBASE_DB
+  return innobase_repl_report_sent_binlog(thd,log_file_name,end_offset);
+#else
+  /* remove warnings about unused parameters */
+  thd=thd; log_file_name=log_file_name; end_offset=end_offset;
+  return 0;
+#endif
+}
+
+/*
+  Reports to table handlers that we stop replication to a specific slave
+
+  SYNOPSIS
+    ha_repl_report_replication_stop()
+
+  NOTES
+    Does nothing at the moment
+
+  RETURN VALUE
+    Always 0 (= success)  
+
+  PARAMETERS
+    THD    *thd             in: thread doing the binlog communication to
+                                the slave
+*/
+
+int ha_repl_report_replication_stop(THD *thd)
+{
+  thd = thd;
+
+  return 0;
+}
+#endif /* HAVE_REPLICATION */

--- 1.130/sql/handler.h	2005-04-26 07:38:07 +02:00
+++ 1.131/sql/handler.h	2005-05-10 04:12:21 +02:00
@@ -76,6 +76,12 @@
 */
 #define HA_CAN_INSERT_DELAYED  (1 << 14)
 #define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
+/* 
+   The position of an arbitrary record can be retrieved using position() when
+   the table has a primary key, effectively allowing random access on the
+   table based on a given record.
+*/ 
+#define HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS (1 << 16) 
 #define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 #define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 #define HA_CAN_FULLTEXT        (1 << 21)
@@ -88,7 +94,6 @@
 #define HA_CAN_BIT_FIELD       (1 << 28) /* supports bit fields */
 #define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
 
-
 /* bits in index_flags(index_number) for what you can do with index */
 #define HA_READ_NEXT            1       /* TODO really use this flag */
 #define HA_READ_PREV            2       /* supports ::index_prev */
@@ -163,6 +168,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,
@@ -531,6 +539,7 @@
 } HANDLER_BUFFER;
 
 
+
 class handler :public Sql_alloc
 {
  protected:
@@ -668,11 +677,18 @@
   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);
+  
+  /*
+    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; }
@@ -825,9 +841,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 */
@@ -859,7 +875,7 @@
  {
    return memcmp(ref1, ref2, ref_length);
  }
- 
+
  /*
    Condition pushdown to storage engines
  */
@@ -893,6 +909,19 @@
      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.
+  */
+  friend int ndb_add_binlog_index(THD *, void *);
+  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 */
@@ -949,7 +978,7 @@
 int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
 int ha_end_key_cache(KEY_CACHE *key_cache);
 
-/* weird stuff */
+/* report to InnoDB that control passes to the client */
 int ha_release_temporary_latches(THD *thd);
 
 /* transactions: interface to handlerton functions */
@@ -981,3 +1010,7 @@
 #define trans_need_2pc(thd, all)                   ((total_ha_2pc > 1) && \
         !((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
 
+/* semi-synchronous replication */
+int ha_repl_report_sent_binlog(THD *thd, char *log_file_name,
+                               my_off_t end_offset);
+int ha_repl_report_replication_stop(THD *thd);

--- 1.246/sql/mysql_priv.h	2005-04-26 07:07:55 +02:00
+++ 1.247/sql/mysql_priv.h	2005-05-10 04:12:21 +02:00
@@ -487,6 +487,7 @@
   COMMIT_RELEASE=-1,   COMMIT=0,    COMMIT_AND_CHAIN=6
 };
 
+int begin_trans(THD *thd);
 int end_trans(THD *thd, enum enum_mysql_completiontype completion);
 
 Item *negate_expression(THD *thd, Item *expr);
@@ -1067,6 +1068,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;
@@ -1108,6 +1112,9 @@
        LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
        LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
        LOCK_global_system_variables, LOCK_user_conn;
+extern pthread_mutex_t LOCK_server_started;
+extern pthread_cond_t COND_server_started;
+extern int mysqld_server_started;
 extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
 extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
 extern pthread_attr_t connection_attrib;
@@ -1153,7 +1160,8 @@
 extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd;
 #endif /* HAVE_OPENSSL */
 
-MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **table,uint count);
+MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count,
+                              bool ignore_global_read_lock= FALSE);
 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
 void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
 void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count);
@@ -1167,6 +1175,8 @@
                               bool is_not_commit);
 void start_waiting_global_read_lock(THD *thd);
 bool make_global_read_lock_block_commit(THD *thd);
+bool set_protect_against_global_read_lock(void);
+void unset_protect_against_global_read_lock(void);
 
 /* Lock based on name */
 int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list);

--- 1.420/sql/mysqld.cc	2005-04-26 07:07:56 +02:00
+++ 1.421/sql/mysqld.cc	2005-05-10 04:12:21 +02:00
@@ -317,6 +317,17 @@
 volatile bool mqh_used = 0;
 my_bool sp_automatic_privileges= 1;
 
+my_bool opt_binlog_row_level = FALSE; // Statement-level is default
+const char *binlog_format_names[]= {"disabled","statement","row", NullS};
+TYPELIB binlog_format_typelib=
+  { array_elements(binlog_format_names)-1,"",
+    binlog_format_names, NULL };
+const char *opt_binlog_format= 0;
+enum Binlog_format { BF_NONE= 0, BF_STMT= 1, BF_ROW= 2 };
+enum Binlog_format opt_binlog_format_id= BF_NONE;
+
+unsigned long opt_binlog_rows_event_max_size = 1024;
+
 #ifdef HAVE_INITGROUPS
 static bool calling_initgroups= FALSE; /* Used in SIGSEGV handler. */
 #endif
@@ -434,6 +445,10 @@
 pthread_cond_t COND_thread_cache,COND_flush_thread_cache;
 pthread_t signal_thread;
 pthread_attr_t connection_attrib;
+pthread_mutex_t  LOCK_server_started;
+pthread_cond_t  COND_server_started;
+
+int mysqld_server_started= 0;
 
 /* replication parameters, if master_host is not NULL, we are a slave */
 uint master_port= MYSQL_PORT, master_connect_retry = 60;
@@ -2023,7 +2038,7 @@
   if (test_flags & TEST_CORE_ON_SIGNAL)
   {
     /* Change limits so that we will get a core file */
-    struct rlimit rl;
+    STRUCT_RLIMIT rl;
     rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
     if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
       sql_print_warning("setrlimit could not change the size of core files to 'infinity';  We may not be able to generate a core file on signals");
@@ -2609,6 +2624,8 @@
   (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
   (void) pthread_cond_init(&COND_rpl_status, NULL);
 #endif
+  (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);
+  (void) pthread_cond_init(&COND_server_started,NULL);
   sp_cache_init();
   /* Parameter for threads created for connections */
   (void) pthread_attr_init(&connection_attrib);
@@ -3178,6 +3195,10 @@
                          mysqld_port,
                          MYSQL_COMPILATION_COMMENT);
 
+  // Signal threads waiting for server to be started
+  mysqld_server_started= 1;
+  pthread_cond_signal(&COND_server_started);
+
 #if defined(__NT__) || defined(HAVE_SMEM)
   handle_connections_methods();
 #else
@@ -4156,6 +4177,7 @@
   OPT_SQL_BIN_UPDATE_SAME,     OPT_REPLICATE_DO_DB,
   OPT_REPLICATE_IGNORE_DB,     OPT_LOG_SLAVE_UPDATES,
   OPT_BINLOG_DO_DB,            OPT_BINLOG_IGNORE_DB,
+  OPT_BINLOG_FORMAT,           OPT_BINLOG_ROWS_EVENT_MAX_SIZE, 
   OPT_WANT_CORE,               OPT_CONCURRENT_INSERT,
   OPT_MEMLOCK,                 OPT_MYISAM_RECOVER,
   OPT_REPLICATE_REWRITE_DB,    OPT_SERVER_ID,
@@ -4364,12 +4386,27 @@
   {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.",
    (gptr*) &my_bind_addr_str, (gptr*) &my_bind_addr_str, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"binlog-format", OPT_BINLOG_FORMAT,
+   "Tell the master the form of logging to use: "
+   "either 'row' for row-level logging or "
+   "'statement' for statement-level logging.",
+   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },   
   {"binlog-do-db", OPT_BINLOG_DO_DB,
    "Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB,
    "Tells the master that updates to the given database should not be logged tothe binary log.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"binlog-row-event-max-size", OPT_BINLOG_ROWS_EVENT_MAX_SIZE,
+   "The maximum size of a row-level event in bytes. "
+   "The value have to be an even multiple of 256.",
+   (gptr*) &opt_binlog_rows_event_max_size, 
+   (gptr*) &opt_binlog_rows_event_max_size, 0, 
+   GET_ULONG, REQUIRED_ARG, 
+   /* def_value */ 1024, /* min_value */  256, /* max_value */ ULONG_MAX, 
+   /* sub_size */     0, /* block_size */ 256, 
+   /* app_type */ 0
+  },
   {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0,
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"character-set-server", 'C', "Set the default character set.",
@@ -5502,7 +5539,7 @@
   {"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
+#ifdef HAVE_REPLICATION
   {"sync-replication", OPT_SYNC_REPLICATION,
    "Enable synchronous replication.",
    (gptr*) &global_system_variables.sync_replication,
@@ -5518,7 +5555,7 @@
    (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
+#endif /* HAVE_REPLICATION */
   {"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,
@@ -5647,6 +5684,7 @@
   {"Com_show_keys",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS},
   {"Com_show_logs",	       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_LOGS]), SHOW_LONG_STATUS},
   {"Com_show_master_status",   (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS},
+  {"Com_show_ndbcluster_status",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NDBCLUSTER_STATUS]), SHOW_LONG_STATUS},
   {"Com_show_new_master",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NEW_MASTER]), SHOW_LONG_STATUS},
   {"Com_show_open_tables",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
   {"Com_show_privileges",      (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PRIVILEGES]), SHOW_LONG_STATUS},
@@ -6223,6 +6261,20 @@
     binlog_filter->add_ignore_db(argument);
     break;
   }
+  case OPT_BINLOG_FORMAT:
+  {
+    int id;
+    if ((id= find_type(argument, &binlog_format_typelib, 2)) <= 0)
+    {
+      fprintf(stderr, 
+	      "Unknown binary log format: '%s' "
+	      "(Should be '%s' or '%s')\n", 
+	      opt_binlog_format,binlog_format_names[BF_STMT],binlog_format_names[BF_ROW]);
+      exit(1);
+    }
+    opt_binlog_format_id= (enum Binlog_format)(id-1);
+    break;
+  }
   case (int)OPT_BINLOG_DO_DB:
   {
     binlog_filter->add_do_db(argument);
@@ -6736,6 +6788,26 @@
       init_global_datetime_format(MYSQL_TIMESTAMP_DATETIME,
 				  &global_system_variables.datetime_format))
     exit(1);
+
+  if (opt_bin_log)
+  {
+    if (opt_binlog_format_id == BF_NONE)
+    {
+      if (have_ndbcluster == SHOW_OPTION_YES)
+      {
+	rpl_filter->add_ignore_table("cluster_replication.binlog_index");
+	opt_binlog_format_id= BF_ROW;
+      }
+      else
+	opt_binlog_format_id= BF_STMT;
+    }
+    if (opt_binlog_format_id == BF_ROW)
+      opt_binlog_row_level= TRUE;
+  }
+  else
+    opt_binlog_format_id= BF_NONE;
+
+  opt_binlog_format= binlog_format_names[opt_binlog_format_id];
 }
 
 
@@ -6975,5 +7047,4 @@
 template class I_List<i_string>;
 template class I_List<i_string_pair>;
 template class I_List<NAMED_LIST>;
-FIX_GCC_LINKING_PROBLEM
 #endif

--- 1.136/BitKeeper/deleted/.del-errmsg.txt~f96b7055cac394e	2005-04-26 07:07:51 +02:00
+++ 1.137/BitKeeper/deleted/.del-errmsg.txt~f96b7055cac394e	2005-05-10 04:12:19 +02:00
@@ -67,7 +67,7 @@
 "Column '%-.64s' cannot be null",
 "Unknown database '%-.64s'",
 "Table '%-.64s' already exists",
-"Unknown table '%-.180s'",
+"Unknown table '%-.100s'",
 "Column '%-.64s' in %-.64s is ambiguous",
 "Server shutdown in progress",
 "Unknown column '%-.64s' in '%-.64s'",

--- 1.206/sql/sql_base.cc	2005-04-26 07:07:57 +02:00
+++ 1.207/sql/sql_base.cc	2005-05-10 04:12:22 +02:00
@@ -2726,6 +2726,17 @@
     {
       if (found == WRONG_GRANT)
 	return (Field*) 0;
+      {
+        SELECT_LEX *current_sel= thd->lex->current_select;
+        SELECT_LEX *last_select= item->cached_table->select_lex;
+        /*
+          If the field was an outer referencee, mark all selects using this
+          sub query as dependent of the outer query
+        */
+        if (current_sel != last_select)
+          mark_select_range_as_dependent(thd, last_select, current_sel,
+                                         found, *ref, item);
+      }
       return found;
     }
   }
@@ -3895,11 +3906,8 @@
     TABLE *table= field->table;
     if (field == table->next_number_field)
       table->auto_increment_field_not_null= TRUE;
-    if ((value->save_in_field(field, 0) < 0) && !ignore_errors)
-    {
-      my_message(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR), MYF(0));
+    if (value->save_in_field(field, 0) == -1)
       DBUG_RETURN(TRUE);
-    }
   }
   DBUG_RETURN(thd->net.report_error);
 }

--- 1.162/sql/sql_lex.h	2005-04-26 07:07:57 +02:00
+++ 1.163/sql/sql_lex.h	2005-05-10 04:12:23 +02:00
@@ -90,6 +90,7 @@
   SQLCOM_CREATE_TRIGGER, SQLCOM_DROP_TRIGGER,
   SQLCOM_XA_START, SQLCOM_XA_END, SQLCOM_XA_PREPARE,
   SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
+  SQLCOM_SHOW_NDBCLUSTER_STATUS,
   /* This should be the last !!! */
 
   SQLCOM_END

--- 1.342/sql/sql_yacc.yy	2005-04-26 12:35:27 +02:00
+++ 1.343/sql/sql_yacc.yy	2005-05-10 04:12:23 +02:00
@@ -1459,6 +1459,12 @@
 	    LEX *lex= Lex;
 	    sp_head *sp= lex->sphead;
 
+	    if (sp->m_multi_results)
+	    {
+	      my_message(ER_SP_NO_RETSET_IN_FUNC, ER(ER_SP_NO_RETSET_IN_FUNC),
+	                 MYF(0));
+	      YYABORT;
+	    }
 	    if (sp->check_backpatch(YYTHD))
 	      YYABORT;
 	    lex->sql_command= SQLCOM_CREATE_SPFUNCTION;
@@ -6795,6 +6801,9 @@
 	    switch (Lex->create_info.db_type) {
 	    case DB_TYPE_INNODB:
 	      Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS;
+	      break;
+	    case DB_TYPE_NDBCLUSTER:
+	      Lex->sql_command = SQLCOM_SHOW_NDBCLUSTER_STATUS;
 	      break;
 	    default:
 	      my_error(ER_NOT_SUPPORTED_YET, MYF(0), "STATUS");

--- 1.151/sql/table.cc	2005-04-26 07:07:58 +02:00
+++ 1.152/sql/table.cc	2005-05-10 04:12:23 +02:00
@@ -771,6 +771,7 @@
   if (!(record= (char *) alloc_root(&outparam->mem_root,
                                     rec_buff_length * records)))
     goto err;                                   /* purecov: inspected */
+  outparam->write_row_record= NULL;
   share->default_values= (byte *) record;
   if (my_pread(file,(byte*) record, (uint) share->reclength,
 	       (ulong) (uint2korr(head+6)+

--- 1.88/sql/table.h	2005-04-26 07:07:59 +02:00
+++ 1.89/sql/table.h	2005-05-10 04:12:24 +02:00
@@ -183,6 +183,8 @@
   Field **field;			/* Pointer to fields */
 
   byte *record[2];			/* Pointer to records */
+  byte *write_row_record;		/* Used as optimisation in
+					   THD::write_row */
   byte *insert_values;                  /* used by INSERT ... UPDATE */
   key_map quick_keys, used_keys, keys_in_use_for_query;
   KEY  *key_info;			/* data of keys in database */

--- 1.54/sql/unireg.cc	2005-04-26 07:07:59 +02:00
+++ 1.55/sql/unireg.cc	2005-05-10 04:12:24 +02:00
@@ -696,6 +696,9 @@
   thd->count_cuted_fields= CHECK_FIELD_WARN;    // To find wrong default values
   while ((field=it++))
   {
+    /*
+      regfield don't have to be deleted as it's allocated with sql_alloc()
+    */
     Field *regfield=make_field((char*) buff+field->offset,field->length,
                                null_pos,
 			       null_count & 7,
@@ -707,7 +710,8 @@
 			       field->interval,
 			       field->field_name,
 			       &table);
-    DBUG_ASSERT(regfield);
+    if (!regfield)
+      goto err;                                 // End of memory
 
     if (!(field->flags & NOT_NULL_FLAG))
       null_count++;
@@ -741,7 +745,6 @@
       regfield->store(ER(ER_NO), (uint) strlen(ER(ER_NO)),system_charset_info);
     else
       regfield->reset();
-    delete regfield;
   }
 
   /* Fill not used startpos */

--- 1.16/sql/share/errmsg.txt	2005-04-26 12:35:26 +02:00
+++ 1.17/sql/share/errmsg.txt	2005-05-10 04:16:05 +02:00
@@ -5090,7 +5090,7 @@
 ER_SP_UNINIT_VAR 01000 
 	eng "Referring to uninitialized variable %s"
 ER_SP_BADSELECT 0A000 
-	eng "SELECT in a stored procedure must have INTO"
+	eng "PROCEDURE %s can't return a result set in the given context"
 ER_SP_BADRETURN 42000 
 	eng "RETURN is only allowed in a FUNCTION"
 ER_SP_BADSTATEMENT 0A000 
@@ -5342,6 +5342,10 @@
 	eng "Duplicate handler declared in the same block"
 ER_SP_NOT_VAR_ARG 42000
 	eng "OUT or INOUT argument %d for routine %s is not a variable"
+ER_SP_NO_RETSET_IN_FUNC 0A000
+	eng "Not allowed to return a result set from a function"
+ER_CANT_CREATE_GEOMETRY_OBJECT 22003 
+	eng "Cannot get geometry object from data you send to the GEOMETRY field"
 ER_PARTITION_REQUIRES_VALUES_ERROR
         eng "%s PARTITIONING requires definition of VALUES %s for each partition"
 ER_PARTITION_WRONG_VALUES_ERROR

--- 1.291/BitKeeper/etc/logging_ok	2005-05-09 17:36:01 +02:00
+++ 1.292/BitKeeper/etc/logging_ok	2005-05-10 04:11:24 +02:00
@@ -146,6 +146,7 @@
 miguel@stripped
 mikael@mc04.(none)
 mikael@stripped
+mikron@stripped
 mikron@stripped
 mikron@stripped
 mleich@stripped

--- 1.239/sql/ha_ndbcluster.cc	2005-05-09 20:28:56 +02:00
+++ 1.240/sql/ha_ndbcluster.cc	2005-05-10 04:12:20 +02:00
@@ -3714,6 +3714,11 @@
   CHARSET_INFO *cs= field->charset();
   // Set type and sizes
   const enum enum_field_types mysql_type= field->real_type();
+  DBUG_PRINT("create",
+    ("MEMORY_STORAGE_TYPE_FLAG is = %u, DISK_STORAGE_TYPE_FLAG is = %u",
+      (field->flags & MEM_STORAGE_TYPE_FLAG),
+      (field->flags & DISK_STORAGE_TYPE_FLAG)));
+
   switch (mysql_type) {
   // Numeric types
   case MYSQL_TYPE_TINY:        
@@ -3958,6 +3963,7 @@
   // Set nullable and pk
   col.setNullable(field->maybe_null());
   col.setPrimaryKey(field->flags & PRI_KEY_FLAG);
+
   // Set autoincrement
   if (field->flags & AUTO_INCREMENT_FLAG) 
   {
@@ -4125,7 +4131,8 @@
 
   DBUG_PRINT("table", ("name: %s", m_tabname));  
   tab.setName(m_tabname);
-  tab.setLogging(!(info->options & HA_LEX_CREATE_TMP_TABLE));    
+  tab.setLogging(!(info->options & HA_LEX_CREATE_TMP_TABLE) &&
+                 !(info->options & HA_LEX_CREATE_NO_LOGGING));    
    
   // Save frm data for this table
   if (readfrm(name, &data, &length))
@@ -4137,7 +4144,27 @@
   tab.setFrm(pack_data, pack_length);      
   my_free((char*)data, MYF(0));
   my_free((char*)pack_data, MYF(0));
-  
+
+  partition_info *part_info= form->s->part_info;
+  // Currently only support for one field in the partion key
+  Field *partition_field= 0;
+  // Check partition info
+  if (part_info)
+  {
+      if (part_info->part_type == HASH_PARTITION &&
+	  part_info->list_of_part_fields == TRUE &&
+	  part_info->subpart_type == NOT_A_PARTITION &&
+	  part_info->part_field_list.elements == 1 &&
+	  part_info->part_field_array[0]->flags & PRI_KEY_FLAG)
+      {
+	  partition_field= part_info->part_field_array[0];
+      }
+      else
+      {
+	  return HA_ERR_UNSUPPORTED;
+      }
+  }
+
   for (i= 0; i < form->s->fields; i++) 
   {
     Field *field= form->field[i];
@@ -4146,11 +4173,18 @@
                         field->pack_length()));
     if ((my_errno= create_ndb_column(col, field, info)))
       DBUG_RETURN(my_errno);
+    if (partition_field)
+    {
+	if (partition_field == field)
+	    col.setDistributionKey(TRUE);
+	else
+	    col.setDistributionKey(FALSE);
+    }
     tab.addColumn(col);
     if(col.getPrimaryKey())
       pk_length += (field->pack_length() + 3) / 4;
   }
-  
+
   // No primary key, create shadow key as 64 bit, auto increment  
   if (form->s->primary_key == MAX_KEY) 
   {

--- 1.85/sql/set_var.cc	2005-04-26 07:07:56 +02:00
+++ 1.86/sql/set_var.cc	2005-05-10 04:12:22 +02:00
@@ -737,6 +737,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},
@@ -957,11 +958,9 @@
   {"sql_warnings",            (char*) &sys_sql_warnings,            SHOW_BOOL},
 #ifdef HAVE_REPLICATION
   {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period,     SHOW_SYS},
-#ifdef DOES_NOTHING_YET
   {sys_sync_replication.name, (char*) &sys_sync_replication,        SHOW_SYS},
   {sys_sync_replication_slave_id.name, (char*) &sys_sync_replication_slave_id,SHOW_SYS},
   {sys_sync_replication_timeout.name, (char*) &sys_sync_replication_timeout,SHOW_SYS},
-#endif
 #endif
   {sys_sync_frm.name,         (char*) &sys_sync_frm,               SHOW_SYS},
 #ifdef HAVE_TZNAME
Thread
bk commit into 5.1 tree (tomas:1.1837)tomas10 May