Below is the list of changes that have just been committed into a local
5.0 repository of cmiller. When cmiller 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, 2008-04-08 20:20:03-04:00, cmiller@stripped +5 -0
Follow-up to Bug#15776, test failures on 64-bit linux.
Make maximum blob size to be 2**32-1, regardless of word size.
Fix failure of timestamp with size of 2**31-1. The method of
rounding up to the nearest even number would overflow.
mysql-test/r/type_blob.result@stripped, 2008-04-08 20:20:01-04:00, cmiller@stripped +5 -1
2**32-1 is not a special case for timestamp.
mysql-test/t/type_blob.test@stripped, 2008-04-08 20:20:01-04:00, cmiller@stripped +3 -1
2**32-1 is not a special case for timestamp.
sql/field.cc@stripped, 2008-04-08 20:20:01-04:00, cmiller@stripped +15 -6
Make 32 and 64-bit machines hold the same max blob size. This is
arguably stupid, but our communication protocol doesn't permit one to
use anywhere near that anyway. There's no reason to restrict this
other than consistency of tests.
Also, fix a bug where the round-to-even code for TIMESTAMP fields
failed where the size would overflow the size to zero and then
fail.
Also, since we silently truncate the size of TIMESTAMP fields, set
the maximum size we report is allowable to be the largest parsable
number.
sql/item_create.cc@stripped, 2008-04-08 20:20:01-04:00, cmiller@stripped +1 -1
Enforce that the size is not too large. This matters on 64-bit
machines.
sql/unireg.h@stripped, 2008-04-08 20:20:01-04:00, cmiller@stripped +1 -1
Make BLOB size consistent across machines of different word sizes.
diff -Nrup a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
--- a/mysql-test/r/type_blob.result 2008-04-01 12:26:10 -04:00
+++ b/mysql-test/r/type_blob.result 2008-04-08 20:20:01 -04:00
@@ -880,9 +880,13 @@ Warnings:
Warning 1287 'TIMESTAMP(4294967294)' is deprecated; use 'TIMESTAMP' instead
DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967295));
-ERROR 42000: Display width out of range for column 'a' (max = 255)
+Warnings:
+Warning 1287 'TIMESTAMP(4294967295)' is deprecated; use 'TIMESTAMP' instead
+DROP TABLE b15776;
CREATE TABLE b15776 (a timestamp(4294967296));
ERROR 42000: Display width out of range for column 'a' (max = 4294967295)
+CREATE TABLE b15776 (a timestamp(-1));
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1))' at line 1
CREATE TABLE b15776 (a timestamp(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
diff -Nrup a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
--- a/mysql-test/t/type_blob.test 2008-03-26 14:52:08 -04:00
+++ b/mysql-test/t/type_blob.test 2008-04-08 20:20:01 -04:00
@@ -528,10 +528,12 @@ CREATE TABLE b15776 (a year(-2));
## For timestamp, we silently rewrite widths to 14 or 19.
CREATE TABLE b15776 (a timestamp(4294967294));
DROP TABLE b15776;
---error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a timestamp(4294967295));
+DROP TABLE b15776;
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a timestamp(4294967296));
+--error ER_PARSE_ERROR
+CREATE TABLE b15776 (a timestamp(-1));
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a timestamp(-2));
diff -Nrup a/sql/field.cc b/sql/field.cc
--- a/sql/field.cc 2007-08-31 15:24:41 -04:00
+++ b/sql/field.cc 2008-04-08 20:20:01 -04:00
@@ -8399,7 +8399,7 @@ bool create_field::init(THD *thd, char *
{
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);
@@ -8556,7 +8556,7 @@ bool create_field::init(THD *thd, char *
}
break;
case FIELD_TYPE_TIMESTAMP:
- if (!fld_length)
+ if (fld_length == NULL)
{
/* Compressed date YYYYMMDDHHMMSS */
length= MAX_DATETIME_COMPRESSED_WIDTH;
@@ -8565,12 +8565,21 @@ bool create_field::init(THD *thd, char *
{
/*
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 */
@@ -8677,7 +8686,7 @@ bool create_field::init(THD *thd, char *
((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)))
{
diff -Nrup a/sql/item_create.cc b/sql/item_create.cc
--- a/sql/item_create.cc 2007-08-31 15:24:41 -04:00
+++ b/sql/item_create.cc 2008-04-08 20:20:01 -04:00
@@ -531,7 +531,7 @@ Item *create_func_cast(Item *a, Cast_tar
ulong decoded_size;
errno= 0;
decoded_size= strtoul(c_len, NULL, 10);
- if (errno != 0)
+ if ((errno != 0) || (decoded_size > MAX_FIELD_BLOBLENGTH))
{
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), "cast as char", MAX_FIELD_BLOBLENGTH);
return NULL;
diff -Nrup a/sql/unireg.h b/sql/unireg.h
--- a/sql/unireg.h 2007-08-31 15:24:41 -04:00
+++ b/sql/unireg.h 2008-04-08 20:20:01 -04:00
@@ -60,7 +60,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 ((uint32) 4294967295U)
#define CONVERT_IF_BIGGER_TO_BLOB 512 /* Used for CREATE ... SELECT */
/* Max column width +1 */
| Thread |
|---|
| • bk commit into 5.0 tree (cmiller:1.2503) BUG#15776 | Chad MILLER | 9 Apr |