Hi Sergei,
Sergei Golubchik edited comment on MDEV-7062 at 11/10/14 11:40 AM: -------------------------------------------------------------------
http://lists.askmonty.org/pipermail/commits/2014-November/006908.html
{noformat} From: serg@mariadb.org To: commits@mariadb.org Subject: [Commits] 2c904b9: parser cleanup: don't store field properties in LEX, use Create_field directly Date: Mon, 10 Nov 2014 10:26:48 +0100 {noformat}
Please find my comments below:
[Commits] 2c904b9: parser cleanup: don't store field properties in LEX, use Create_field directly serg at mariadb.org serg at mariadb.org Mon Nov 10 11:26:48 EET 2014
Previous message: [Commits] Rev 4344: MDEV-6179: dynamic columns functions/cast()/convert() doesn't play nice with CREATE/ALTER TABLE in lp:~maria-captains/maria/5.5 Next message: [Commits] Rev 4345: MDEV-6862 "#error <my_config.h>" and third-party libraries in lp:~maria-captains/maria/5.5 Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
revision-id: 2c904b937b5ef7fbec60ebb9cb514a501c5bd8e4 parent(s): f59588b9112965849986c45fcd150d9abed74063 committer: Sergei Golubchik branch nick: maria timestamp: 2014-11-09 22:33:17 +0100 message:
parser cleanup: don't store field properties in LEX, use Create_field directly
length/dec/charset are still in LEX, because they're also used for CAST and dynamic columns.
also 1. fix "MDEV-7041 COLLATION(CAST('a' AS CHAR BINARY)) returns a wrong result" 2. allow BINARY modifier in stored function RETURN clause 3. allow "COLLATION without CHARSET" in SP/SF (parameters, RETURN, DECLARE) 4. print correct variable name in error messages for stored routine parameters
A very nice clean up. I only found it a little bit not easy to track that all Lex and Create_field attributes get initialized and copied to each other properly. I suggest to go a little bit further and get rid from Lex->dec, Lex->length and Lex->charset at all, and write the attributes directly to the destination as soon as they get parsed. See a proposed addon patch attached.
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index c81af13..8ad4568 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -796,3 +796,32 @@ DATE("foo") NULL Warnings: Warning 1292 Incorrect datetime value: 'foo' +create table t1 (a int, b char(5) as (cast("a" as char(10) binary) + a) ); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` char(5) AS (cast("a" as char(10) binary) + a) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select collation(cast("a" as char(10) binary)); +collation(cast("a" as char(10) binary)) +latin1_bin +select collation(cast("a" as char(10) charset utf8 binary)); +collation(cast("a" as char(10) charset utf8 binary)) +utf8_bin +select collation(cast("a" as char(10) ascii binary)); +collation(cast("a" as char(10) ascii binary)) +latin1_bin +select collation(cast("a" as char(10) unicode binary)); +collation(cast("a" as char(10) unicode binary)) +ucs2_bin
UNICODE is an alias for UCS2, which is not always compiled. Please move ucs2 related tests to ctype_ucs.test. <skip>
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index b6c37ca..aa43ee6 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -456,3 +456,21 @@ SELECT CAST(TIME('10:20:30') AS DATE) + INTERVAL 1 DAY; SET SQL_MODE=ALLOW_INVALID_DATES; SELECT DATE("foo");
+# +# CAST and field definition using same fields in LEX +# +create table t1 (a int, b char(5) as (cast("a" as char(10) binary) + a) ); +show create table t1; +drop table t1; + +# +# CAST (... BINARY) +# +select collation(cast("a" as char(10) binary)); +select collation(cast("a" as char(10) charset utf8 binary)); +select collation(cast("a" as char(10) ascii binary)); +select collation(cast("a" as char(10) unicode binary)); +select collation(cast("a" as char(10) binary charset utf8)); +select collation(cast("a" as char(10) binary ascii)); +select collation(cast("a" as char(10) binary unicode));
More UCS2. You removed this code in field.cc:
- 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= NULL; /* purecov: inspected */ - }
and added this in sql_yacc.yy:
+ if (length) + { + int err; + last_field->length= (ulong)my_strtoll10(length, NULL, &err); + if (err) + last_field->length= ~0UL; // safety + } + else + last_field->length= 0;
I have a feeling that on a 32bit platforms it will stop sending errors on attempt to create a blob larger that 4Gb. last_field->length is ulong, which is 32bit is a 32 bit platform, and it gets assigned to a 64 bit value.