diff options
author | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-11-10 18:43:43 -0200 |
---|---|---|
committer | Davi Arnaut <Davi.Arnaut@Sun.COM> | 2009-11-10 18:43:43 -0200 |
commit | ff847056319f41cd8b6c70833ec3647146d12c72 (patch) | |
tree | fed1d3717bed422e5e9dbacb0b35b0254b93b200 /mysql-test/t/alias.test | |
parent | e879919a9f7bb3681bc4a8522c30e335d1fc28ce (diff) | |
download | mariadb-git-ff847056319f41cd8b6c70833ec3647146d12c72.tar.gz |
Backport of Bug#27249 to mysql-next-mr
------------------------------------------------------------
revno: 2476.784.4
revision-id: sp1r-davi@moksha.local-20071008114751-46069
parent: sp1r-davi@moksha.local-20071003002731-48537
committer: davi@moksha.local
timestamp: Mon 2007-10-08 08:47:51 -0300
message:
Bug#27249 table_wild with alias: select t1.* as something
Aliases to table wildcards are silently ignored, but they should
not be allowed as it is non-standard and currently useless. There
is not point in having a alias to a wildcard of column names.
The solution is to rewrite the select_item rule so that aliases
for table wildcards are not accepted.
Contribution by Martin Friebe
mysql-test/r/alias.result:
Add test case result for Bug#27249
mysql-test/t/alias.test:
Add test case for Bug#27249
sql/sql_yacc.yy:
Split up select_item rule so that aliases for table wildcards
are not accepted by the parser.
Diffstat (limited to 'mysql-test/t/alias.test')
-rw-r--r-- | mysql-test/t/alias.test | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test index 6546581eef2..0e2d57598e2 100644 --- a/mysql-test/t/alias.test +++ b/mysql-test/t/alias.test @@ -86,3 +86,132 @@ ASC LIMIT 1; drop table t1; # End of 4.1 tests + +# +# Bug#27249 table_wild with alias: select t1.* as something +# + +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings + +create table t1 (a int, b int, c int); +create table t2 (d int); +create table t3 (a1 int, b1 int, c1 int); +insert into t1 values(1,2,3); +insert into t1 values(11,22,33); +insert into t2 values(99); + +# Invalid queries with alias on wild +--error ER_PARSE_ERROR +select t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +select t2.* as 'with_alias' from t2; +--error ER_PARSE_ERROR +select t1.*, t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', t1.* from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', t1.* as 'alias2' from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', a, t1.* as 'alias2' from t1; + +# other fields without alias +--error ER_PARSE_ERROR +select a, t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', a from t1; +--error ER_PARSE_ERROR +select a, t1.* as 'with_alias', b from t1; +--error ER_PARSE_ERROR +select (select d from t2 where d > a), t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', (select a from t2 where d > a) from t1; + +# other fields with alias +--error ER_PARSE_ERROR +select a as 'x', t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', a as 'x' from t1; +--error ER_PARSE_ERROR +select a as 'x', t1.* as 'with_alias', b as 'x' from t1; +--error ER_PARSE_ERROR +select (select d from t2 where d > a) as 'x', t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +select t1.* as 'with_alias', (select a from t2 where d > a) as 'x' from t1; + +# some more subquery +--error ER_PARSE_ERROR +select (select t2.* as 'x' from t2) from t1; +--error ER_PARSE_ERROR +select a, (select t2.* as 'x' from t2) from t1; +--error ER_PARSE_ERROR +select t1.*, (select t2.* as 'x' from t2) from t1; + +# insert +--error ER_PARSE_ERROR +insert into t3 select t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +insert into t3 select t2.* as 'with_alias', 1, 2 from t2; +--error ER_PARSE_ERROR +insert into t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2; +--error ER_PARSE_ERROR +insert into t3 select t2.*, t2.* as 'with_alias', 3 from t2; + +# create +--error ER_PARSE_ERROR +create table t3 select t1.* as 'with_alias' from t1; +--error ER_PARSE_ERROR +create table t3 select t2.* as 'with_alias', 1, 2 from t2; +--error ER_PARSE_ERROR +create table t3 select t2.* as 'with_alias', d as 'x', d as 'z' from t2; +--error ER_PARSE_ERROR +create table t3 select t2.*, t2.* as 'with_alias', 3 from t2; + +# +# Valid queries without alias on wild +# (proof the above fail due to invalid aliasing) +# + +select t1.* from t1; +select t2.* from t2; +select t1.*, t1.* from t1; +select t1.*, a, t1.* from t1; + +# other fields without alias +select a, t1.* from t1; +select t1.*, a from t1; +select a, t1.*, b from t1; +select (select d from t2 where d > a), t1.* from t1; +select t1.*, (select a from t2 where d > a) from t1; + +# other fields with alias +select a as 'x', t1.* from t1; +select t1.*, a as 'x' from t1; +select a as 'x', t1.*, b as 'x' from t1; +select (select d from t2 where d > a) as 'x', t1.* from t1; +select t1.*, (select a from t2 where d > a) as 'x' from t1; + +# some more subquery +select (select t2.* from t2) from t1; +select a, (select t2.* from t2) from t1; +select t1.*, (select t2.* from t2) from t1; + +# insert +insert into t3 select t1.* from t1; +insert into t3 select t2.*, 1, 2 from t2; +insert into t3 select t2.*, d as 'x', d as 'z' from t2; +insert into t3 select t2.*, t2.*, 3 from t2; + +# create +create table t4 select t1.* from t1; +drop table t4; +create table t4 select t2.*, 1, 2 from t2; +drop table t4; +create table t4 select t2.*, d as 'x', d as 'z' from t2; +drop table t4; + +# end +drop table t1,t2,t3; + +# End of 5.2 tests |