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
ebeb4f93
Commit
ebeb4f93
authored
5 years ago
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-16327: Server doesn't account for engines that supports OFFSET on their own.
Engine get LIMIT/OFFSET info an can it use/reset.
parent
a6de6408
Branches unavailable
Tags unavailable
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
7 deletions
+71
-7
sql/group_by_handler.h
sql/group_by_handler.h
+6
-1
sql/sql_limit.h
sql/sql_limit.h
+6
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-1
storage/sequence/mysql-test/sequence/group_by.result
storage/sequence/mysql-test/sequence/group_by.result
+30
-0
storage/sequence/mysql-test/sequence/group_by.test
storage/sequence/mysql-test/sequence/group_by.test
+12
-0
storage/sequence/sequence.cc
storage/sequence/sequence.cc
+15
-5
No files found.
sql/group_by_handler.h
View file @
ebeb4f93
...
@@ -14,6 +14,10 @@
...
@@ -14,6 +14,10 @@
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#ifndef GROUP_BY_HANDLER_INCLUDED
#define GROUP_BY_HANDLER_INCLUDED
class
Select_limit_counters
;
/*
/*
This file implements the group_by_handler interface. This interface
This file implements the group_by_handler interface. This interface
can be used by storage handlers that can intercept summary or GROUP
can be used by storage handlers that can intercept summary or GROUP
...
@@ -56,7 +60,7 @@ struct Query
...
@@ -56,7 +60,7 @@ struct Query
ORDER
*
order_by
;
ORDER
*
order_by
;
Item
*
having
;
Item
*
having
;
// LIMIT
// LIMIT
//ha_rows select_limit_cnt, offset_limit_cn
t;
Select_limit_counters
*
limi
t
;
};
};
class
group_by_handler
class
group_by_handler
...
@@ -101,3 +105,4 @@ class group_by_handler
...
@@ -101,3 +105,4 @@ class group_by_handler
virtual
void
print_error
(
int
error
,
myf
errflag
);
virtual
void
print_error
(
int
error
,
myf
errflag
);
};
};
#endif //GROUP_BY_HANDLER_INCLUDED
This diff is collapsed.
Click to expand it.
sql/sql_limit.h
View file @
ebeb4f93
...
@@ -28,6 +28,10 @@ class Select_limit_counters
...
@@ -28,6 +28,10 @@ class Select_limit_counters
Select_limit_counters
()
:
Select_limit_counters
()
:
select_limit_cnt
(
0
),
offset_limit_cnt
(
0
)
select_limit_cnt
(
0
),
offset_limit_cnt
(
0
)
{};
{};
Select_limit_counters
(
Select_limit_counters
&
orig
)
:
select_limit_cnt
(
orig
.
select_limit_cnt
),
offset_limit_cnt
(
orig
.
offset_limit_cnt
)
{};
void
set_limit
(
ha_rows
limit
,
ha_rows
offset
)
void
set_limit
(
ha_rows
limit
,
ha_rows
offset
)
{
{
...
@@ -48,6 +52,8 @@ class Select_limit_counters
...
@@ -48,6 +52,8 @@ class Select_limit_counters
bool
is_unlimited
()
bool
is_unlimited
()
{
return
select_limit_cnt
==
HA_POS_ERROR
;
}
{
return
select_limit_cnt
==
HA_POS_ERROR
;
}
bool
is_unrestricted
()
{
return
select_limit_cnt
==
HA_POS_ERROR
&&
offset_limit_cnt
==
0
;
}
void
set_unlimited
()
void
set_unlimited
()
{
select_limit_cnt
=
HA_POS_ERROR
;
offset_limit_cnt
=
0
;
}
{
select_limit_cnt
=
HA_POS_ERROR
;
offset_limit_cnt
=
0
;
}
...
...
This diff is collapsed.
Click to expand it.
sql/sql_select.cc
View file @
ebeb4f93
...
@@ -3146,7 +3146,8 @@ bool JOIN::make_aggr_tables_info()
...
@@ -3146,7 +3146,8 @@ bool JOIN::make_aggr_tables_info()
{
{
/* Check if the storage engine can intercept the query */
/* Check if the storage engine can intercept the query */
Query
query
=
{
&
all_fields
,
select_distinct
,
tables_list
,
conds
,
Query
query
=
{
&
all_fields
,
select_distinct
,
tables_list
,
conds
,
group_list
,
order
?
order
:
group_list
,
having
};
group_list
,
order
?
order
:
group_list
,
having
,
&
select_lex
->
master_unit
()
->
lim
};
group_by_handler
*
gbh
=
ht
->
create_group_by
(
thd
,
&
query
);
group_by_handler
*
gbh
=
ht
->
create_group_by
(
thd
,
&
query
);
if
(
gbh
)
if
(
gbh
)
...
...
This diff is collapsed.
Click to expand it.
storage/sequence/mysql-test/sequence/group_by.result
View file @
ebeb4f93
...
@@ -103,3 +103,33 @@ count(NULL)
...
@@ -103,3 +103,33 @@ count(NULL)
select count(NULL) from seq_1_to_3 limit 0;
select count(NULL) from seq_1_to_3 limit 0;
count(NULL)
count(NULL)
# End of 10.3 tests
# End of 10.3 tests
#
# MDEV-16327: Server doesn't account for engines that supports
# OFFSET on their own.
#
select count(NULL) from seq_1_to_3 limit 1;
count(NULL)
0
explain format=json select count(NULL) from seq_1_to_3 limit 1;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"message": "Storage engine handles GROUP BY"
}
}
}
select count(NULL) from seq_1_to_3 limit 1 offset 1;
count(NULL)
explain format=json select count(NULL) from seq_1_to_3 limit 1 offset 1;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"message": "Storage engine handles GROUP BY"
}
}
}
# End of 10.5 tests
This diff is collapsed.
Click to expand it.
storage/sequence/mysql-test/sequence/group_by.test
View file @
ebeb4f93
...
@@ -56,3 +56,15 @@ select count(NULL) from seq_1_to_3;
...
@@ -56,3 +56,15 @@ select count(NULL) from seq_1_to_3;
select
count
(
NULL
)
from
seq_1_to_3
limit
0
;
select
count
(
NULL
)
from
seq_1_to_3
limit
0
;
--
echo
# End of 10.3 tests
--
echo
# End of 10.3 tests
--
echo
#
--
echo
# MDEV-16327: Server doesn't account for engines that supports
--
echo
# OFFSET on their own.
--
echo
#
select
count
(
NULL
)
from
seq_1_to_3
limit
1
;
explain
format
=
json
select
count
(
NULL
)
from
seq_1_to_3
limit
1
;
select
count
(
NULL
)
from
seq_1_to_3
limit
1
offset
1
;
explain
format
=
json
select
count
(
NULL
)
from
seq_1_to_3
limit
1
offset
1
;
--
echo
# End of 10.5 tests
This diff is collapsed.
Click to expand it.
storage/sequence/sequence.cc
View file @
ebeb4f93
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include <handler.h>
#include <handler.h>
#include <table.h>
#include <table.h>
#include <field.h>
#include <field.h>
#include <sql_limit.h>
static
handlerton
*
sequence_hton
;
static
handlerton
*
sequence_hton
;
...
@@ -361,15 +362,21 @@ static int dummy_savepoint(handlerton *, THD *, void *) { return 0; }
...
@@ -361,15 +362,21 @@ static int dummy_savepoint(handlerton *, THD *, void *) { return 0; }
class
ha_seq_group_by_handler
:
public
group_by_handler
class
ha_seq_group_by_handler
:
public
group_by_handler
{
{
Select_limit_counters
limit
;
List
<
Item
>
*
fields
;
List
<
Item
>
*
fields
;
TABLE_LIST
*
table_list
;
TABLE_LIST
*
table_list
;
bool
first_row
;
bool
first_row
;
public:
public:
ha_seq_group_by_handler
(
THD
*
thd_arg
,
List
<
Item
>
*
fields_arg
,
ha_seq_group_by_handler
(
THD
*
thd_arg
,
List
<
Item
>
*
fields_arg
,
TABLE_LIST
*
table_list_arg
)
TABLE_LIST
*
table_list_arg
,
:
group_by_handler
(
thd_arg
,
sequence_hton
),
fields
(
fields_arg
),
Select_limit_counters
*
orig_lim
)
table_list
(
table_list_arg
)
{}
:
group_by_handler
(
thd_arg
,
sequence_hton
),
limit
(
orig_lim
[
0
]),
fields
(
fields_arg
),
table_list
(
table_list_arg
)
{
// Reset limit because we are handling it now
orig_lim
->
set_unlimited
();
}
~
ha_seq_group_by_handler
()
{}
~
ha_seq_group_by_handler
()
{}
int
init_scan
()
{
first_row
=
1
;
return
0
;
}
int
init_scan
()
{
first_row
=
1
;
return
0
;
}
int
next_row
();
int
next_row
();
...
@@ -425,7 +432,8 @@ create_group_by_handler(THD *thd, Query *query)
...
@@ -425,7 +432,8 @@ create_group_by_handler(THD *thd, Query *query)
}
}
/* Create handler and return it */
/* Create handler and return it */
handler
=
new
ha_seq_group_by_handler
(
thd
,
query
->
select
,
query
->
from
);
handler
=
new
ha_seq_group_by_handler
(
thd
,
query
->
select
,
query
->
from
,
query
->
limit
);
return
handler
;
return
handler
;
}
}
...
@@ -440,7 +448,9 @@ int ha_seq_group_by_handler::next_row()
...
@@ -440,7 +448,9 @@ int ha_seq_group_by_handler::next_row()
Check if this is the first call to the function. If not, we have already
Check if this is the first call to the function. If not, we have already
returned all data.
returned all data.
*/
*/
if
(
!
first_row
)
if
(
!
first_row
||
limit
.
get_offset_limit
()
>
0
||
limit
.
get_select_limit
()
==
0
)
DBUG_RETURN
(
HA_ERR_END_OF_FILE
);
DBUG_RETURN
(
HA_ERR_END_OF_FILE
);
first_row
=
0
;
first_row
=
0
;
...
...
This diff is collapsed.
Click to expand it.
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