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
2b29b55c
Commit
2b29b55c
authored
Dec 14, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding comments as per Monty's request.
parent
aec84fd9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
4 deletions
+39
-4
sql/sql_derived.cc
sql/sql_derived.cc
+39
-4
No files found.
sql/sql_derived.cc
View file @
2b29b55c
...
...
@@ -27,13 +27,33 @@
static
const
char
*
any_db
=
"*any*"
;
// Special symbol for check_access
/*
Resolve derived tables in all queries
SYNOPSIS
mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
thd Thread handle
lex LEX for this thread
unit node that contains all SELECT's for derived tables
t TABLE_LIST for the upper SELECT
IMPLEMENTATION
Derived table is resolved with temporary table. It is created based on the
queries defined. After temporary table is created, if this is not EXPLAIN,
then the entire unit / node is deleted. unit is deleted if UNION is used
for derived table and node is deleted is it is a simple SELECT.
After table creation, the above TABLE_LIST is updated with a new table.
This function is called before any command containing derived table is executed.
TODO: To move creation of derived tables IN open_and_lock_tables()
*/
int
mysql_derived
(
THD
*
thd
,
LEX
*
lex
,
SELECT_LEX_UNIT
*
unit
,
TABLE_LIST
*
t
)
{
/*
TODO: make derived tables with union inside (now only 1 SELECT may be
procesed)
*/
SELECT_LEX
*
sl
=
unit
->
first_select
();
List
<
Item
>
item_list
;
TABLE
*
table
;
...
...
@@ -45,6 +65,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
DBUG_ENTER
(
"mysql_derived"
);
/*
In create_total_list, derived tables have to be treated in case of EXPLAIN,
This is because unit/node is not deleted in that case. Current code in this
function has to be improved to recognize better when this function is called
from derived tables and when from other functions.
*/
if
(
is_union
&&
unit
->
create_total_list
(
thd
,
lex
,
&
tables
))
DBUG_RETURN
(
-
1
);
...
...
@@ -65,6 +91,15 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
{
if
(
is_union
)
{
/*
The following code is a re-do of fix_tables_pointers() found in sql_select.cc
for UNION's within derived tables. The only difference is in navigation, as in
derived tables we care for this level only.
fix_tables_pointers makes sure that in UNION's we do not open single table twice
if found in different SELECT's.
*/
for
(
SELECT_LEX
*
sel
=
sl
;
sel
;
sel
=
sel
->
next_select
())
...
...
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