List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:July 18 2006 11:04pm
Subject:bk commit into 5.0 tree (jimw:1.2234) BUG#19498
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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, 2006-07-18 16:04:18-07:00, jimw@rama.(none) +11 -0
  Bug #19498: Inconsistent support for DEFAULT in TEXT columns
  
    When a default of '' was specified for TEXT/BLOB columns, the specification
    was silently ignored. This is presumably to be nice to applications (or
    people) who generate their column definitions in a not-very-clever fashion.
  
    For clarity, doing this now results in a warning, or an error in strict
    mode.

  mysql-test/r/federated.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +4 -0
    Update results

  mysql-test/r/fulltext_distinct.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +2 -0
    Update results

  mysql-test/r/fulltext_update.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +2 -0
    Update results

  mysql-test/r/gis-rtree.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +6 -0
    Update results

  mysql-test/r/gis.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +2 -0
    Update results

  mysql-test/r/join_outer.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +2 -0
    Update results

  mysql-test/r/order_by.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +2 -0
    Update results

  mysql-test/r/type_blob.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +20 -0
    Add new results

  mysql-test/r/type_ranges.result@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +3 -0
    Update results

  mysql-test/t/type_blob.test@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +15 -0
    Add new test

  sql/field.cc@stripped, 2006-07-18 16:04:15-07:00, jimw@rama.(none) +19 -2
    Issue a warning when setting '' as the default on a BLOB/TEXT column,
    and make it an error in strict mode. Also, clarify comments about when
    NO_DEFAULT_VALUE_FLAG is set.

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-19498

--- 1.314/sql/field.cc	2006-07-18 16:04:22 -07:00
+++ 1.315/sql/field.cc	2006-07-18 16:04:22 -07:00
@@ -8363,7 +8363,8 @@
 
   comment= *fld_comment;
   /*
-    Set flag if this field doesn't have a default value
+    Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and
+    it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
   */
   if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) &&
       (fld_type_modifier & NOT_NULL_FLAG) && fld_type != FIELD_TYPE_TIMESTAMP)
@@ -8440,11 +8441,27 @@
       /* Allow empty as default value. */
       String str,*res;
       res= fld_default_value->val_str(&str);
-      if (res->length())
+      /*
+        A default other than '' is always an error, and any non-NULL
+        specified default is an error in strict mode.
+      */
+      if (res->length() || (thd->variables.sql_mode &
+                            (MODE_STRICT_TRANS_TABLES |
+                             MODE_STRICT_ALL_TABLES)))
       {
         my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0),
                  fld_name); /* purecov: inspected */
         DBUG_RETURN(TRUE);
+      }
+      else
+      {
+        /*
+          Otherwise a default of '' is just a warning.
+        */
+        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                            ER_BLOB_CANT_HAVE_DEFAULT,
+                            ER(ER_BLOB_CANT_HAVE_DEFAULT),
+                            fld_name);
       }
       def= 0;
     }

--- 1.48/mysql-test/r/join_outer.result	2006-07-18 16:04:22 -07:00
+++ 1.49/mysql-test/r/join_outer.result	2006-07-18 16:04:22 -07:00
@@ -598,6 +598,8 @@
 name tinytext DEFAULT '' NOT NULL,
 UNIQUE id (id)
 );
+Warnings:
+Warning	1101	BLOB/TEXT column 'name' can't have a default value
 INSERT INTO t1 VALUES (1,'yes'),(2,'no');
 CREATE TABLE t2 (
 id int(11) DEFAULT '0' NOT NULL,

--- 1.51/mysql-test/r/order_by.result	2006-07-18 16:04:22 -07:00
+++ 1.52/mysql-test/r/order_by.result	2006-07-18 16:04:22 -07:00
@@ -280,6 +280,8 @@
 ipnr varchar(30) NOT NULL default '',
 PRIMARY KEY  (member_id)
 ) ENGINE=MyISAM PACK_KEYS=1;
+Warnings:
+Warning	1101	BLOB/TEXT column 'info' can't have a default value
 insert into t1 (member_id) values (1),(2),(3);
 select member_id, nickname, voornaam FROM t1
 ORDER by lastchange_datum DESC LIMIT 2;

--- 1.50/mysql-test/r/type_blob.result	2006-07-18 16:04:22 -07:00
+++ 1.51/mysql-test/r/type_blob.result	2006-07-18 16:04:22 -07:00
@@ -503,6 +503,8 @@
 fish	10
 drop table t1;
 create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
+Warnings:
+Warning	1101	BLOB/TEXT column 'imagem' can't have a default value
 insert into t1 (id) values (1);
 select 
 charset(load_file('../../std_data/words.dat')),
@@ -788,3 +790,21 @@
 616100000000
 620000000000
 drop table t1;
+create table t1 (a text default '');
+Warnings:
+Warning	1101	BLOB/TEXT column 'a' can't have a default value
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` text
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values (default);
+select * from t1;
+a
+NULL
+drop table t1;
+set @@sql_mode='TRADITIONAL';
+create table t1 (a text default '');
+ERROR 42000: BLOB/TEXT column 'a' can't have a default value
+set @@sql_mode='';
+End of 5.0 tests

--- 1.39/mysql-test/r/type_ranges.result	2006-07-18 16:04:22 -07:00
+++ 1.40/mysql-test/r/type_ranges.result	2006-07-18 16:04:22 -07:00
@@ -38,6 +38,9 @@
 KEY (ulonglong,ulong),
 KEY (options,flags)
 );
+Warnings:
+Warning	1101	BLOB/TEXT column 'mediumblob_col' can't have a default value
+Warning	1101	BLOB/TEXT column 'longblob_col' can't have a default value
 show full fields from t1;
 Field	Type	Collation	Null	Key	Default	Extra	Privileges	Comment
 auto	int(5) unsigned	NULL	NO	PRI	NULL	auto_increment	#	

--- 1.31/mysql-test/t/type_blob.test	2006-07-18 16:04:22 -07:00
+++ 1.32/mysql-test/t/type_blob.test	2006-07-18 16:04:22 -07:00
@@ -423,3 +423,18 @@
 select hex(a) from t1 order by a;
 select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
 drop table t1;
+
+#
+# Bug #19489: Inconsistent support for DEFAULT in TEXT columns
+#
+create table t1 (a text default '');
+show create table t1;
+insert into t1 values (default);
+select * from t1;
+drop table t1;
+set @@sql_mode='TRADITIONAL';
+--error ER_BLOB_CANT_HAVE_DEFAULT
+create table t1 (a text default '');
+set @@sql_mode='';
+
+--echo End of 5.0 tests

--- 1.5/mysql-test/r/fulltext_distinct.result	2006-07-18 16:04:22 -07:00
+++ 1.6/mysql-test/r/fulltext_distinct.result	2006-07-18 16:04:22 -07:00
@@ -8,6 +8,8 @@
 KEY kv(value(15)),
 FULLTEXT KEY kvf(value)
 ) ENGINE=MyISAM;
+Warnings:
+Warning	1101	BLOB/TEXT column 'value' can't have a default value
 CREATE TABLE t2 (
 id_t2 mediumint unsigned NOT NULL default '0',
 id_t1 mediumint unsigned NOT NULL default '0',

--- 1.33/mysql-test/r/federated.result	2006-07-18 16:04:22 -07:00
+++ 1.34/mysql-test/r/federated.result	2006-07-18 16:04:22 -07:00
@@ -967,6 +967,8 @@
 `blurb` text default '',
 PRIMARY KEY (blurb_id))
 DEFAULT CHARSET=latin1;
+Warnings:
+Warning	1101	BLOB/TEXT column 'blurb' can't have a default value
 DROP TABLE IF EXISTS federated.t1;
 CREATE TABLE federated.t1 (
 `blurb_id` int NOT NULL DEFAULT 0,
@@ -975,6 +977,8 @@
 ENGINE="FEDERATED"
   DEFAULT CHARSET=latin1
 CONNECTION='mysql://root@stripped:SLAVE_PORT/federated/t1';
+Warnings:
+Warning	1101	BLOB/TEXT column 'blurb' can't have a default value
 INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types.  This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements.  The overview is intentionally brief.  The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.");
 INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.");
 INSERT INTO federated.t1 VALUES (3, " A floating-point number.  p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following.  FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined.  ");

--- 1.17/mysql-test/r/gis-rtree.result	2006-07-18 16:04:22 -07:00
+++ 1.18/mysql-test/r/gis-rtree.result	2006-07-18 16:04:22 -07:00
@@ -804,6 +804,8 @@
 ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
 drop table t1, t2;
 CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+Warnings:
+Warning	1101	BLOB/TEXT column 'geometry' can't have a default value
 INSERT INTO t1 (geometry) VALUES
 (PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
 -66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999,
@@ -820,6 +822,8 @@
 c1 geometry NOT NULL default '',
 SPATIAL KEY i1 (c1(32))
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+Warnings:
+Warning	1101	BLOB/TEXT column 'c1' can't have a default value
 INSERT INTO t1 (c1) VALUES (
 PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
                             -18.6055555000 -66.8158332999,
@@ -834,6 +838,8 @@
 c1 geometry NOT NULL default '',
 SPATIAL KEY i1 (c1(32))
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+Warnings:
+Warning	1101	BLOB/TEXT column 'c1' can't have a default value
 INSERT INTO t1 (c1) VALUES (
 PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
                             -18.6055555000 -66.8158332999,

--- 1.33/mysql-test/r/gis.result	2006-07-18 16:04:22 -07:00
+++ 1.34/mysql-test/r/gis.result	2006-07-18 16:04:22 -07:00
@@ -583,6 +583,8 @@
 drop table t1;
 CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
 geometry NOT NULL default '') ENGINE=MyISAM ;
+Warnings:
+Warning	1101	BLOB/TEXT column 'geo' can't have a default value
 insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
 36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163
 36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363

--- 1.4/mysql-test/r/fulltext_update.result	2006-07-18 16:04:22 -07:00
+++ 1.5/mysql-test/r/fulltext_update.result	2006-07-18 16:04:22 -07:00
@@ -9,6 +9,8 @@
 FULLTEXT(url,description,shortdesc,longdesc),
 PRIMARY KEY(gnr)
 );
+Warnings:
+Warning	1101	BLOB/TEXT column 'longdesc' can't have a default value
 insert into test (url,shortdesc,longdesc,description,name) VALUES 
 ("http:/test.at", "kurz", "lang","desc", "name");
 insert into test (url,shortdesc,longdesc,description,name) VALUES 
Thread
bk commit into 5.0 tree (jimw:1.2234) BUG#19498Jim Winstead19 Jul