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
be8f7641
Commit
be8f7641
authored
May 06, 2004
by
miguel@hegel.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge miguel@bk-internal.mysql.com:/home/bk/mysql-4.1
into hegel.local:/home/miguel/bk/mysql-4.1
parents
1106c26b
cd242210
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
19 deletions
+66
-19
sql/sql_lex.h
sql/sql_lex.h
+6
-2
sql/sql_union.cc
sql/sql_union.cc
+60
-17
No files found.
sql/sql_lex.h
View file @
be8f7641
...
@@ -332,7 +332,10 @@ public:
...
@@ -332,7 +332,10 @@ public:
Item_subselect
*
item
;
Item_subselect
*
item
;
/* thread handler */
/* thread handler */
THD
*
thd
;
THD
*
thd
;
/* fake SELECT_LEX for union processing */
/*
SELECT_LEX for hidden SELECT in onion which process global
ORDER BY and LIMIT
*/
st_select_lex
*
fake_select_lex
;
st_select_lex
*
fake_select_lex
;
st_select_lex
*
union_distinct
;
/* pointer to the last UNION DISTINCT */
st_select_lex
*
union_distinct
;
/* pointer to the last UNION DISTINCT */
...
@@ -367,6 +370,7 @@ public:
...
@@ -367,6 +370,7 @@ public:
bool
check_updateable
(
char
*
db
,
char
*
table
);
bool
check_updateable
(
char
*
db
,
char
*
table
);
void
print
(
String
*
str
);
void
print
(
String
*
str
);
ulong
init_prepare_fake_select_lex
(
THD
*
thd
);
friend
void
mysql_init_query
(
THD
*
thd
);
friend
void
mysql_init_query
(
THD
*
thd
);
friend
int
subselect_union_engine
::
exec
();
friend
int
subselect_union_engine
::
exec
();
...
...
sql/sql_union.cc
View file @
be8f7641
...
@@ -106,6 +106,41 @@ bool select_union::flush()
...
@@ -106,6 +106,41 @@ bool select_union::flush()
}
}
/*
initialization procedures before fake_select_lex preparation()
SYNOPSIS
st_select_lex_unit::init_prepare_fake_select_lex()
thd - thread handler
RETURN
options of SELECT
*/
ulong
st_select_lex_unit
::
init_prepare_fake_select_lex
(
THD
*
thd
)
{
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
->
ftfunc_list_alloc
.
empty
();
fake_select_lex
->
ftfunc_list
=
&
fake_select_lex
->
ftfunc_list_alloc
;
fake_select_lex
->
table_list
.
link_in_list
((
byte
*
)
&
result_table_list
,
(
byte
**
)
&
result_table_list
.
next
);
return
options_tmp
;
}
int
st_select_lex_unit
::
prepare
(
THD
*
thd_arg
,
select_result
*
sel_result
,
int
st_select_lex_unit
::
prepare
(
THD
*
thd_arg
,
select_result
*
sel_result
,
ulong
additional_options
)
ulong
additional_options
)
{
{
...
@@ -207,7 +242,6 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -207,7 +242,6 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
}
}
}
}
item_list
.
empty
();
// it is not single select
// it is not single select
if
(
first_select
->
next_select
())
if
(
first_select
->
next_select
())
{
{
...
@@ -229,6 +263,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -229,6 +263,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
union_result
->
set_table
(
table
);
union_result
->
set_table
(
table
);
thd_arg
->
lex
->
current_select
=
lex_select_save
;
thd_arg
->
lex
->
current_select
=
lex_select_save
;
if
(
!
item_list
.
elements
)
{
{
Statement
*
stmt
=
thd
->
current_statement
;
Statement
*
stmt
=
thd
->
current_statement
;
Statement
backup
;
Statement
backup
;
...
@@ -246,7 +281,30 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
...
@@ -246,7 +281,30 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
}
}
}
}
if
(
stmt
)
if
(
stmt
)
{
thd
->
restore_backup_item_arena
(
stmt
,
&
backup
);
thd
->
restore_backup_item_arena
(
stmt
,
&
backup
);
/* prepare fake select to initialize it correctly */
ulong
options_tmp
=
init_prepare_fake_select_lex
(
thd
);
if
(
!
(
fake_select_lex
->
join
=
new
JOIN
(
thd
,
item_list
,
thd
->
options
,
result
)))
{
fake_select_lex
->
table_list
.
empty
();
DBUG_RETURN
(
-
1
);
}
fake_select_lex
->
item_list
=
item_list
;
thd_arg
->
lex
->
current_select
=
fake_select_lex
;
res
=
fake_select_lex
->
join
->
prepare
(
&
fake_select_lex
->
ref_pointer_array
,
(
TABLE_LIST
*
)
fake_select_lex
->
table_list
.
first
,
0
,
0
,
fake_select_lex
->
order_list
.
elements
,
(
ORDER
*
)
fake_select_lex
->
order_list
.
first
,
(
ORDER
*
)
NULL
,
NULL
,
(
ORDER
*
)
NULL
,
fake_select_lex
,
this
);
fake_select_lex
->
table_list
.
empty
();
}
}
}
}
}
else
else
...
@@ -373,22 +431,7 @@ int st_select_lex_unit::exec()
...
@@ -373,22 +431,7 @@ int st_select_lex_unit::exec()
if
(
!
thd
->
is_fatal_error
)
// Check if EOM
if
(
!
thd
->
is_fatal_error
)
// Check if EOM
{
{
ulong
options_tmp
=
thd
->
options
;
ulong
options_tmp
=
init_prepare_fake_select_lex
(
thd
);
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
->
ftfunc_list
=
&
empty_list
;
fake_select_lex
->
table_list
.
link_in_list
((
byte
*
)
&
result_table_list
,
(
byte
**
)
&
result_table_list
.
next
);
JOIN
*
join
=
fake_select_lex
->
join
;
JOIN
*
join
=
fake_select_lex
->
join
;
if
(
!
join
)
if
(
!
join
)
{
{
...
...
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