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
410cbef6
Commit
410cbef6
authored
Feb 15, 2003
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code clean-up
parent
af2a07f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
32 deletions
+40
-32
sql/sql_derived.cc
sql/sql_derived.cc
+36
-29
sql/sql_lex.h
sql/sql_lex.h
+2
-1
sql/sql_union.cc
sql/sql_union.cc
+2
-2
No files found.
sql/sql_derived.cc
View file @
410cbef6
...
@@ -64,15 +64,16 @@ extern const char *any_db; // Special symbol for check_access
...
@@ -64,15 +64,16 @@ extern const char *any_db; // Special symbol for check_access
int
mysql_derived
(
THD
*
thd
,
LEX
*
lex
,
SELECT_LEX_UNIT
*
unit
,
int
mysql_derived
(
THD
*
thd
,
LEX
*
lex
,
SELECT_LEX_UNIT
*
unit
,
TABLE_LIST
*
org_table_list
)
TABLE_LIST
*
org_table_list
)
{
{
SELECT_LEX
*
s
l
=
unit
->
first_select
();
SELECT_LEX
*
s
elect_cursor
=
unit
->
first_select
();
List
<
Item
>
item_list
;
List
<
Item
>
item_list
;
TABLE
*
table
;
TABLE
*
table
;
int
res
;
int
res
;
select_union
*
derived_result
;
select_union
*
derived_result
;
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
s
l
->
table_list
.
first
;
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
s
elect_cursor
->
table_list
.
first
;
TMP_TABLE_PARAM
tmp_table_param
;
TMP_TABLE_PARAM
tmp_table_param
;
bool
is_union
=
sl
->
next_select
()
&&
sl
->
next_select
()
->
linkage
==
UNION_TYPE
;
bool
is_union
=
select_cursor
->
next_select
()
&&
bool
is_subsel
=
sl
->
first_inner_unit
()
?
1
:
0
;
select_cursor
->
next_select
()
->
linkage
==
UNION_TYPE
;
bool
is_subsel
=
select_cursor
->
first_inner_unit
()
?
1
:
0
;
SELECT_LEX_NODE
*
save_current_select
=
lex
->
current_select
;
SELECT_LEX_NODE
*
save_current_select
=
lex
->
current_select
;
DBUG_ENTER
(
"mysql_derived"
);
DBUG_ENTER
(
"mysql_derived"
);
...
@@ -111,21 +112,23 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
...
@@ -111,21 +112,23 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
fix_tables_pointers
(
unit
);
fix_tables_pointers
(
unit
);
}
}
lex
->
current_select
=
sl
;
lex
->
current_select
=
select_cursor
;
TABLE_LIST
*
first_table
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
TABLE_LIST
*
first_table
=
(
TABLE_LIST
*
)
select_cursor
->
table_list
.
first
;
/* Setting up. A must if a join or IGNORE, USE or similar are utilised */
if
(
setup_tables
(
first_table
)
||
if
(
setup_tables
(
first_table
)
||
setup_wild
(
thd
,
first_table
,
s
l
->
item_list
,
0
,
sl
->
with_wild
))
setup_wild
(
thd
,
first_table
,
s
elect_cursor
->
item_list
,
0
,
select_cursor
->
with_wild
))
{
{
res
=
-
1
;
res
=
-
1
;
goto
exit
;
goto
exit
;
}
}
item_list
=
sl
->
item_list
;
item_list
=
select_cursor
->
item_list
;
sl
->
with_wild
=
0
;
select_cursor
->
with_wild
=
0
;
if
(
setup_ref_array
(
thd
,
&
sl
->
ref_pointer_array
,
if
(
setup_ref_array
(
thd
,
&
select_cursor
->
ref_pointer_array
,
(
item_list
.
elements
+
sl
->
with_sum_func
+
(
item_list
.
elements
+
select_cursor
->
with_sum_func
+
sl
->
order_list
.
elements
+
sl
->
group_list
.
elements
))
||
select_cursor
->
order_list
.
elements
+
setup_fields
(
thd
,
sl
->
ref_pointer_array
,
first_table
,
item_list
,
select_cursor
->
group_list
.
elements
))
||
setup_fields
(
thd
,
select_cursor
->
ref_pointer_array
,
first_table
,
item_list
,
0
,
0
,
1
))
0
,
0
,
1
))
{
{
res
=
-
1
;
res
=
-
1
;
...
@@ -133,10 +136,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
...
@@ -133,10 +136,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
}
}
bzero
((
char
*
)
&
tmp_table_param
,
sizeof
(
tmp_table_param
));
bzero
((
char
*
)
&
tmp_table_param
,
sizeof
(
tmp_table_param
));
tmp_table_param
.
field_count
=
item_list
.
elements
;
tmp_table_param
.
field_count
=
item_list
.
elements
;
/* temp table is created so that it hounours if UNION without ALL is to be
processed */
if
(
!
(
table
=
create_tmp_table
(
thd
,
&
tmp_table_param
,
item_list
,
if
(
!
(
table
=
create_tmp_table
(
thd
,
&
tmp_table_param
,
item_list
,
(
ORDER
*
)
0
,
(
ORDER
*
)
0
,
is_union
&&
!
unit
->
union_option
,
1
,
is_union
&&
!
unit
->
union_option
,
1
,
(
s
l
->
options
|
thd
->
options
|
(
s
elect_cursor
->
options
|
thd
->
options
|
TMP_TABLE_ALL_COLUMNS
),
TMP_TABLE_ALL_COLUMNS
),
HA_POS_ERROR
)))
HA_POS_ERROR
)))
{
{
...
@@ -147,26 +152,27 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
...
@@ -147,26 +152,27 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
if
((
derived_result
=
new
select_union
(
table
)))
if
((
derived_result
=
new
select_union
(
table
)))
{
{
derived_result
->
tmp_table_param
=&
tmp_table_param
;
derived_result
->
tmp_table_param
=&
tmp_table_param
;
unit
->
offset_limit_cnt
=
sl
->
offset_limit
;
unit
->
offset_limit_cnt
=
select_cursor
->
offset_limit
;
unit
->
select_limit_cnt
=
sl
->
select_limit
+
sl
->
offset_limit
;
unit
->
select_limit_cnt
=
select_cursor
->
select_limit
+
if
(
unit
->
select_limit_cnt
<
sl
->
select_limit
)
select_cursor
->
offset_limit
;
if
(
unit
->
select_limit_cnt
<
select_cursor
->
select_limit
)
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
unit
->
select_limit_cnt
=
HA_POS_ERROR
;
if
(
unit
->
select_limit_cnt
==
HA_POS_ERROR
)
if
(
unit
->
select_limit_cnt
==
HA_POS_ERROR
)
s
l
->
options
&=
~
OPTION_FOUND_ROWS
;
s
elect_cursor
->
options
&=
~
OPTION_FOUND_ROWS
;
if
(
is_union
)
if
(
is_union
)
res
=
mysql_union
(
thd
,
lex
,
derived_result
,
unit
,
1
);
res
=
mysql_union
(
thd
,
lex
,
derived_result
,
unit
,
1
);
else
else
res
=
mysql_select
(
thd
,
&
s
l
->
ref_pointer_array
,
res
=
mysql_select
(
thd
,
&
s
elect_cursor
->
ref_pointer_array
,
(
TABLE_LIST
*
)
s
l
->
table_list
.
first
,
(
TABLE_LIST
*
)
s
elect_cursor
->
table_list
.
first
,
s
l
->
with_wild
,
s
elect_cursor
->
with_wild
,
s
l
->
item_list
,
sl
->
where
,
s
elect_cursor
->
item_list
,
select_cursor
->
where
,
s
l
->
order_list
.
elements
+
sl
->
group_list
.
elements
,
s
elect_cursor
->
order_list
.
elements
+
select_cursor
->
group_list
.
elements
,
(
ORDER
*
)
s
l
->
order_list
.
first
,
(
ORDER
*
)
s
elect_cursor
->
order_list
.
first
,
(
ORDER
*
)
s
l
->
group_list
.
first
,
(
ORDER
*
)
s
elect_cursor
->
group_list
.
first
,
s
l
->
having
,
(
ORDER
*
)
NULL
,
s
elect_cursor
->
having
,
(
ORDER
*
)
NULL
,
s
l
->
options
|
thd
->
options
|
SELECT_NO_UNLOCK
,
s
elect_cursor
->
options
|
thd
->
options
|
SELECT_NO_UNLOCK
,
derived_result
,
unit
,
s
l
,
0
,
1
);
derived_result
,
unit
,
s
elect_cursor
,
0
,
1
);
if
(
!
res
)
if
(
!
res
)
{
{
...
@@ -180,7 +186,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
...
@@ -180,7 +186,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
{
{
org_table_list
->
real_name
=
table
->
real_name
;
org_table_list
->
real_name
=
table
->
real_name
;
org_table_list
->
table
=
table
;
org_table_list
->
table
=
table
;
table
->
derived_select_number
=
s
l
->
select_number
;
table
->
derived_select_number
=
s
elect_cursor
->
select_number
;
table
->
tmp_table
=
TMP_TABLE
;
table
->
tmp_table
=
TMP_TABLE
;
if
(
lex
->
describe
)
if
(
lex
->
describe
)
{
{
...
@@ -195,6 +201,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
...
@@ -195,6 +201,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
/* Try to catch errors if this is accessed */
/* Try to catch errors if this is accessed */
org_table_list
->
derived
=
(
SELECT_LEX_UNIT
*
)
1
;
org_table_list
->
derived
=
(
SELECT_LEX_UNIT
*
)
1
;
#endif
#endif
// This line is required to force read of table stats in the optimizer
table
->
file
->
info
(
HA_STATUS_VARIABLE
);
table
->
file
->
info
(
HA_STATUS_VARIABLE
);
}
}
}
}
...
...
sql/sql_lex.h
View file @
410cbef6
...
@@ -289,7 +289,8 @@ protected:
...
@@ -289,7 +289,8 @@ protected:
bool
describe
,
found_rows_for_union
,
bool
describe
,
found_rows_for_union
,
prepared
,
// prepare phase already performed for UNION (unit)
prepared
,
// prepare phase already performed for UNION (unit)
optimized
,
// optimize phase already performed for UNION (unit)
optimized
,
// optimize phase already performed for UNION (unit)
executed
,
t_and_f
;
// already executed
executed
,
// already executed
t_and_f
;
// used for transferring tables_and_fields_initied UNIT:: methods
public:
public:
/*
/*
Pointer to 'last' select or pointer to unit where stored
Pointer to 'last' select or pointer to unit where stored
...
...
sql/sql_union.cc
View file @
410cbef6
...
@@ -120,7 +120,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result,
...
@@ -120,7 +120,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result,
found_rows_for_union
=
0
;
found_rows_for_union
=
0
;
TMP_TABLE_PARAM
tmp_table_param
;
TMP_TABLE_PARAM
tmp_table_param
;
this
->
result
=
result
;
this
->
result
=
result
;
t_and_f
=
tables_and_fields_initied
;
t_and_f
=
tables_and_fields_initied
;
SELECT_LEX_NODE
*
lex_select_save
=
thd
->
lex
.
current_select
;
SELECT_LEX_NODE
*
lex_select_save
=
thd
->
lex
.
current_select
;
SELECT_LEX
*
sl
;
SELECT_LEX
*
sl
;
...
@@ -204,7 +204,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result,
...
@@ -204,7 +204,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result,
sl
->
having
,
sl
->
having
,
(
ORDER
*
)
NULL
,
(
ORDER
*
)
NULL
,
sl
,
this
,
0
,
t_and_f
);
sl
,
this
,
0
,
t_and_f
);
t_and_f
=
0
;
t_and_f
=
0
;
if
(
res
|
thd
->
is_fatal_error
)
if
(
res
|
thd
->
is_fatal_error
)
goto
err
;
goto
err
;
}
}
...
...
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