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
f9d38ef2
Commit
f9d38ef2
authored
Dec 14, 2002
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding comments as per Monty's request.
parent
fdbfc982
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 @
f9d38ef2
...
@@ -27,13 +27,33 @@
...
@@ -27,13 +27,33 @@
static
const
char
*
any_db
=
"*any*"
;
// Special symbol for check_access
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
)
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
();
SELECT_LEX
*
sl
=
unit
->
first_select
();
List
<
Item
>
item_list
;
List
<
Item
>
item_list
;
TABLE
*
table
;
TABLE
*
table
;
...
@@ -45,6 +65,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
...
@@ -45,6 +65,12 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
DBUG_ENTER
(
"mysql_derived"
);
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
))
if
(
is_union
&&
unit
->
create_total_list
(
thd
,
lex
,
&
tables
))
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
...
@@ -65,6 +91,15 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
...
@@ -65,6 +91,15 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
{
{
if
(
is_union
)
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
;
for
(
SELECT_LEX
*
sel
=
sl
;
sel
;
sel
;
sel
=
sel
->
next_select
())
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