summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2008-04-09 18:09:42 -0400
committerunknown <cmiller@zippy.cornsilk.net>2008-04-09 18:09:42 -0400
commit4a77e833f2c05938839d4f8ed8375420734428ad (patch)
tree34a756c10c96bdedcfa8508577f50e141483d8bf /sql
parentc704e8bdd7d583e86efb7bae7f391a798c871ffa (diff)
parent2bc7179d2d0019fd2b4666de0990faf3f19b9582 (diff)
downloadmariadb-git-4a77e833f2c05938839d4f8ed8375420734428ad.tar.gz
Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug15776/my50-bug15776
into zippy.cornsilk.net:/home/cmiller/work/mysql/bug15776/my51-bug15776 mysql-test/r/type_blob.result: Auto merged mysql-test/t/type_blob.test: Auto merged sql/field.cc: Auto merged sql/unireg.h: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc24
-rw-r--r--sql/unireg.h2
2 files changed, 18 insertions, 8 deletions
diff --git a/sql/field.cc b/sql/field.cc
index a7a76d6c950..2b6d5235003 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7082,6 +7082,7 @@ uint32 Field_blob::get_length(const uchar *pos)
return (uint32) tmp;
}
}
+ /* When expanding this, see also MAX_FIELD_BLOBLENGTH. */
return 0; // Impossible
}
@@ -8772,11 +8773,11 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
(fld_type_modifier & NOT_NULL_FLAG) && fld_type != MYSQL_TYPE_TIMESTAMP)
flags|= NO_DEFAULT_VALUE_FLAG;
- if (fld_length != 0)
+ if (fld_length != NULL)
{
errno= 0;
length= strtoul(fld_length, NULL, 10);
- if (errno != 0)
+ if ((errno != 0) || (length > MAX_FIELD_BLOBLENGTH))
{
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), fld_name, MAX_FIELD_BLOBLENGTH);
DBUG_RETURN(TRUE);
@@ -8933,7 +8934,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
}
break;
case MYSQL_TYPE_TIMESTAMP:
- if (!fld_length)
+ if (fld_length == NULL)
{
/* Compressed date YYYYMMDDHHMMSS */
length= MAX_DATETIME_COMPRESSED_WIDTH;
@@ -8942,12 +8943,21 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
{
/*
We support only even TIMESTAMP lengths less or equal than 14
- and 19 as length of 4.1 compatible representation.
+ and 19 as length of 4.1 compatible representation. Silently
+ shrink it to MAX_DATETIME_COMPRESSED_WIDTH.
*/
- length= ((length+1)/2)*2; /* purecov: inspected */
- length= min(length, MAX_DATETIME_COMPRESSED_WIDTH); /* purecov: inspected */
+ DBUG_ASSERT(MAX_DATETIME_COMPRESSED_WIDTH < UINT_MAX);
+ if (length != UINT_MAX) /* avoid overflow; is safe because of min() */
+ length= ((length+1)/2)*2;
+ length= min(length, MAX_DATETIME_COMPRESSED_WIDTH);
}
flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
+ /*
+ Since we silently rewrite down to MAX_DATETIME_COMPRESSED_WIDTH bytes,
+ the parser should not raise errors unless bizzarely large.
+ */
+ max_field_charlength= UINT_MAX;
+
if (fld_default_value)
{
/* Grammar allows only NOW() value for ON UPDATE clause */
@@ -9054,7 +9064,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
((length > max_field_charlength && fld_type != MYSQL_TYPE_SET &&
fld_type != MYSQL_TYPE_ENUM &&
(fld_type != MYSQL_TYPE_VARCHAR || fld_default_value)) ||
- (!length &&
+ ((length == 0) &&
fld_type != MYSQL_TYPE_STRING &&
fld_type != MYSQL_TYPE_VARCHAR && fld_type != MYSQL_TYPE_GEOMETRY)))
{
diff --git a/sql/unireg.h b/sql/unireg.h
index 87e0e4ac8f8..aaf7a827f5f 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -63,7 +63,7 @@
#define MAX_MBWIDTH 3 /* Max multibyte sequence */
#define MAX_FIELD_CHARLENGTH 255
#define MAX_FIELD_VARCHARLENGTH 65535
-#define MAX_FIELD_BLOBLENGTH UINT_MAX
+#define MAX_FIELD_BLOBLENGTH UINT_MAX32 /* cf field_blob::get_length() */
#define CONVERT_IF_BIGGER_TO_BLOB 512 /* Used for CREATE ... SELECT */
/* Max column width +1 */