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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c375d868
Commit
c375d868
authored
Mar 27, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
merge
mysql-test/r/union.result: Auto merged
parents
220494bd
f28b5e6e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
53 deletions
+53
-53
mysql-test/r/union.result
mysql-test/r/union.result
+2
-2
sql/item_subselect.cc
sql/item_subselect.cc
+3
-7
sql/sql_lex.cc
sql/sql_lex.cc
+12
-0
sql/sql_lex.h
sql/sql_lex.h
+1
-0
sql/sql_parse.cc
sql/sql_parse.cc
+2
-17
sql/sql_select.cc
sql/sql_select.cc
+19
-8
sql/sql_union.cc
sql/sql_union.cc
+14
-19
No files found.
mysql-test/r/union.result
View file @
c375d868
...
...
@@ -123,8 +123,8 @@ id select_type table type possible_keys key key_len ref rows Extra
3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
explain select a,b from t1 union select 1 limit 0;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY
NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 UNION NULL NULL NULL NULL NULL NULL NULL
Impossible WHERE
1 PRIMARY
t1 ALL NULL NULL NULL NULL 4
2 UNION NULL NULL NULL NULL NULL NULL NULL
No tables used
select a,b from t1 into outfile 'skr' union select a,b from t2;
ERROR HY000: Wrong usage of UNION and INTO
select a,b from t1 order by a union select a,b from t2;
...
...
sql/item_subselect.cc
View file @
c375d868
...
...
@@ -883,13 +883,9 @@ subselect_single_select_engine(st_select_lex *select,
{
select_lex
=
select
;
SELECT_LEX_UNIT
*
unit
=
select_lex
->
master_unit
();
unit
->
offset_limit_cnt
=
unit
->
global_parameters
->
offset_limit
;
unit
->
select_limit_cnt
=
unit
->
global_parameters
->
select_limit
+
unit
->
global_parameters
->
offset_limit
;
if
(
unit
->
select_limit_cnt
<
unit
->
global_parameters
->
select_limit
)
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
unit
->
select_limit_cnt
==
HA_POS_ERROR
)
select_lex
->
options
&=
~
OPTION_FOUND_ROWS
;
unit
->
set_limit
(
unit
->
global_parameters
->
select_limit
,
unit
->
global_parameters
->
offset_limit
,
select_lex
);
unit
->
item
=
item
;
this
->
select_lex
=
select_lex
;
}
...
...
sql/sql_lex.cc
View file @
c375d868
...
...
@@ -1001,6 +1001,7 @@ void st_select_lex_unit::init_query()
table
=
0
;
fake_select_lex
=
0
;
cleaned
=
0
;
found_rows_for_union
=
0
;
}
void
st_select_lex
::
init_query
()
...
...
@@ -1634,6 +1635,17 @@ void st_select_lex::print_limit(THD *thd, String *str)
}
}
void
st_select_lex_unit
::
set_limit
(
ha_rows
limit
,
ha_rows
offset
,
SELECT_LEX
*
sl
)
{
offset_limit_cnt
=
offset
;
select_limit_cnt
=
limit
+
offset
;
if
(
select_limit_cnt
<
limit
)
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
select_limit_cnt
==
HA_POS_ERROR
)
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
}
/*
There are st_select_lex::add_table_to_list &
st_select_lex::set_lock_for_tables in sql_parse.cc
...
...
sql/sql_lex.h
View file @
c375d868
...
...
@@ -371,6 +371,7 @@ class st_select_lex_unit: public st_select_lex_node {
bool
check_updateable
(
char
*
db
,
char
*
table
);
void
print
(
String
*
str
);
void
set_limit
(
ha_rows
limit
,
ha_rows
offset
,
st_select_lex
*
sl
);
friend
void
mysql_init_query
(
THD
*
thd
,
bool
lexonly
);
friend
int
subselect_union_engine
::
exec
();
...
...
sql/sql_parse.cc
View file @
c375d868
...
...
@@ -1867,18 +1867,6 @@ mysql_execute_command(THD *thd)
res
=
0
;
break
;
// Error message is given
}
/*
In case of single SELECT unit->global_parameters points on first SELECT
TODO: move counters to SELECT_LEX
*/
unit
->
offset_limit_cnt
=
(
ha_rows
)
unit
->
global_parameters
->
offset_limit
;
unit
->
select_limit_cnt
=
(
ha_rows
)
(
unit
->
global_parameters
->
select_limit
+
unit
->
global_parameters
->
offset_limit
);
if
(
unit
->
select_limit_cnt
<
(
ha_rows
)
unit
->
global_parameters
->
select_limit
)
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
unit
->
select_limit_cnt
==
HA_POS_ERROR
&&
!
select_lex
->
next_select
())
select_lex
->
options
&=
~
OPTION_FOUND_ROWS
;
if
(
!
(
res
=
open_and_lock_tables
(
thd
,
tables
)))
{
...
...
@@ -2191,11 +2179,8 @@ mysql_execute_command(THD *thd)
if
(
tables
&&
check_table_access
(
thd
,
SELECT_ACL
,
tables
,
0
))
goto
error
;
// Error message is given
select_lex
->
options
|=
SELECT_NO_UNLOCK
;
unit
->
offset_limit_cnt
=
select_lex
->
offset_limit
;
unit
->
select_limit_cnt
=
select_lex
->
select_limit
+
select_lex
->
offset_limit
;
if
(
unit
->
select_limit_cnt
<
select_lex
->
select_limit
)
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
// No limit
unit
->
set_limit
(
select_lex
->
select_limit
,
select_lex
->
offset_limit
,
select_lex
);
if
(
!
(
res
=
open_and_lock_tables
(
thd
,
tables
)))
{
...
...
sql/sql_select.cc
View file @
c375d868
...
...
@@ -175,8 +175,13 @@ int handle_select(THD *thd, LEX *lex, select_result *result)
DBUG_ENTER
(
"handle_select"
);
if
(
select_lex
->
next_select
())
res
=
mysql_union
(
thd
,
lex
,
result
,
&
lex
->
unit
);
res
=
mysql_union
(
thd
,
lex
,
result
,
&
lex
->
unit
);
else
{
SELECT_LEX_UNIT
*
unit
=
&
lex
->
unit
;
unit
->
set_limit
(
unit
->
global_parameters
->
select_limit
,
unit
->
global_parameters
->
offset_limit
,
select_lex
);
res
=
mysql_select
(
thd
,
&
select_lex
->
ref_pointer_array
,
(
TABLE_LIST
*
)
select_lex
->
table_list
.
first
,
select_lex
->
with_wild
,
select_lex
->
item_list
,
...
...
@@ -188,7 +193,8 @@ int handle_select(THD *thd, LEX *lex, select_result *result)
select_lex
->
having
,
(
ORDER
*
)
lex
->
proc_list
.
first
,
select_lex
->
options
|
thd
->
options
,
result
,
&
(
lex
->
unit
),
&
(
lex
->
select_lex
));
result
,
unit
,
select_lex
);
}
/* Don't set res if it's -1 as we may want this later */
DBUG_PRINT
(
"info"
,(
"res: %d report_error: %d"
,
res
,
...
...
@@ -1009,12 +1015,8 @@ JOIN::reinit()
{
DBUG_ENTER
(
"JOIN::reinit"
);
/* TODO move to unit reinit */
unit
->
offset_limit_cnt
=
select_lex
->
offset_limit
;
unit
->
select_limit_cnt
=
select_lex
->
select_limit
+
select_lex
->
offset_limit
;
if
(
unit
->
select_limit_cnt
<
select_lex
->
select_limit
)
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
unit
->
select_limit_cnt
==
HA_POS_ERROR
)
select_lex
->
options
&=
~
OPTION_FOUND_ROWS
;
unit
->
set_limit
(
select_lex
->
select_limit
,
select_lex
->
offset_limit
,
select_lex
);
if
(
setup_tables
(
tables_list
,
1
))
DBUG_RETURN
(
1
);
...
...
@@ -9258,6 +9260,15 @@ int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type,
select_lex
->
type
=
type
;
thd
->
lex
->
current_select
=
select_lex
;
SELECT_LEX_UNIT
*
unit
=
select_lex
->
master_unit
();
if
(
select_lex
==
unit
->
global_parameters
&&
unit
->
first_select
()
->
next_select
())
{
unit
->
offset_limit_cnt
=
0
;
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
}
else
unit
->
set_limit
(
select_lex
->
select_limit
,
select_lex
->
offset_limit
,
select_lex
);
int
res
=
mysql_select
(
thd
,
&
select_lex
->
ref_pointer_array
,
(
TABLE_LIST
*
)
select_lex
->
table_list
.
first
,
select_lex
->
with_wild
,
select_lex
->
item_list
,
...
...
sql/sql_union.cc
View file @
c375d868
...
...
@@ -151,11 +151,8 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
sl
->
options
|
thd_arg
->
options
|
additional_options
,
tmp_result
);
thd_arg
->
lex
->
current_select
=
sl
;
offset_limit_cnt
=
sl
->
offset_limit
;
select_limit_cnt
=
sl
->
select_limit
+
sl
->
offset_limit
;
if
(
select_limit_cnt
<
sl
->
select_limit
)
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
select_limit_cnt
==
HA_POS_ERROR
||
sl
->
braces
)
set_limit
(
sl
->
select_limit
,
sl
->
offset_limit
,
sl
);
if
(
sl
->
braces
)
sl
->
options
&=
~
OPTION_FOUND_ROWS
;
res
=
join
->
prepare
(
&
sl
->
ref_pointer_array
,
...
...
@@ -376,18 +373,15 @@ int st_select_lex_unit::exec()
if
(
!
thd
->
is_fatal_error
)
// Check if EOM
{
ulong
options_tmp
=
thd
->
options
;
thd
->
lex
->
current_select
=
fake_select_lex
;
offset_limit_cnt
=
global_parameters
->
offset_limit
;
select_limit_cnt
=
global_parameters
->
select_limit
+
global_parameters
->
offset_limit
;
if
(
select_limit_cnt
<
global_parameters
->
select_limit
)
select_limit_cnt
=
HA_POS_ERROR
;
// no limit
if
(
select_limit_cnt
==
HA_POS_ERROR
)
options_tmp
&=
~
OPTION_FOUND_ROWS
;
else
if
(
found_rows_for_union
&&
!
thd
->
lex
->
describe
)
options_tmp
|=
OPTION_FOUND_ROWS
;
fake_select_lex
->
options
=
thd
->
options
;
set_limit
(
global_parameters
->
select_limit
,
global_parameters
->
offset_limit
,
fake_select_lex
);
if
(
found_rows_for_union
&&
!
thd
->
lex
->
describe
&&
select_limit_cnt
!=
HA_POS_ERROR
)
fake_select_lex
->
options
|=
OPTION_FOUND_ROWS
;
fake_select_lex
->
ftfunc_list
=
&
empty_list
;
fake_select_lex
->
table_list
.
link_in_list
((
byte
*
)
&
result_table_list
,
(
byte
**
)
...
...
@@ -399,7 +393,8 @@ int st_select_lex_unit::exec()
allocate JOIN for fake select only once (privent
mysql_select automatic allocation)
*/
fake_select_lex
->
join
=
new
JOIN
(
thd
,
item_list
,
thd
->
options
,
result
);
fake_select_lex
->
join
=
new
JOIN
(
thd
,
item_list
,
fake_select_lex
->
options
,
result
);
/*
Fake st_select_lex should have item list for correctref_array
allocation.
...
...
@@ -414,7 +409,7 @@ int st_select_lex_unit::exec()
delete
tab
->
select
;
delete
tab
->
quick
;
}
join
->
init
(
thd
,
item_list
,
thd
->
options
,
result
);
join
->
init
(
thd
,
item_list
,
fake_select_lex
->
options
,
result
);
}
res
=
mysql_select
(
thd
,
&
fake_select_lex
->
ref_pointer_array
,
&
result_table_list
,
...
...
@@ -422,7 +417,7 @@ int st_select_lex_unit::exec()
global_parameters
->
order_list
.
elements
,
(
ORDER
*
)
global_parameters
->
order_list
.
first
,
(
ORDER
*
)
NULL
,
NULL
,
(
ORDER
*
)
NULL
,
options_tmp
|
SELECT_NO_UNLOCK
,
fake_select_lex
->
options
|
SELECT_NO_UNLOCK
,
result
,
this
,
fake_select_lex
);
if
(
!
res
)
thd
->
limit_found_rows
=
(
ulonglong
)
table
->
file
->
records
+
add_rows
;
...
...
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