MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:holyfoot Date:January 14 2007 9:12pm
Subject:bk commit into 5.0 tree (holyfoot:1.2377) BUG#20961
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-01-15 01:11:56+04:00, holyfoot@stripped +5 -0
  bug #20961 (DEFAULT for NO DEFAULT may insert garbage)
  GEOMETRY field fixed - now it returns an error in this
  case.

  mysql-test/r/gis.result@stripped, 2007-01-15 01:11:55+04:00, holyfoot@stripped +4 -0
    result fixed

  mysql-test/t/gis.test@stripped, 2007-01-15 01:11:55+04:00, holyfoot@stripped +9 -0
    testcase

  sql/field.cc@stripped, 2007-01-15 01:11:55+04:00, holyfoot@stripped +11 -0
    return an error as we can't set DEFAULT to the GEOMETRY field
    if no default value was specified

  sql/field.h@stripped, 2007-01-15 01:11:55+04:00, holyfoot@stripped +6 -3
    set_default returns 'success' flag now
    as this operation is possible not for
    all fields

  sql/item.cc@stripped, 2007-01-15 01:11:55+04:00, holyfoot@stripped +1 -2
    set_default can return an error

# 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:	holyfoot
# Host:	hfmain.(none)
# Root:	/home/hf/work/20691/my50-20691

--- 1.337/sql/field.cc	2007-01-15 01:12:00 +04:00
+++ 1.338/sql/field.cc	2007-01-15 01:12:00 +04:00
@@ -7601,6 +7601,17 @@ err:
   return -1;
 }
 
+int Field_geom::set_default()
+{
+  if (flags & NO_DEFAULT_VALUE_FLAG)
+  {
+    my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
+               ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+    return -1;
+  }
+  return Field_blob::set_default();
+}
+
 #endif /*HAVE_SPATIAL*/
 
 /****************************************************************************

--- 1.195/sql/field.h	2007-01-15 01:12:00 +04:00
+++ 1.196/sql/field.h	2007-01-15 01:12:00 +04:00
@@ -151,7 +151,7 @@ public:
   virtual uint32 sort_length() const { return pack_length(); }
   virtual int reset(void) { bzero(ptr,pack_length()); return 0; }
   virtual void reset_fields() {}
-  virtual void set_default()
+  virtual int set_default()
   {
     my_ptrdiff_t offset = (my_ptrdiff_t) (table->s->default_values -
 					  table->record[0]);
@@ -159,6 +159,7 @@ public:
     if (null_ptr)
       *null_ptr= ((*null_ptr & (uchar) ~null_bit) |
 		  null_ptr[offset] & null_bit);
+    return 0;
   }
   virtual bool binary() const { return 1; }
   virtual bool zero_pack() const { return 1; }
@@ -816,13 +817,14 @@ public:
   bool can_be_compared_as_longlong() const { return TRUE; }
   bool zero_pack() const { return 0; }
   void set_time();
-  virtual void set_default()
+  int set_default()
   {
     if (table->timestamp_field == this &&
         unireg_check != TIMESTAMP_UN_FIELD)
       set_time();
     else
-      Field::set_default();
+      return Field::set_default();
+    return 0;
   }
   /* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
   inline long get_timestamp(my_bool *null_value)
@@ -1277,6 +1279,7 @@ public:
   void get_key_image(char *buff,uint length,imagetype type);
   uint size_of() const { return sizeof(*this); }
   int  reset(void) { return !maybe_null(); }
+  int set_default();
 };
 #endif /*HAVE_SPATIAL*/
 

--- 1.248/sql/item.cc	2007-01-15 01:12:00 +04:00
+++ 1.249/sql/item.cc	2007-01-15 01:12:00 +04:00
@@ -5488,8 +5488,7 @@ int Item_default_value::save_in_field(Fi
                             ER(ER_NO_DEFAULT_FOR_FIELD),
                             field_arg->field_name);
       }
-      field_arg->set_default();
-      return 1;
+      return field_arg->set_default();
     }
     field_arg->set_default();
     return 0;

--- 1.38/mysql-test/r/gis.result	2007-01-15 01:12:00 +04:00
+++ 1.39/mysql-test/r/gis.result	2007-01-15 01:12:00 +04:00
@@ -717,3 +717,7 @@ desc t1;
 Field	Type	Null	Key	Default	Extra
 GeomFromText('point(1 1)')	geometry	NO			
 drop table t1;
+create table t1 (g geometry not null);
+insert into t1 values(default);
+ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
+drop table t1;

--- 1.31/mysql-test/t/gis.test	2007-01-15 01:12:00 +04:00
+++ 1.32/mysql-test/t/gis.test	2007-01-15 01:12:00 +04:00
@@ -428,3 +428,12 @@ drop table t1;
 create table t1 select GeomFromText('point(1 1)');
 desc t1;
 drop table t1;
+
+#
+# Bug #20691 (DEFAULT over NOT NULL field)
+#
+create table t1 (g geometry not null);
+--error ER_CANT_CREATE_GEOMETRY_OBJECT
+insert into t1 values(default);
+drop table t1;
+
Thread
bk commit into 5.0 tree (holyfoot:1.2377) BUG#20961holyfoot14 Jan