diff options
author | unknown <cmiller@zippy.cornsilk.net> | 2008-04-09 12:27:51 -0400 |
---|---|---|
committer | unknown <cmiller@zippy.cornsilk.net> | 2008-04-09 12:27:51 -0400 |
commit | a16a72b6c3c46538a6b79c6500b1a79756866450 (patch) | |
tree | 46137c7289c73db76ff56b401daabb233cdea751 /sql/field.cc | |
parent | f89f3c803df72c25124344a56949ec573363a2e8 (diff) | |
parent | 2bc7179d2d0019fd2b4666de0990faf3f19b9582 (diff) | |
download | mariadb-git-a16a72b6c3c46538a6b79c6500b1a79756866450.tar.gz |
Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug15776/my50-bug15776
into zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-build
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/field.cc')
-rw-r--r-- | sql/field.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/sql/field.cc b/sql/field.cc index bbc2f549ead..91f356988e4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6930,6 +6930,7 @@ uint32 Field_blob::get_length(const char *pos) return (uint32) tmp; } } + /* When expanding this, see also MAX_FIELD_BLOBLENGTH. */ return 0; // Impossible } @@ -8441,11 +8442,11 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, (fld_type_modifier & NOT_NULL_FLAG) && fld_type != FIELD_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); @@ -8602,7 +8603,7 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, } break; case FIELD_TYPE_TIMESTAMP: - if (!fld_length) + if (fld_length == NULL) { /* Compressed date YYYYMMDDHHMMSS */ length= MAX_DATETIME_COMPRESSED_WIDTH; @@ -8611,12 +8612,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 */ @@ -8723,7 +8733,7 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, ((length > max_field_charlength && fld_type != FIELD_TYPE_SET && fld_type != FIELD_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 != FIELD_TYPE_GEOMETRY))) { |