Commit 66e3b9d7 authored by unknown's avatar unknown

many, many changes


mysql-test/r/subselect.result:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
include/mysqld_error.h:
  Merging changes ...
mysql-test/t/subselect.test:
  Merging changes ...
sql/share/czech/errmsg.txt:
  Merging changes ...
sql/share/danish/errmsg.txt:
  Merging changes ...
sql/share/dutch/errmsg.txt:
  Merging changes ...
sql/share/english/errmsg.txt:
  Merging changes ...
sql/share/estonian/errmsg.txt:
  Merging changes ...
sql/share/french/errmsg.txt:
  Merging changes ...
sql/share/german/errmsg.txt:
  Merging changes ...
sql/share/greek/errmsg.txt:
  Merging changes ...
sql/share/hungarian/errmsg.txt:
  Merging changes ...
sql/share/italian/errmsg.txt:
  Merging changes ...
sql/share/japanese/errmsg.txt:
  Merging changes ...
sql/share/korean/errmsg.txt:
  Merging changes ...
sql/share/norwegian-ny/errmsg.txt:
  Merging changes ...
sql/share/norwegian/errmsg.txt:
  Merging changes ...
sql/share/polish/errmsg.txt:
  Merging changes ...
sql/share/portuguese/errmsg.txt:
  Merging changes ...
sql/share/romanian/errmsg.txt:
  Merging changes ...
sql/share/russian/errmsg.txt:
  Merging changes ...
sql/share/serbian/errmsg.txt:
  Merging changes ...
sql/share/slovak/errmsg.txt:
  Merging changes ...
sql/share/spanish/errmsg.txt:
  Merging changes ...
sql/share/swedish/errmsg.txt:
  Merging changes ...
sql/share/ukrainian/errmsg.txt:
  Merging changes ...
parents b226e15a 1b921a99
......@@ -262,5 +262,6 @@
#define ER_CYCLIC_REFERENCE 1243
#define ER_AUTO_CONVERT 1244
#define ER_ILLEGAL_REFERENCE 1245
#define ER_SELECT_REDUCED 1246
#define ER_ERROR_MESSAGES 247
#define ER_DERIVED_MUST_HAVE_ALIAS 1246
#define ER_SELECT_REDUCED 1247
#define ER_ERROR_MESSAGES 248
......@@ -17,32 +17,32 @@ select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3
a y
3 3
3 3
SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1);
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
Unknown column 'a' in 'having clause'
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1;
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
Column: 'a' in having clause is ambiguous
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2;
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
a a
1 2
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1;
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
a a
SELECT 1 FROM (SELECT 1) WHERE a=2;
SELECT 1 FROM (SELECT 1) a WHERE a=2;
Unknown column 'a' in 'where clause'
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
Unknown column 'a' in 'having clause'
drop table if exists t1.t2,t3;
select * from (select 1);
select * from (select 1) as a;
1
1
select a from (select 1 as a);
select a from (select 1 as a) as b;
a
1
select 1 from (select 1);
select 1 from (select 1) as a;
1
1
drop table if exists t1;
create table t1(a int not null, t char(8), index(a));
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
a t
1 1
2 2
......@@ -64,7 +64,13 @@ a t
18 18
19 19
20 20
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Select tables optimized away
drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a)));
(SELECT * FROM (SELECT 1 as a))
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
(SELECT * FROM (SELECT 1 as a) as a )
1
select * from (select 1 as a) b left join (select 2 as a) c using(a);
a a
1 NULL
SELECT 1 FROM (SELECT 1) GROUP BY SUM(1);
SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
Invalid use of group function
drop table if exists t1,t2,t3;
CREATE TABLE t1 (
......
......@@ -168,7 +168,7 @@ test2 2 2
SELECT FOUND_ROWS();
FOUND_ROWS()
2
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
1
SELECT FOUND_ROWS();
FOUND_ROWS()
......
......@@ -8,29 +8,29 @@ SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0));
(SELECT (SELECT 0 UNION SELECT 0))
0
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
Reference 'a' not supported (forward reference in item list)
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
Reference 'b' not supported (forward reference in item list)
SELECT (SELECT 1),MAX(1) FROM (SELECT 1);
SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
(SELECT 1) MAX(1)
1 1
SELECT (SELECT a) as a;
Reference 'a' not supported (forward reference in item list)
EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
3 DEPENDENT SUBSELECT No tables used
2 DERIVED No tables used
SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
SELECT (SELECT 1), a;
Unknown column 'a' in 'field list'
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
a
1
SELECT 1 FROM (SELECT (SELECT a));
SELECT 1 FROM (SELECT (SELECT a) b) c;
Unknown column 'a' in 'field list'
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
id
......@@ -319,7 +319,7 @@ SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='j
numeropost maxnumrep
43506 2
40143 1
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
Unknown column 'a' in 'having clause'
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
Unknown column 'a' in 'having clause'
......@@ -368,7 +368,7 @@ Subselect returns more than 1 record
drop table t1;
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO t1 VALUES ();
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
Subselect returns more than 1 record
drop table t1;
CREATE TABLE `t1` (
......@@ -398,7 +398,7 @@ id select_type table type possible_keys key key_len ref rows Extra
drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
1
1
drop table t1;
......
......@@ -9,19 +9,19 @@ CREATE TABLE t3 (a int not null, b char (10) not null);
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
--error 1054
SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1);
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
--error 1052
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1;
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2;
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1;
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
--error 1054
SELECT 1 FROM (SELECT 1) WHERE a=2;
SELECT 1 FROM (SELECT 1) a WHERE a=2;
--error 1054
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
drop table if exists t1.t2,t3;
select * from (select 1);
select a from (select 1 as a);
select 1 from (select 1);
select * from (select 1) as a;
select a from (select 1 as a) as b;
select 1 from (select 1) as a;
drop table if exists t1;
create table t1(a int not null, t char(8), index(a));
disable_query_log;
......@@ -32,6 +32,8 @@ while ($1)
dec $1;
}
enable_query_log;
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a)));
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
select * from (select 1 as a) b left join (select 2 as a) c using(a);
-- error 1111
SELECT 1 FROM (SELECT 1) GROUP BY SUM(1);
SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
#
# Test of group (Failed for Lars Hoss <lh@pbm.de>)
#
......
......@@ -84,7 +84,7 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
('test1','1'),('test2','2'),('test3','3');
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
SELECT FOUND_ROWS();
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
SELECT FOUND_ROWS();
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
SELECT FOUND_ROWS();
......
......@@ -2,25 +2,25 @@ select (select 2);
SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0));
-- error 1245
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
-- error 1245
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
SELECT (SELECT 1),MAX(1) FROM (SELECT 1);
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
-- error 1245
SELECT (SELECT a) as a;
EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
-- error 1054
SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
-- error 1054
SELECT 1 FROM (SELECT (SELECT a) b) c;
SELECT 1 FROM (SELECT (SELECT a));
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
-- error 1239
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
......@@ -176,7 +176,7 @@ INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce
select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
-- error 1054
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
-- error 1054
SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date);
......@@ -210,7 +210,7 @@ drop table t1;
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO t1 VALUES ();
-- error 1240
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
drop table t1;
# threadhardwarefr7
......@@ -236,7 +236,7 @@ drop table t1;
CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
drop table t1;
#update with subselects
......
......@@ -256,4 +256,5 @@ v/*
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -250,4 +250,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -258,4 +258,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -252,4 +252,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -250,4 +250,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -249,4 +249,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -249,4 +249,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -249,4 +249,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -249,4 +249,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -251,4 +251,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -251,4 +251,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s"
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -250,4 +250,5 @@
" ",
" '%s' %s %s",
" '%-.64s' (%s)",
"Every derived table must have it's own alias"
"Select %u ",
......@@ -243,4 +243,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -255,4 +255,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -248,4 +248,5 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -247,4 +247,5 @@
"Syklisk referens i subselect",
"Konvertar kolumn '%s' från %s till %s",
"Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation",
......@@ -252,4 +252,5 @@
"̦ Ц",
" '%s' %s %s",
" '%-.64s' i (%s)",
"Every derived table must have it's own alias"
"Select %u was iii",
......@@ -1894,13 +1894,13 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
const char *name=item->field_name;
uint length=(uint) strlen(name);
if (table_name)
if (table_name && table_name[0])
{ /* Qualified field */
bool found_table=0;
for (; tables ; tables=tables->next)
{
if (!strcmp(tables->alias,table_name) &&
(!db || !strcmp(db,tables->db)))
(!db || !tables->db || !tables->db[0] || !strcmp(db,tables->db)))
{
found_table=1;
Field *find=find_field_in_table(thd,tables->table,name,length,
......
......@@ -106,7 +106,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
t->table=table;
table->derived_select_number= sl->select_number;
table->tmp_table=TMP_TABLE;
if (!lex->describe)
if (lex->describe)
sl->exclude();
t->db=(char *)"";
t->derived=(SELECT_LEX *)0; // just in case ...
......
......@@ -1205,6 +1205,8 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex,
net_printf(thd,ER_WRONG_USAGE,"UNION","ORDER BY");
return 1;
}
if (sl->linkage == DERIVED_TABLE_TYPE)
continue;
for (SELECT_LEX_UNIT *inner= sl->first_inner_unit();
inner;
inner= inner->next_unit())
......
......@@ -3404,8 +3404,15 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table,
}
if (!alias) /* Alias is case sensitive */
{
if (table->sel)
{
net_printf(thd,ER_DERIVED_MUST_HAVE_ALIAS);
DBUG_RETURN(0);
}
if (!(alias_str=thd->memdup(alias_str,table->table.length+1)))
DBUG_RETURN(0);
}
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
DBUG_RETURN(0); /* purecov: inspected */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment