--- ../mysql-5.0.bk-orig/./sql/share/errmsg.txt Fri Feb 23 16:36:00 2007 +++ ./sql/share/errmsg.txt Wed May 23 18:06:37 2007 @@ -1769,34 +1769,34 @@ slo "Blob pole '%-.64s' neme by pouit ako k" spa "La columna Blob '%-.64s' no puede ser usada en una declaracion de clave" swe "En BLOB '%-.64s' kan inte vara nyckel med den anvnda tabelltypen" ukr "BLOB '%-.64s' Φ Ц æ" ER_TOO_BIG_FIELDLENGTH 42000 S1009 - cze "P-Bli velk dlka sloupce '%-.64s' (nejvce %d). Pouijte BLOB" - dan "For stor feltlngde for kolonne '%-.64s' (maks = %d). Brug BLOB i stedet" - nla "Te grote kolomlengte voor '%-.64s' (max = %d). Maak hiervoor gebruik van het type BLOB" - eng "Column length too big for column '%-.64s' (max = %d); use BLOB or TEXT instead" - jps "column '%-.64s' ,mۂ column ̑傫܂. (ő %d ܂). BLOB ɎgpĂ.", - est "Tulba '%-.64s' pikkus on liiga pikk (maksimaalne pikkus: %d). Kasuta BLOB vljatpi" - fre "Champ '%-.64s' trop long (max = %d). Utilisez un BLOB" - ger "Feldlnge fr Feld '%-.64s' zu gro (maximal %d). BLOB- oder TEXT-Spaltentyp verwenden!" - greek " '%-.64s' (max = %d). BLOB" - hun "A(z) '%-.64s' oszlop tul hosszu. (maximum = %d). Hasznaljon BLOB tipust inkabb." - ita "La colonna '%-.64s' e` troppo grande (max=%d). Utilizza un BLOB." - jpn "column '%-.64s' ,ݤ column 礭¿ޤ. ( %d ޤ). BLOB 򤫤˻ѤƤ." - kor "Į '%-.64s' Į ̰ ʹ ϴ (ִ = %d). ſ BLOB ϼ." - nor "For stor nkkellengde for kolonne '%-.64s' (maks = %d). Bruk BLOB istedenfor" - norwegian-ny "For stor nykkellengde for felt '%-.64s' (maks = %d). Bruk BLOB istadenfor" - pol "Zbyt dua dugo? kolumny '%-.64s' (maks. = %d). W zamian uyj typu BLOB" - por "Comprimento da coluna '%-.64s' grande demais (max = %d); use BLOB em seu lugar" - rum "Lungimea coloanei '%-.64s' este prea lunga (maximum = %d). Foloseste BLOB mai bine" - rus " '%-.64s' ( = %d). BLOB TEXT " - serbian "Previe podataka za kolonu '%-.64s' (maksimum je %d). Upotrebite BLOB polje" - slo "Prli vek dka pre pole '%-.64s' (maximum = %d). Pouite BLOB" - spa "Longitud de columna demasiado grande para la columna '%-.64s' (maximo = %d).Usar BLOB en su lugar" - swe "Fr stor kolumnlngd angiven fr '%-.64s' (max= %d). Anvnd en BLOB instllet" - ukr " '%-.64s' (max = %d). BLOB" + cze "P-Bli velk dlka sloupce '%-.64s' (nejvce %lu). Pouijte BLOB" + dan "For stor feltlngde for kolonne '%-.64s' (maks = %lu). Brug BLOB i stedet" + nla "Te grote kolomlengte voor '%-.64s' (max = %lu). Maak hiervoor gebruik van het type BLOB" + eng "Column length too big for column '%-.64s' (max = %lu); use BLOB or TEXT instead" + jps "column '%-.64s' ,mۂ column ̑傫܂. (ő %lu ܂). BLOB ɎgpĂ.", + est "Tulba '%-.64s' pikkus on liiga pikk (maksimaalne pikkus: %lu). Kasuta BLOB vljatpi" + fre "Champ '%-.64s' trop long (max = %lu). Utilisez un BLOB" + ger "Feldlnge fr Feld '%-.64s' zu gro (maximal %lu). BLOB- oder TEXT-Spaltentyp verwenden!" + greek " '%-.64s' (max = %lu). BLOB" + hun "A(z) '%-.64s' oszlop tul hosszu. (maximum = %lu). Hasznaljon BLOB tipust inkabb." + ita "La colonna '%-.64s' e` troppo grande (max=%lu). Utilizza un BLOB." + jpn "column '%-.64s' ,ݤ column 礭¿ޤ. ( %lu ޤ). BLOB 򤫤˻ѤƤ." + kor "Į '%-.64s' Į ̰ ʹ ϴ (ִ = %lu). ſ BLOB ϼ." + nor "For stor nkkellengde for kolonne '%-.64s' (maks = %lu). Bruk BLOB istedenfor" + norwegian-ny "For stor nykkellengde for felt '%-.64s' (maks = %lu). Bruk BLOB istadenfor" + pol "Zbyt dua dugo? kolumny '%-.64s' (maks. = %lu). W zamian uyj typu BLOB" + por "Comprimento da coluna '%-.64s' grande demais (max = %lu); use BLOB em seu lugar" + rum "Lungimea coloanei '%-.64s' este prea lunga (maximum = %lu). Foloseste BLOB mai bine" + rus " '%-.64s' ( = %lu). BLOB TEXT " + serbian "Previe podataka za kolonu '%-.64s' (maksimum je %lu). Upotrebite BLOB polje" + slo "Prli vek dka pre pole '%-.64s' (maximum = %lu). Pouite BLOB" + spa "Longitud de columna demasiado grande para la columna '%-.64s' (maximo = %lu).Usar BLOB en su lugar" + swe "Fr stor kolumnlngd angiven fr '%-.64s' (max= %lu). Anvnd en BLOB instllet" + ukr " '%-.64s' (max = %lu). BLOB" ER_WRONG_AUTO_KEY 42000 S1009 cze "M-Bete mt pouze jedno AUTO pole a to mus bt definovno jako kl" dan "Der kan kun specificeres eet AUTO_INCREMENT-felt, og det skal vre indekseret" nla "Er kan slechts 1 autofield zijn en deze moet als zoeksleutel worden gedefinieerd." eng "Incorrect table definition; there can be only one auto column and it must be defined as a key" --- ../mysql-5.0.bk-orig/./sql/field.cc Wed May 9 20:17:20 2007 +++ ./sql/field.cc Wed May 23 18:05:43 2007 @@ -8391,12 +8391,15 @@ */ if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) && (fld_type_modifier & NOT_NULL_FLAG) && fld_type != FIELD_TYPE_TIMESTAMP) flags|= NO_DEFAULT_VALUE_FLAG; - if (fld_length && !(length= (uint) atoi(fld_length))) + errno= 0; + if (fld_length && !(length= strtoul(fld_length, 0, 10))) fld_length= 0; /* purecov: inspected */ + bool err_too_long= errno ? TRUE : FALSE; + sign_len= fld_type_modifier & UNSIGNED_FLAG ? 0 : 1; switch (fld_type) { case FIELD_TYPE_TINY: if (!fld_length) @@ -8670,10 +8673,16 @@ ER_TOO_BIG_DISPLAYWIDTH, MYF(0), fld_name, max_field_charlength); /* purecov: inspected */ DBUG_RETURN(TRUE); } + else if ((flags & BLOB_FLAG) && err_too_long) + { + my_error( ER_TOO_BIG_FIELDLENGTH, MYF(0), fld_name, 4294967295); + DBUG_RETURN(TRUE); + } + fld_type_modifier&= AUTO_INCREMENT_FLAG; if ((~allowed_type_modifier) & fld_type_modifier) { my_error(ER_WRONG_FIELD_SPEC, MYF(0), fld_name); DBUG_RETURN(TRUE); --- ../mysql-5.0.bk-orig/./sql/item_create.cc Wed May 9 20:17:20 2007 +++ ./sql/item_create.cc Wed May 23 16:10:12 2007 @@ -447,11 +447,11 @@ Item *create_func_cast(Item *a, Cast_target cast_type, const char *c_len, const char *c_dec, CHARSET_INFO *cs) { - Item *res; + Item *res= 0; ulong len; uint dec; LINT_INIT(res); switch (cast_type) { @@ -471,13 +471,20 @@ return 0; } res= new Item_decimal_typecast(a, len, dec); break; case ITEM_CAST_CHAR: - len= c_len ? atoi(c_len) : -1; + errno= 0; + longlong len= c_len ? strtoul(c_len, 0,10) : -1LL; + if (errno != 0) + { + my_error( ER_TOO_BIG_FIELDLENGTH, MYF(0), "cast as char", 4294967295); + break; + } + res= new Item_char_typecast(a, len, cs ? cs : - current_thd->variables.collation_connection); + current_thd->variables.collation_connection); break; } return res; } --- ../mysql-5.0.bk-orig/./sql/item_timefunc.h Thu Mar 22 08:44:37 2007 +++ ./sql/item_timefunc.h Wed May 23 15:13:03 2007 @@ -753,16 +753,17 @@ }; class Item_char_typecast :public Item_typecast { - int cast_length; + // cast_length supports up to 4294967295, but also -1 + longlong cast_length; CHARSET_INFO *cast_cs, *from_cs; bool charset_conversion; String tmp_value; public: - Item_char_typecast(Item *a, int length_arg, CHARSET_INFO *cs_arg) + Item_char_typecast(Item *a, longlong length_arg, CHARSET_INFO *cs_arg) :Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {} enum Functype functype() const { return CHAR_TYPECAST_FUNC; } bool eq(const Item *item, bool binary_cmp) const; const char *func_name() const { return "cast_as_char"; } const char* cast_type() const { return "char"; }; --- ../mysql-5.0.bk-orig/./sql/sql_yacc.yy Tue May 15 10:56:05 2007 +++ ./sql/sql_yacc.yy Tue May 22 17:21:03 2007 @@ -3295,12 +3295,15 @@ SIGNED_SYM {} | UNSIGNED { Lex->type|= UNSIGNED_FLAG;} | ZEROFILL { Lex->type|= UNSIGNED_FLAG | ZEROFILL_FLAG; }; opt_len: - /* empty */ { Lex->length=(char*) 0; } /* use default length */ - | '(' NUM ')' { Lex->length= $2.str; }; + /* empty */ { Lex->length=(char*) 0; } /* use default length */ + | '(' NUM ')' { Lex->length= $2.str; } + | '(' LONG_NUM ')' { Lex->length= $2.str; } + | '(' ULONGLONG_NUM ')' { Lex->length= $2.str; } + | '(' DECIMAL_NUM ')' { Lex->length= $2.str; }; opt_precision: /* empty */ {} | precision {}; --- ../mysql-5.0.bk-orig/./mysql-test/t/type_blob.test Wed Feb 14 13:44:31 2007 +++ ./mysql-test/t/type_blob.test Wed May 23 14:36:36 2007 @@ -24,10 +24,88 @@ show create TABLE t3; show create TABLE t4; drop table t1,t2,t3,t4; # +# BUG #15776: longblob/text can be up to 4294967295 +# + +CREATE TABLE t1 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) ); +show columns from t1; +drop table t1; +--error ER_TOO_BIG_FIELDLENGTH +CREATE TABLE t1 (a blob(4294967296)); +--error ER_TOO_BIG_FIELDLENGTH +CREATE TABLE t1 (a text(4294967296)); +--error ER_TOO_BIG_FIELDLENGTH +CREATE TABLE t1 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--error ER_TOO_BIG_FIELDLENGTH +CREATE TABLE t1 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); + +# BUG #15776: additional test, affecting other functions +--error ER_TOO_BIG_DISPLAYWIDTH +CREATE TABLE t1 (a int(4294967296)); +--error 1064 +CREATE TABLE t1 (a char(4294967296)); +CREATE TABLE t1 (a year(4294967296)); +show columns from t1; +drop table t1; +--error ER_TOO_BIG_DISPLAYWIDTH +CREATE TABLE t1 (a timestamp(4294967296)); + +--error ER_TOO_BIG_DISPLAYWIDTH +CREATE TABLE t1 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--error 1064 +CREATE TABLE t1 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +CREATE TABLE t1 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +show columns from t1; +drop table t1; +--error ER_TOO_BIG_DISPLAYWIDTH +CREATE TABLE t1 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); + +# do not select, to much memory needed +CREATE TABLE t1 select cast(null as char(4294967295)); +show columns from t1; +drop table t1; +CREATE TABLE t1 select cast(null as nchar(4294967295)); +show columns from t1; +drop table t1; +CREATE TABLE t1 select cast(null as binary(4294967295)); +show columns from t1; +drop table t1; + +explain select cast(1 as char(4294967295)); +explain select cast(1 as nchar(4294967295)); +explain select cast(1 as binary(4294967295)); + +--error 1074 +explain select cast(1 as char(4294967296)); +--error 1074 +explain select cast(1 as char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--error 1074 +explain select cast(1 as nchar(4294967296)); +--error 1074 +explain select cast(1 as nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--error 1074 +explain select cast(1 as binary(4294967296)); +--error 1074 +explain select cast(1 as binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); + +--error 1074 +explain select convert(1, char(4294967296)); +--error 1074 +explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--error 1074 +explain select convert(1, nchar(4294967296)); +--error 1074 +explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--error 1074 +explain select convert(1, binary(4294967296)); +--error 1074 +explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); + +# # Check errors with blob # --error 1074 CREATE TABLE t1 (a char(257) default "hello"); --- ../mysql-5.0.bk-orig/./mysql-test/r/type_blob.result Thu Mar 1 16:59:52 2007 +++ ./mysql-test/r/type_blob.result Wed May 23 18:15:44 2007 @@ -30,10 +30,98 @@ Table Create Table t4 CREATE TABLE `t4` ( `c` mediumtext character set utf8 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1,t2,t3,t4; +CREATE TABLE t1 (a blob(2147483647), b blob(2147483648), c blob(4294967295), a1 text(2147483647), b1 text(2147483648), c1 text(4294967295) ); +show columns from t1; +Field Type Null Key Default Extra +a longblob YES NULL +b longblob YES NULL +c longblob YES NULL +a1 longtext YES NULL +b1 longtext YES NULL +c1 longtext YES NULL +drop table t1; +CREATE TABLE t1 (a blob(4294967296)); +ERROR 42000: Column length too big for column 'a' (max = 4294967295); use BLOB or TEXT instead +CREATE TABLE t1 (a text(4294967296)); +ERROR 42000: Column length too big for column 'a' (max = 4294967295); use BLOB or TEXT instead +CREATE TABLE t1 (a blob(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'a' (max = 4294967295); use BLOB or TEXT instead +CREATE TABLE t1 (a text(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'a' (max = 4294967295); use BLOB or TEXT instead +CREATE TABLE t1 (a int(4294967296)); +ERROR 42000: Display width out of range for column 'a' (max = 255) +CREATE TABLE t1 (a char(4294967296)); +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 '4294967296))' at line 1 +CREATE TABLE t1 (a year(4294967296)); +show columns from t1; +Field Type Null Key Default Extra +a year(4) YES NULL +drop table t1; +CREATE TABLE t1 (a timestamp(4294967296)); +ERROR 42000: Display width out of range for column 'a' (max = 255) +CREATE TABLE t1 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Display width out of range for column 'a' (max = 255) +CREATE TABLE t1 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +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 '99999999999999999999999999999999999999999999999999999999999999999999999999999999' at line 1 +CREATE TABLE t1 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +show columns from t1; +Field Type Null Key Default Extra +a year(4) YES NULL +drop table t1; +CREATE TABLE t1 (a timestamp(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Display width out of range for column 'a' (max = 255) +CREATE TABLE t1 select cast(null as char(4294967295)); +show columns from t1; +Field Type Null Key Default Extra +cast(null as char(4294967295)) longtext YES NULL +drop table t1; +CREATE TABLE t1 select cast(null as nchar(4294967295)); +show columns from t1; +Field Type Null Key Default Extra +cast(null as nchar(4294967295)) longtext YES NULL +drop table t1; +CREATE TABLE t1 select cast(null as binary(4294967295)); +show columns from t1; +Field Type Null Key Default Extra +cast(null as binary(4294967295)) longblob YES NULL +drop table t1; +explain select cast(1 as char(4294967295)); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +explain select cast(1 as nchar(4294967295)); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +explain select cast(1 as binary(4294967295)); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +explain select cast(1 as char(4294967296)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select cast(1 as char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select cast(1 as nchar(4294967296)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select cast(1 as nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select cast(1 as binary(4294967296)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select cast(1 as binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select convert(1, char(4294967296)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select convert(1, char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select convert(1, nchar(4294967296)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select convert(1, nchar(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select convert(1, binary(4294967296)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead +explain select convert(1, binary(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +ERROR 42000: Column length too big for column 'cast as char' (max = 4294967295); use BLOB or TEXT instead CREATE TABLE t1 (a char(257) default "hello"); ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead CREATE TABLE t2 (a char(256)); ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead CREATE TABLE t1 (a varchar(70000) default "hello");