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
c93ac0a1
Commit
c93ac0a1
authored
Oct 02, 2015
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanups and simplifications
parent
7ca8b4bb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
40 deletions
+21
-40
sql/group_by_handler.cc
sql/group_by_handler.cc
+1
-1
sql/group_by_handler.h
sql/group_by_handler.h
+9
-16
sql/sql_select.cc
sql/sql_select.cc
+3
-3
sql/sql_select.h
sql/sql_select.h
+2
-1
storage/sequence/sequence.cc
storage/sequence/sequence.cc
+6
-19
No files found.
sql/group_by_handler.cc
View file @
c93ac0a1
...
...
@@ -70,7 +70,7 @@ int Pushdown_query::execute(JOIN *join)
}
/* Check if we can accept the row */
if
(
!
ha
ndler
->
having
||
handler
->
having
->
val_bool
())
if
(
!
ha
ving
||
having
->
val_bool
())
{
if
(
store_data_in_temp_table
)
{
...
...
sql/group_by_handler.h
View file @
c93ac0a1
...
...
@@ -34,22 +34,13 @@ class group_by_handler
{
public:
THD
*
thd
;
List
<
Item
>
*
fields
;
TABLE_LIST
*
table_list
;
ORDER
*
group_by
,
*
order_by
;
Item
*
where
,
*
having
;
handlerton
*
ht
;
/* Temporary table where all results should be stored in record[0] */
TABLE
*
table
;
group_by_handler
(
THD
*
thd_arg
,
List
<
Item
>
*
fields_arg
,
TABLE_LIST
*
table_list_arg
,
ORDER
*
group_by_arg
,
ORDER
*
order_by_arg
,
Item
*
where_arg
,
Item
*
having_arg
,
handlerton
*
ht_arg
)
:
thd
(
thd_arg
),
fields
(
fields_arg
),
table_list
(
table_list_arg
),
group_by
(
group_by_arg
),
order_by
(
order_by_arg
),
where
(
where_arg
),
having
(
having_arg
),
ht
(
ht_arg
),
table
(
0
)
{}
group_by_handler
(
THD
*
thd_arg
,
handlerton
*
ht_arg
)
:
thd
(
thd_arg
),
ht
(
ht_arg
),
table
(
0
)
{}
virtual
~
group_by_handler
()
{}
/*
...
...
@@ -65,15 +56,17 @@ class group_by_handler
This is becasue we can't revert back the old having and order_by elements.
*/
virtual
bool
init
(
TABLE
*
temporary_table
,
Item
*
having_arg
,
ORDER
*
order_by_arg
)
virtual
bool
init
(
Item
*
having_arg
,
ORDER
*
order_by_arg
)
{
table
=
temporary_table
;
having
=
having_arg
;
order_by
=
order_by_arg
;
return
0
;
}
bool
ha_init
(
TABLE
*
temporary_table
,
Item
*
having_arg
,
ORDER
*
order_by_arg
)
{
table
=
temporary_table
;
return
init
(
having_arg
,
order_by_arg
);
}
/*
Bits of things the storage engine can do for this query.
Should be initialized on object creation.
...
...
sql/sql_select.cc
View file @
c93ac0a1
...
...
@@ -1960,13 +1960,13 @@ JOIN::optimize_inner()
DBUG_RETURN
(
1
);
/* Give storage engine access to temporary table */
if
((
err
=
gbh
->
init
(
exec_tmp_table1
,
having
,
order
)))
if
((
err
=
gbh
->
ha_init
(
exec_tmp_table1
,
having
,
order
)))
{
gbh
->
print_error
(
err
,
MYF
(
0
));
DBUG_RETURN
(
1
);
}
pushdown_query
->
store_data_in_temp_table
=
need_tmp
;
pushdown_query
->
having
=
having
;
/*
If no ORDER BY clause was specified explicitly, we should sort things
according to the group_by
...
...
@@ -2080,7 +2080,7 @@ int JOIN::init_execution()
thd
->
lex
->
set_limit_rows_examined
();
/* Create a tmp table if distinct or if the sort is too complicated */
if
(
need_tmp
&&
!
pushdown_query
)
if
(
need_tmp
&&
!
exec_tmp_table1
)
{
DBUG_PRINT
(
"info"
,(
"Creating tmp table"
));
THD_STAGE_INFO
(
thd
,
stage_copying_to_tmp_table
);
...
...
sql/sql_select.h
View file @
c93ac0a1
...
...
@@ -1971,10 +1971,11 @@ class Pushdown_query: public Sql_alloc
SELECT_LEX
*
select_lex
;
bool
store_data_in_temp_table
;
group_by_handler
*
handler
;
Item
*
having
;
Pushdown_query
(
SELECT_LEX
*
select_lex_arg
,
group_by_handler
*
handler_arg
)
:
select_lex
(
select_lex_arg
),
store_data_in_temp_table
(
0
),
handler
(
handler_arg
)
{}
handler
(
handler_arg
)
,
having
(
0
)
{}
~
Pushdown_query
()
{
delete
handler
;
}
...
...
storage/sequence/sequence.cc
View file @
c93ac0a1
...
...
@@ -359,18 +359,16 @@ static int dummy_ret_int() { return 0; }
class
ha_seq_group_by_handler
:
public
group_by_handler
{
List
<
Item
>
*
fields
;
TABLE_LIST
*
table_list
;
bool
first_row
;
public:
ha_seq_group_by_handler
(
THD
*
thd_arg
,
List
<
Item
>
*
fields_arg
,
TABLE_LIST
*
table_list_arg
,
ORDER
*
group_by_arg
,
ORDER
*
order_by_arg
,
Item
*
where_arg
,
Item
*
having_arg
)
:
group_by_handler
(
thd_arg
,
fields_arg
,
table_list_arg
,
group_by_arg
,
order_by_arg
,
where_arg
,
having_arg
,
sequence_hton
)
{}
TABLE_LIST
*
table_list_arg
)
:
group_by_handler
(
thd_arg
,
sequence_hton
),
fields
(
fields_arg
),
table_list
(
table_list_arg
)
{}
~
ha_seq_group_by_handler
()
{}
bool
init
(
TABLE
*
temporary_table
,
Item
*
having_arg
,
ORDER
*
order_by_arg
);
int
init_scan
()
{
first_row
=
1
;
return
0
;
}
int
next_row
();
int
end_scan
()
{
return
0
;
}
...
...
@@ -427,21 +425,10 @@ create_group_by_handler(THD *thd, List<Item> *fields, TABLE_LIST *table_list,
}
/* Create handler and return it */
handler
=
new
ha_seq_group_by_handler
(
thd
,
fields
,
table_list
,
group_by
,
order_by
,
where
,
having
);
handler
=
new
ha_seq_group_by_handler
(
thd
,
fields
,
table_list
);
return
handler
;
}
bool
ha_seq_group_by_handler
::
init
(
TABLE
*
temporary_table
,
Item
*
having_arg
,
ORDER
*
order_by_arg
)
{
/*
Here we could add checks if the temporary table was created correctly
*/
return
group_by_handler
::
init
(
temporary_table
,
having_arg
,
order_by_arg
);
}
int
ha_seq_group_by_handler
::
next_row
()
{
List_iterator_fast
<
Item
>
it
(
*
fields
);
...
...
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