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
f5f55979
Commit
f5f55979
authored
Sep 30, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug#5782
parent
8a63a0b5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
2 deletions
+83
-2
mysql-test/r/ndb_limit.result
mysql-test/r/ndb_limit.result
+41
-0
mysql-test/t/ndb_limit.test
mysql-test/t/ndb_limit.test
+38
-0
sql/sql_select.cc
sql/sql_select.cc
+4
-2
No files found.
mysql-test/r/ndb_limit.result
View file @
f5f55979
...
...
@@ -29,3 +29,44 @@ count(*)
select * from t2 limit 0;
a b c
drop table t2;
CREATE TABLE `t2` (
`views` int(11) NOT NULL default '0',
`clicks` int(11) NOT NULL default '0',
`day` date NOT NULL default '0000-00-00',
`hour` tinyint(4) NOT NULL default '0',
`bannerid` smallint(6) NOT NULL default '0',
`zoneid` smallint(6) NOT NULL default '0',
`source` varchar(50) NOT NULL default '',
PRIMARY KEY (`day`,`hour`,`bannerid`,`zoneid`,`source`),
KEY `bannerid_day` (`bannerid`,`day`),
KEY `zoneid` (`zoneid`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
INSERT INTO `t2` VALUES
( 1,0,'2004-09-17', 5,100,100,''),
( 1,0,'2004-09-18', 7,100,100,''),
( 17,0,'2004-09-27',20,132,100,''),
( 4,0,'2004-09-16',23,132,100,''),
( 86,0,'2004-09-18', 7,196,196,''),
( 11,0,'2004-09-16',16,132,100,''),
(140,0,'2004-09-18', 0,100,164,''),
( 2,0,'2004-09-17', 7,132,100,''),
(846,0,'2004-09-27',11,132,164,''),
( 1,0,'2004-09-18', 8,132,100,''),
( 22,0,'2004-09-27', 9,164,132,''),
(711,0,'2004-09-27', 9,100,164,''),
( 11,0,'2004-09-18', 0,196,132,''),
( 41,0,'2004-09-27',15,196,132,''),
( 57,0,'2004-09-18', 2,164,196,'');
SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y')
as date_formatted FROM t2 GROUP BY day ORDER BY day DESC;
date date_formatted
20040927 27-09-2004
20040918 18-09-2004
20040917 17-09-2004
20040916 16-09-2004
SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y')
as date_formatted FROM t2 GROUP BY day ORDER BY day DESC LIMIT 2;
date date_formatted
20040927 27-09-2004
20040918 18-09-2004
drop table t2;
mysql-test/t/ndb_limit.test
View file @
f5f55979
...
...
@@ -42,3 +42,41 @@ select count(*) from t2 where c=12345678 limit 1000;
select
*
from
t2
limit
0
;
drop
table
t2
;
CREATE
TABLE
`t2`
(
`views`
int
(
11
)
NOT
NULL
default
'0'
,
`clicks`
int
(
11
)
NOT
NULL
default
'0'
,
`day`
date
NOT
NULL
default
'0000-00-00'
,
`hour`
tinyint
(
4
)
NOT
NULL
default
'0'
,
`bannerid`
smallint
(
6
)
NOT
NULL
default
'0'
,
`zoneid`
smallint
(
6
)
NOT
NULL
default
'0'
,
`source`
varchar
(
50
)
NOT
NULL
default
''
,
PRIMARY
KEY
(
`day`
,
`hour`
,
`bannerid`
,
`zoneid`
,
`source`
),
KEY
`bannerid_day`
(
`bannerid`
,
`day`
),
KEY
`zoneid`
(
`zoneid`
)
)
ENGINE
=
ndbcluster
DEFAULT
CHARSET
=
latin1
;
INSERT
INTO
`t2`
VALUES
(
1
,
0
,
'2004-09-17'
,
5
,
100
,
100
,
''
),
(
1
,
0
,
'2004-09-18'
,
7
,
100
,
100
,
''
),
(
17
,
0
,
'2004-09-27'
,
20
,
132
,
100
,
''
),
(
4
,
0
,
'2004-09-16'
,
23
,
132
,
100
,
''
),
(
86
,
0
,
'2004-09-18'
,
7
,
196
,
196
,
''
),
(
11
,
0
,
'2004-09-16'
,
16
,
132
,
100
,
''
),
(
140
,
0
,
'2004-09-18'
,
0
,
100
,
164
,
''
),
(
2
,
0
,
'2004-09-17'
,
7
,
132
,
100
,
''
),
(
846
,
0
,
'2004-09-27'
,
11
,
132
,
164
,
''
),
(
1
,
0
,
'2004-09-18'
,
8
,
132
,
100
,
''
),
(
22
,
0
,
'2004-09-27'
,
9
,
164
,
132
,
''
),
(
711
,
0
,
'2004-09-27'
,
9
,
100
,
164
,
''
),
(
11
,
0
,
'2004-09-18'
,
0
,
196
,
132
,
''
),
(
41
,
0
,
'2004-09-27'
,
15
,
196
,
132
,
''
),
(
57
,
0
,
'2004-09-18'
,
2
,
164
,
196
,
''
);
SELECT
DATE_FORMAT
(
day
,
'%Y%m%d'
)
as
date
,
DATE_FORMAT
(
day
,
'%d-%m-%Y'
)
as
date_formatted
FROM
t2
GROUP
BY
day
ORDER
BY
day
DESC
;
SELECT
DATE_FORMAT
(
day
,
'%Y%m%d'
)
as
date
,
DATE_FORMAT
(
day
,
'%d-%m-%Y'
)
as
date_formatted
FROM
t2
GROUP
BY
day
ORDER
BY
day
DESC
LIMIT
2
;
drop
table
t2
;
sql/sql_select.cc
View file @
f5f55979
...
...
@@ -7188,11 +7188,13 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
for
(
nr
=
0
;
nr
<
table
->
keys
;
nr
++
)
{
uint
not_used
;
uint
used_key_parts
;
if
(
keys
.
is_set
(
nr
))
{
int
flag
;
if
((
flag
=
test_if_order_by_key
(
order
,
table
,
nr
,
&
not_used
)))
if
((
flag
=
test_if_order_by_key
(
order
,
table
,
nr
,
&
used_key_parts
))
>
0
||
((
flag
<
0
)
&&
(
table
->
file
->
index_flags
(
nr
,
used_key_parts
-
1
,
1
)
&
HA_READ_PREV
)))
{
if
(
!
no_changes
)
{
...
...
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