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
c4637293
Commit
c4637293
authored
Apr 23, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-order-4.1
parents
a3d3937a
c96e5884
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
13 deletions
+76
-13
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+8
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+5
-0
sql/sql_lex.cc
sql/sql_lex.cc
+46
-9
sql/sql_lex.h
sql/sql_lex.h
+8
-0
sql/sql_parse.cc
sql/sql_parse.cc
+8
-3
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
No files found.
mysql-test/r/subselect.result
View file @
c4637293
...
@@ -458,6 +458,14 @@ Subselect returns more than 1 record
...
@@ -458,6 +458,14 @@ Subselect returns more than 1 record
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
Subselect returns more than 1 record
Subselect returns more than 1 record
drop table t1;
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
(select * from t1) union (select * from t1) order by (select a from t1 limit 1);
a
1
2
3
drop table t1;
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO t1 VALUES ();
INSERT INTO t1 VALUES ();
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
...
...
mysql-test/t/subselect.test
View file @
c4637293
...
@@ -244,6 +244,11 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
...
@@ -244,6 +244,11 @@ select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
select
numeropost
as
a
FROM
t1
ORDER
BY
(
SELECT
1
FROM
t1
HAVING
a
=
1
);
select
numeropost
as
a
FROM
t1
ORDER
BY
(
SELECT
1
FROM
t1
HAVING
a
=
1
);
drop
table
t1
;
drop
table
t1
;
create
table
t1
(
a
int
);
insert
into
t1
values
(
1
),(
2
),(
3
);
(
select
*
from
t1
)
union
(
select
*
from
t1
)
order
by
(
select
a
from
t1
limit
1
);
drop
table
t1
;
#iftest
#iftest
CREATE
TABLE
t1
(
field
char
(
1
)
NOT
NULL
DEFAULT
'b'
);
CREATE
TABLE
t1
(
field
char
(
1
)
NOT
NULL
DEFAULT
'b'
);
INSERT
INTO
t1
VALUES
();
INSERT
INTO
t1
VALUES
();
...
...
sql/sql_lex.cc
View file @
c4637293
...
@@ -1203,23 +1203,60 @@ TABLE_LIST *st_select_lex_node::add_table_to_list(THD *thd, Table_ident *table,
...
@@ -1203,23 +1203,60 @@ TABLE_LIST *st_select_lex_node::add_table_to_list(THD *thd, Table_ident *table,
}
}
ulong
st_select_lex_node
::
get_table_join_options
()
{
return
0
;
}
ulong
st_select_lex_node
::
get_table_join_options
()
{
return
0
;
}
/*
This is used for UNION & subselect to create a new table list of all used
tables.
The table_list->table entry in all used tables are set to point
to the entries in this list.
*/
// interface
/*
Interface method of table list creation for query
SYNOPSIS
st_select_lex_unit::create_total_list()
thd THD pointer
result pointer on result list of tables pointer
check_derived force derived table chacking (used for creating
table list for derived query)
DESCRIPTION
This is used for UNION & subselect to create a new table list of all used
tables.
The table_list->table entry in all used tables are set to point
to the entries in this list.
RETURN
0 - OK
!0 - error
*/
bool
st_select_lex_unit
::
create_total_list
(
THD
*
thd
,
st_lex
*
lex
,
bool
st_select_lex_unit
::
create_total_list
(
THD
*
thd
,
st_lex
*
lex
,
TABLE_LIST
**
result
,
TABLE_LIST
**
result
,
bool
check_derived
)
bool
check_derived
)
{
{
*
result
=
0
;
*
result
=
0
;
return
create_total_list_n_last_return
(
thd
,
lex
,
&
result
,
check_derived
);
for
(
SELECT_LEX_UNIT
*
unit
=
this
;
unit
;
unit
=
unit
->
next_unit
())
{
if
((
res
=
unit
->
create_total_list_n_last_return
(
thd
,
lex
,
&
result
,
check_derived
)))
return
res
;
}
return
0
;
}
}
// list creator
/*
Table list creation for query
SYNOPSIS
st_select_lex_unit::create_total_list()
thd THD pointer
lex pointer on LEX stricture
result pointer on pointer on result list of tables pointer
check_derived force derived table chacking (used for creating
table list for derived query)
DESCRIPTION
This is used for UNION & subselect to create a new table list of all used
tables.
The table_list->table entry in all used tables are set to point
to the entries in this list.
RETURN
0 - OK
!0 - error
*/
bool
st_select_lex_unit
::
create_total_list_n_last_return
(
THD
*
thd
,
st_lex
*
lex
,
bool
st_select_lex_unit
::
create_total_list_n_last_return
(
THD
*
thd
,
st_lex
*
lex
,
TABLE_LIST
***
result
,
TABLE_LIST
***
result
,
bool
check_derived
)
bool
check_derived
)
...
...
sql/sql_lex.h
View file @
c4637293
...
@@ -230,6 +230,7 @@ public:
...
@@ -230,6 +230,7 @@ public:
virtual
st_select_lex_unit
*
master_unit
()
=
0
;
virtual
st_select_lex_unit
*
master_unit
()
=
0
;
virtual
st_select_lex
*
outer_select
()
=
0
;
virtual
st_select_lex
*
outer_select
()
=
0
;
virtual
st_select_lex_node
*
return_after_parsing
()
=
0
;
virtual
bool
set_braces
(
bool
value
);
virtual
bool
set_braces
(
bool
value
);
virtual
bool
inc_in_sum_expr
();
virtual
bool
inc_in_sum_expr
();
...
@@ -284,6 +285,8 @@ public:
...
@@ -284,6 +285,8 @@ public:
global parameters for union
global parameters for union
*/
*/
st_select_lex_node
*
global_parameters
;
st_select_lex_node
*
global_parameters
;
//node on wich we should return current_select pointer after parsing subquery
st_select_lex_node
*
return_to
;
/* LIMIT clause runtime counters */
/* LIMIT clause runtime counters */
ha_rows
select_limit_cnt
,
offset_limit_cnt
;
ha_rows
select_limit_cnt
,
offset_limit_cnt
;
/* not NULL if union used in subselect, point to subselect item */
/* not NULL if union used in subselect, point to subselect item */
...
@@ -304,6 +307,7 @@ public:
...
@@ -304,6 +307,7 @@ public:
(
st_select_lex
*
)
slave
->
next
:
(
st_select_lex
*
)
slave
;
(
st_select_lex
*
)
slave
->
next
:
(
st_select_lex
*
)
slave
;
}
}
st_select_lex_unit
*
next_unit
()
{
return
(
st_select_lex_unit
*
)
next
;
}
st_select_lex_unit
*
next_unit
()
{
return
(
st_select_lex_unit
*
)
next
;
}
st_select_lex_node
*
return_after_parsing
()
{
return
return_to
;
}
void
exclude_level
();
void
exclude_level
();
/* UNION methods */
/* UNION methods */
...
@@ -366,6 +370,10 @@ public:
...
@@ -366,6 +370,10 @@ public:
{
{
return
&
link_next
;
return
&
link_next
;
}
}
st_select_lex_node
*
return_after_parsing
()
{
return
master_unit
()
->
return_after_parsing
();
}
bool
set_braces
(
bool
value
);
bool
set_braces
(
bool
value
);
bool
inc_in_sum_expr
();
bool
inc_in_sum_expr
();
...
...
sql/sql_parse.cc
View file @
c4637293
...
@@ -3235,7 +3235,8 @@ mysql_init_query(THD *thd)
...
@@ -3235,7 +3235,8 @@ mysql_init_query(THD *thd)
lex
->
select_lex
.
init_query
();
lex
->
select_lex
.
init_query
();
lex
->
value_list
.
empty
();
lex
->
value_list
.
empty
();
lex
->
param_list
.
empty
();
lex
->
param_list
.
empty
();
lex
->
unit
.
next
=
lex
->
unit
.
master
=
lex
->
unit
.
link_next
=
0
;
lex
->
unit
.
next
=
lex
->
unit
.
master
=
lex
->
unit
.
return_to
=
lex
->
unit
.
link_next
=
0
;
lex
->
unit
.
prev
=
lex
->
unit
.
link_prev
=
0
;
lex
->
unit
.
prev
=
lex
->
unit
.
link_prev
=
0
;
lex
->
unit
.
global_parameters
=
lex
->
unit
.
slave
=
lex
->
current_select
=
lex
->
unit
.
global_parameters
=
lex
->
unit
.
slave
=
lex
->
current_select
=
lex
->
all_selects_list
=
&
lex
->
select_lex
;
lex
->
all_selects_list
=
&
lex
->
select_lex
;
...
@@ -3283,9 +3284,9 @@ bool
...
@@ -3283,9 +3284,9 @@ bool
mysql_new_select
(
LEX
*
lex
,
bool
move_down
)
mysql_new_select
(
LEX
*
lex
,
bool
move_down
)
{
{
SELECT_LEX
*
select_lex
=
new
SELECT_LEX
();
SELECT_LEX
*
select_lex
=
new
SELECT_LEX
();
select_lex
->
select_number
=
++
lex
->
thd
->
select_number
;
if
(
!
select_lex
)
if
(
!
select_lex
)
return
1
;
return
1
;
select_lex
->
select_number
=
++
lex
->
thd
->
select_number
;
select_lex
->
init_query
();
select_lex
->
init_query
();
select_lex
->
init_select
();
select_lex
->
init_select
();
if
(
move_down
)
if
(
move_down
)
...
@@ -3297,9 +3298,13 @@ mysql_new_select(LEX *lex, bool move_down)
...
@@ -3297,9 +3298,13 @@ mysql_new_select(LEX *lex, bool move_down)
unit
->
init_query
();
unit
->
init_query
();
unit
->
init_select
();
unit
->
init_select
();
unit
->
thd
=
lex
->
thd
;
unit
->
thd
=
lex
->
thd
;
unit
->
include_down
(
lex
->
current_select
);
if
(
lex
->
current_select
->
linkage
==
GLOBAL_OPTIONS_TYPE
)
unit
->
include_neighbour
(
lex
->
current_select
);
else
unit
->
include_down
(
lex
->
current_select
);
unit
->
link_next
=
0
;
unit
->
link_next
=
0
;
unit
->
link_prev
=
0
;
unit
->
link_prev
=
0
;
unit
->
return_to
=
lex
->
current_select
;
select_lex
->
include_down
(
unit
);
select_lex
->
include_down
(
unit
);
}
}
else
else
...
...
sql/sql_yacc.yy
View file @
c4637293
...
@@ -5014,5 +5014,5 @@ subselect_end:
...
@@ -5014,5 +5014,5 @@ subselect_end:
')'
')'
{
{
LEX *lex=Lex;
LEX *lex=Lex;
lex->current_select = lex->current_select->
outer_select
();
lex->current_select = lex->current_select->
return_after_parsing
();
};
};
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