summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2005-08-10 17:45:00 +0400
committerunknown <evgen@moonbone.local>2005-08-10 17:45:00 +0400
commite66cd71698e033c788adb6364fdf261143fb5601 (patch)
tree9daa110455c864e4bfbf2f5a8c350de43a71686e /mysql-test
parentaa337b1d5e0de234458b15d4eeead1ff5df45822 (diff)
downloadmariadb-git-e66cd71698e033c788adb6364fdf261143fb5601.tar.gz
Fix bug #11864 non unique names are allowed in subquery
Column names weren't checked for uniqueness for subqueries. Code for names uniqueness checking used for view creation moved into separate function named check_duplicate_names(). It's called on preparation of subqueries to check uniqueness of names. If duplicate names are found then error is raised. sql/sql_derived.cc: Fix bug #11864 non unique names are allowed in subquery Added check for names uniqueness in select list. sql/sql_view.cc: Fix bug #11864 non unique names are allowed in subquery Code for checking uniqueness of names in item list moved into separate function to make in available for use from other places. sql/sql_view.h: Fix bug #11864 non unique names are allowed in subquery Added check_duplicate_names() function prototype. mysql-test/t/derived.test: Fixed test case results after bug fix #11864 Added test case for bug#11864 non unique names are allowed in subquery. mysql-test/t/select_safe.test: Fixed test case results after bug fix #11864 mysql-test/r/derived.result: Added test case for bug #11864 non unique names are allowed in subquery. Fixed test case results after bug fix #11864 mysql-test/r/select_safe.result: Fixed test case results after bug fix #11864
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/derived.result7
-rw-r--r--mysql-test/r/select_safe.result2
-rw-r--r--mysql-test/t/derived.test11
-rw-r--r--mysql-test/t/select_safe.test2
4 files changed, 18 insertions, 4 deletions
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index fd6a834c694..af0f190d917 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -111,7 +111,7 @@ a b
1 a
2 b
3 c
-explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
+explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED t2 system NULL NULL NULL NULL 1
@@ -363,3 +363,8 @@ a
3
3
drop table t1, t2, t3;
+create table t1 (a int);
+create table t2 (a int);
+select * from (select * from t1,t2) foo;
+ERROR 42S21: Duplicate column name 'a'
+drop table t1,t2;
diff --git a/mysql-test/r/select_safe.result b/mysql-test/r/select_safe.result
index 5d458c40f34..feac9efcb13 100644
--- a/mysql-test/r/select_safe.result
+++ b/mysql-test/r/select_safe.result
@@ -84,7 +84,7 @@ set local max_join_size=8;
select * from (select * from t1) x;
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
set local max_join_size=1;
-select * from (select * from t1 a, t1 b) x;
+select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x;
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
set local max_join_size=1;
select * from (select 1 union select 2 union select 3) x;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 8d51b4666e7..f52e12849e4 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -42,7 +42,7 @@ CREATE TABLE t2 (a int not null);
insert into t2 values(1);
select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
-explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
+explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
drop table t1, t2;
create table t1(a int not null, t char(8), index(a));
disable_query_log;
@@ -249,4 +249,13 @@ select * from t1 union distinct select * from t2 union all select * from t3;
select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
drop table t1, t2, t3;
+#
+# Bug #11864 non unique names are allowed in subquery
+#
+create table t1 (a int);
+create table t2 (a int);
+--error 1060
+select * from (select * from t1,t2) foo;
+drop table t1,t2;
+
# End of 4.1 tests
diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test
index 1da700c9adf..481779e76d7 100644
--- a/mysql-test/t/select_safe.test
+++ b/mysql-test/t/select_safe.test
@@ -78,7 +78,7 @@ select * from (select * from t1) x;
set local max_join_size=1;
--error 1104
-select * from (select * from t1 a, t1 b) x;
+select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x;
set local max_join_size=1;
--error 1104