Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
4957c485
Commit
4957c485
authored
Feb 13, 2005
by
acurtis@pcgem.rdg.cyberkinetica.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#2435
Alter handling for UNION syntax Tests for UNION and parentheses
parent
961d8b0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
7 deletions
+62
-7
mysql-test/r/union.result
mysql-test/r/union.result
+22
-0
mysql-test/t/union.test
mysql-test/t/union.test
+12
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+28
-7
No files found.
mysql-test/r/union.result
View file @
4957c485
...
@@ -1173,3 +1173,25 @@ show columns from t4;
...
@@ -1173,3 +1173,25 @@ show columns from t4;
Field Type Null Key Default Extra
Field Type Null Key Default Extra
sdate date YES NULL
sdate date YES NULL
drop table t1, t2, t3, t4;
drop table t1, t2, t3, t4;
create table t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
select * from ((select * from t1 limit 1)) a;
a b
1 a
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a;
a b
1 a
select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a;
a b
1 a
2 b
3 c
select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a;
a b
1 a
2 b
3 c
drop table t1;
mysql-test/t/union.test
View file @
4957c485
...
@@ -699,3 +699,15 @@ union
...
@@ -699,3 +699,15 @@ union
order
by
sdate
;
order
by
sdate
;
show
columns
from
t4
;
show
columns
from
t4
;
drop
table
t1
,
t2
,
t3
,
t4
;
drop
table
t1
,
t2
,
t3
,
t4
;
#
# Bug #2435 UNION with parentheses not supported
#
create
table
t1
(
a
int
not
null
,
b
char
(
10
)
not
null
);
insert
into
t1
values
(
1
,
'a'
),(
2
,
'b'
),(
3
,
'c'
),(
3
,
'c'
);
select
*
from
((
select
*
from
t1
limit
1
))
a
;
select
*
from
((
select
*
from
t1
limit
1
)
union
(
select
*
from
t1
limit
1
))
a
;
select
*
from
((
select
*
from
t1
limit
1
)
union
(
select
*
from
t1
limit
1
)
union
(
select
*
from
t1
limit
1
))
a
;
select
*
from
((((
select
*
from
t1
)))
union
(
select
*
from
t1
)
union
(
select
*
from
t1
))
a
;
select
*
from
((
select
*
from
t1
)
union
(((
select
*
from
t1
)))
union
(
select
*
from
t1
))
a
;
drop
table
t1
;
sql/sql_yacc.yy
View file @
4957c485
...
@@ -2389,7 +2389,10 @@ select:
...
@@ -2389,7 +2389,10 @@ select:
select_init:
select_init:
SELECT_SYM select_init2
SELECT_SYM select_init2
|
|
'(' SELECT_SYM select_part2 ')'
'(' select_paren ')' union_opt;
select_paren:
SELECT_SYM select_part2
{
{
LEX *lex= Lex;
LEX *lex= Lex;
SELECT_LEX * sel= lex->current_select;
SELECT_LEX * sel= lex->current_select;
...
@@ -2408,7 +2411,8 @@ select_init:
...
@@ -2408,7 +2411,8 @@ select_init:
if (sel->master_unit()->fake_select_lex)
if (sel->master_unit()->fake_select_lex)
sel->master_unit()->global_parameters=
sel->master_unit()->global_parameters=
sel->master_unit()->fake_select_lex;
sel->master_unit()->fake_select_lex;
} union_opt;
}
| '(' select_paren ')';
select_init2:
select_init2:
select_part2
select_part2
...
@@ -3404,8 +3408,7 @@ when_list2:
...
@@ -3404,8 +3408,7 @@ when_list2:
};
};
join_table_list:
join_table_list:
'(' join_table_list ')' { $$=$2; }
join_table { $$=$1; }
| join_table { $$=$1; }
| join_table_list ',' join_table_list { $$=$3; }
| join_table_list ',' join_table_list { $$=$3; }
| join_table_list normal_join join_table_list { $$=$3; }
| join_table_list normal_join join_table_list { $$=$3; }
| join_table_list STRAIGHT_JOIN join_table_list
| join_table_list STRAIGHT_JOIN join_table_list
...
@@ -3482,7 +3485,7 @@ join_table:
...
@@ -3482,7 +3485,7 @@ join_table:
}
}
| '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}'
| '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}'
{ add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; }
{ add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; }
| '('
SELECT_SYM select_derived
')' opt_table_alias
| '('
select_derived union_opt
')' opt_table_alias
{
{
LEX *lex=Lex;
LEX *lex=Lex;
SELECT_LEX_UNIT *unit= lex->current_select->master_unit();
SELECT_LEX_UNIT *unit= lex->current_select->master_unit();
...
@@ -3493,9 +3496,27 @@ join_table:
...
@@ -3493,9 +3496,27 @@ join_table:
(List<String> *)0)))
(List<String> *)0)))
YYABORT;
YYABORT;
};
}
| '(' join_table_list ')' { $$=$2; };
select_derived:
select_derived:
SELECT_SYM select_derived2
| '(' select_derived ')'
{
LEX *lex= Lex;
SELECT_LEX * sel= lex->current_select;
if (sel->set_braces(1))
{
yyerror(ER(ER_SYNTAX_ERROR));
YYABORT;
}
/* select in braces, can't contain global parameters */
if (sel->master_unit()->fake_select_lex)
sel->master_unit()->global_parameters=
sel->master_unit()->fake_select_lex;
};
select_derived2:
{
{
LEX *lex= Lex;
LEX *lex= Lex;
lex->derived_tables= 1;
lex->derived_tables= 1;
...
@@ -3517,7 +3538,7 @@ select_derived:
...
@@ -3517,7 +3538,7 @@ select_derived:
{
{
Select->parsing_place= NO_MATTER;
Select->parsing_place= NO_MATTER;
}
}
opt_select_from
union_opt
opt_select_from
;
;
opt_outer:
opt_outer:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment