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
ea15ebbb
Commit
ea15ebbb
authored
Feb 05, 2009
by
Gleb Shchepa
Browse files
Options
Browse Files
Download
Plain Diff
automerge 5.0-bugteam --> 5.1-bugteam (bug 42037)
parents
aa964b79
061bf717
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
42 deletions
+40
-42
sql/sql_select.cc
sql/sql_select.cc
+33
-40
sql/sql_select.h
sql/sql_select.h
+7
-2
No files found.
sql/sql_select.cc
View file @
ea15ebbb
...
...
@@ -87,7 +87,6 @@ static store_key *get_store_key(THD *thd,
KEYUSE
*
keyuse
,
table_map
used_tables
,
KEY_PART_INFO
*
key_part
,
uchar
*
key_buff
,
uint
maybe_null
);
static
bool
make_simple_join
(
JOIN
*
join
,
TABLE
*
tmp_table
);
static
void
make_outerjoin_info
(
JOIN
*
join
);
static
bool
make_join_select
(
JOIN
*
join
,
SQL_SELECT
*
select
,
COND
*
item
);
static
void
make_join_readinfo
(
JOIN
*
join
,
ulonglong
options
);
...
...
@@ -1879,7 +1878,7 @@ JOIN::exec()
/* Free first data from old join */
curr_join
->
join_free
();
if
(
make_simple_join
(
curr_join
,
curr_tmp_table
))
if
(
curr_join
->
make_simple_join
(
this
,
curr_tmp_table
))
DBUG_VOID_RETURN
;
calc_group_buffer
(
curr_join
,
group_list
);
count_field_types
(
select_lex
,
&
curr_join
->
tmp_table_param
,
...
...
@@ -2002,7 +2001,7 @@ JOIN::exec()
curr_join
->
select_distinct
=
0
;
}
curr_tmp_table
->
reginfo
.
lock_type
=
TL_UNLOCK
;
if
(
make_simple_join
(
curr_join
,
curr_tmp_table
))
if
(
curr_join
->
make_simple_join
(
this
,
curr_tmp_table
))
DBUG_VOID_RETURN
;
calc_group_buffer
(
curr_join
,
curr_join
->
group_list
);
count_field_types
(
select_lex
,
&
curr_join
->
tmp_table_param
,
...
...
@@ -5686,48 +5685,42 @@ store_val_in_field(Field *field, Item *item, enum_check_fields check_flag)
}
static
bool
make_simple_join
(
JOIN
*
join
,
TABLE
*
tmp_table
)
/**
@details Initialize a JOIN as a query execution plan
that accesses a single table via a table scan.
@param parent contains JOIN_TAB and TABLE object buffers for this join
@param tmp_table temporary table
@retval FALSE success
@retval TRUE error occurred
*/
bool
JOIN
::
make_simple_join
(
JOIN
*
parent
,
TABLE
*
tmp_table
)
{
TABLE
**
tableptr
;
JOIN_TAB
*
join_tab
;
DBUG_ENTER
(
"make_simple_join"
);
DBUG_ENTER
(
"JOIN::make_simple_join"
);
/*
Reuse TABLE * and JOIN_TAB if already allocated by a previous call
to this function through JOIN::exec (may happen for sub-queries).
*/
if
(
!
join
->
table_reexec
)
{
if
(
!
(
join
->
table_reexec
=
(
TABLE
**
)
join
->
thd
->
alloc
(
sizeof
(
TABLE
*
))))
DBUG_RETURN
(
TRUE
);
/* purecov: inspected */
if
(
join
->
tmp_join
)
join
->
tmp_join
->
table_reexec
=
join
->
table_reexec
;
}
if
(
!
join
->
join_tab_reexec
)
{
if
(
!
(
join
->
join_tab_reexec
=
(
JOIN_TAB
*
)
join
->
thd
->
alloc
(
sizeof
(
JOIN_TAB
))))
DBUG_RETURN
(
TRUE
);
/* purecov: inspected */
if
(
join
->
tmp_join
)
join
->
tmp_join
->
join_tab_reexec
=
join
->
join_tab_reexec
;
}
tableptr
=
join
->
table_reexec
;
join_tab
=
join
->
join_tab_reexec
;
join
->
join_tab
=
join_tab
;
join
->
table
=
tableptr
;
tableptr
[
0
]
=
tmp_table
;
join
->
tables
=
1
;
join
->
const_tables
=
0
;
join
->
const_table_map
=
0
;
join
->
tmp_table_param
.
field_count
=
join
->
tmp_table_param
.
sum_func_count
=
join
->
tmp_table_param
.
func_count
=
0
;
join
->
tmp_table_param
.
copy_field
=
join
->
tmp_table_param
.
copy_field_end
=
0
;
join
->
first_record
=
join
->
sort_and_group
=
0
;
join
->
send_records
=
(
ha_rows
)
0
;
join
->
group
=
0
;
join
->
row_limit
=
join
->
unit
->
select_limit_cnt
;
join
->
do_send_rows
=
(
join
->
row_limit
)
?
1
:
0
;
if
(
!
parent
->
join_tab_reexec
&&
!
(
parent
->
join_tab_reexec
=
(
JOIN_TAB
*
)
thd
->
alloc
(
sizeof
(
JOIN_TAB
))))
DBUG_RETURN
(
TRUE
);
/* purecov: inspected */
join_tab
=
parent
->
join_tab_reexec
;
table
=
&
parent
->
table_reexec
[
0
];
parent
->
table_reexec
[
0
]
=
tmp_table
;
tables
=
1
;
const_tables
=
0
;
const_table_map
=
0
;
tmp_table_param
.
field_count
=
tmp_table_param
.
sum_func_count
=
tmp_table_param
.
func_count
=
0
;
tmp_table_param
.
copy_field
=
tmp_table_param
.
copy_field_end
=
0
;
first_record
=
sort_and_group
=
0
;
send_records
=
(
ha_rows
)
0
;
group
=
0
;
row_limit
=
unit
->
select_limit_cnt
;
do_send_rows
=
row_limit
?
1
:
0
;
join_tab
->
cache
.
buff
=
0
;
/* No caching */
join_tab
->
table
=
tmp_table
;
...
...
@@ -5744,7 +5737,7 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
join_tab
->
ref
.
key
=
-
1
;
join_tab
->
not_used_in_distinct
=
0
;
join_tab
->
read_first_record
=
join_init_read_record
;
join_tab
->
join
=
join
;
join_tab
->
join
=
this
;
join_tab
->
ref
.
key_parts
=
0
;
bzero
((
char
*
)
&
join_tab
->
read_record
,
sizeof
(
join_tab
->
read_record
));
tmp_table
->
status
=
0
;
...
...
sql/sql_select.h
View file @
ea15ebbb
...
...
@@ -402,9 +402,12 @@ class JOIN :public Sql_alloc
cleared only at the end of the execution of the whole query and not caching
allocations that occur in repetition at execution time will result in
excessive memory usage.
Note: make_simple_join always creates an execution plan that accesses
a single table, thus it is sufficient to have a one-element array for
table_reexec.
*/
SORT_FIELD
*
sortorder
;
// make_unireg_sortorder()
TABLE
*
*
table_reexec
;
// make_simple_join()
TABLE
*
table_reexec
[
1
];
// make_simple_join()
JOIN_TAB
*
join_tab_reexec
;
// make_simple_join()
/* end of allocation caching storage */
...
...
@@ -434,7 +437,7 @@ class JOIN :public Sql_alloc
exec_tmp_table1
=
0
;
exec_tmp_table2
=
0
;
sortorder
=
0
;
table_reexec
=
0
;
table_reexec
[
0
]
=
0
;
join_tab_reexec
=
0
;
thd
=
thd_arg
;
sum_funcs
=
sum_funcs2
=
0
;
...
...
@@ -526,6 +529,8 @@ class JOIN :public Sql_alloc
return
(
unit
==
&
thd
->
lex
->
unit
&&
(
unit
->
fake_select_lex
==
0
||
select_lex
==
unit
->
fake_select_lex
));
}
private:
bool
make_simple_join
(
JOIN
*
join
,
TABLE
*
tmp_table
);
};
...
...
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