mirror of
https://github.com/MariaDB/server.git
synced 2026-05-10 00:54:30 +02:00
Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug15776/my51-bug15776
into zippy.cornsilk.net:/home/cmiller/work/mysql/bug15776-encore/my51-bug15776-encore sql/field.cc: Auto merged sql/item_create.cc: Auto merged sql/share/errmsg.txt: Auto merged sql/unireg.h: Auto merged mysql-test/r/type_blob.result: manual merge. mysql-test/t/type_blob.test: manual merge. sql/sql_yacc.yy: merge by hand.
This commit is contained in:
commit
7cce56b2f2
6 changed files with 410 additions and 42 deletions
36
sql/field.cc
36
sql/field.cc
|
|
@ -7568,6 +7568,7 @@ uint32 Field_blob::get_length(const uchar *pos, uint packlength_arg, bool low_by
|
|||
return (uint32) tmp;
|
||||
}
|
||||
}
|
||||
/* When expanding this, see also MAX_FIELD_BLOBLENGTH. */
|
||||
return 0; // Impossible
|
||||
}
|
||||
|
||||
|
|
@ -9449,8 +9450,20 @@ 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 && !(length= (uint) atoi(fld_length)))
|
||||
fld_length= 0; /* purecov: inspected */
|
||||
if (fld_length != NULL)
|
||||
{
|
||||
errno= 0;
|
||||
length= strtoul(fld_length, NULL, 10);
|
||||
if ((errno != 0) || (length > MAX_FIELD_BLOBLENGTH))
|
||||
{
|
||||
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), fld_name, MAX_FIELD_BLOBLENGTH);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
fld_length= 0; /* purecov: inspected */
|
||||
}
|
||||
|
||||
sign_len= fld_type_modifier & UNSIGNED_FLAG ? 0 : 1;
|
||||
|
||||
switch (fld_type) {
|
||||
|
|
@ -9598,7 +9611,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;
|
||||
|
|
@ -9607,12 +9620,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 */
|
||||
|
|
@ -9719,7 +9741,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)))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue