diff options
author | Martin Hansson <martin.hansson@sun.com> | 2009-09-07 16:52:47 +0200 |
---|---|---|
committer | Martin Hansson <martin.hansson@sun.com> | 2009-09-07 16:52:47 +0200 |
commit | fe3b6356ca924b2d1313417bcf5a302f0ba70869 (patch) | |
tree | 34178b5fb89dd1d4e6b9247917aae4d5288c7d31 | |
parent | bdd43744452eb5312f38b3f4fb9a88de35ed3eb4 (diff) | |
parent | 2cb3a131f47a8bcf0398a28e4a6a16d1c30c9708 (diff) | |
download | mariadb-git-fe3b6356ca924b2d1313417bcf5a302f0ba70869.tar.gz |
Bug#46259: Merge
-rw-r--r-- | mysql-test/r/udf.result | 16 | ||||
-rw-r--r-- | mysql-test/t/udf.test | 12 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 8 |
3 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 15410ac2039..601b364fbbe 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -392,4 +392,20 @@ a 4 DROP FUNCTION sequence; DROP TABLE t1,t2; +# +# Bug#46259: 5.0.83 -> 5.1.36, query doesn't work +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (2), (3); +SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b` + 1, 1 ); +b +1 +2 +3 +SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b`, 1 ); +b +2 +3 +1 +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index e9ae1a31079..7bf252040e5 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -436,4 +436,16 @@ SELECT * FROM t2 WHERE a = sequence(); DROP FUNCTION sequence; DROP TABLE t1,t2; +--echo # +--echo # Bug#46259: 5.0.83 -> 5.1.36, query doesn't work +--echo # +CREATE TABLE t1 ( a INT ); + +INSERT INTO t1 VALUES (1), (2), (3); + +SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b` + 1, 1 ); +SELECT IF( a = 1, a, a ) AS `b` FROM t1 ORDER BY field( `b`, 1 ); + +DROP TABLE t1; + --echo End of 5.0 tests. diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a18f57bf9cf..db97e77bbd0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7921,7 +7921,13 @@ udf_expr: $2->is_autogenerated_name= FALSE; $2->set_name($4.str, $4.length, system_charset_info); } - else + /* + A field has to have its proper name in order for name + resolution to work, something we are only guaranteed if we + parse it out. If we hijack the input stream with + remember_name we may get quoted or escaped names. + */ + else if ($2->type() != Item::FIELD_ITEM) $2->set_name($1, (uint) ($3 - $1), YYTHD->charset()); $$= $2; } |