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
bb77b2e5
Commit
bb77b2e5
authored
Jan 17, 2005
by
timour@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for BUG#7331 merged manually from 4.1.
parent
2933cd3d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
7 deletions
+87
-7
mysql-test/r/order_by.result
mysql-test/r/order_by.result
+38
-0
mysql-test/t/order_by.test
mysql-test/t/order_by.test
+33
-0
sql/sql_select.cc
sql/sql_select.cc
+16
-7
No files found.
mysql-test/r/order_by.result
View file @
bb77b2e5
...
@@ -740,3 +740,41 @@ a b
...
@@ -740,3 +740,41 @@ a b
1 2
1 2
1 1
1 1
drop table t1;
drop table t1;
create table t1 (
`sid` decimal(8,0) default null,
`wnid` varchar(11) not null default '',
key `wnid14` (`wnid`(4)),
key `wnid` (`wnid`)
) engine=myisam default charset=latin1;
insert into t1 (`sid`, `wnid`) values
('10100','01019000000'),('37986','01019000000'),('37987','01019010000'),
('39560','01019090000'),('37989','01019000000'),('37990','01019011000'),
('37991','01019011000'),('37992','01019019000'),('37993','01019030000'),
('37994','01019090000'),('475','02070000000'),('25253','02071100000'),
('25255','02071100000'),('25256','02071110000'),('25258','02071130000'),
('25259','02071190000'),('25260','02071200000'),('25261','02071210000'),
('25262','02071290000'),('25263','02071300000'),('25264','02071310000'),
('25265','02071310000'),('25266','02071320000'),('25267','02071320000'),
('25269','02071330000'),('25270','02071340000'),('25271','02071350000'),
('25272','02071360000'),('25273','02071370000'),('25281','02071391000'),
('25282','02071391000'),('25283','02071399000'),('25284','02071400000'),
('25285','02071410000'),('25286','02071410000'),('25287','02071420000'),
('25288','02071420000'),('25291','02071430000'),('25290','02071440000'),
('25292','02071450000'),('25293','02071460000'),('25294','02071470000'),
('25295','02071491000'),('25296','02071491000'),('25297','02071499000');
explain select * from t1 where wnid like '0101%' order by wnid;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range wnid14,wnid wnid 13 NULL 10 Using where
select * from t1 where wnid like '0101%' order by wnid;
sid wnid
10100 01019000000
37986 01019000000
37989 01019000000
37987 01019010000
37990 01019011000
37991 01019011000
37992 01019019000
37993 01019030000
39560 01019090000
37994 01019090000
drop table t1;
mysql-test/t/order_by.test
View file @
bb77b2e5
...
@@ -506,3 +506,36 @@ insert t1 values (1,1,1),(1,1,2),(1,2,1);
...
@@ -506,3 +506,36 @@ insert t1 values (1,1,1),(1,1,2),(1,2,1);
select
a
,
b
from
t1
group
by
a
,
b
order
by
sum
(
c
);
select
a
,
b
from
t1
group
by
a
,
b
order
by
sum
(
c
);
drop
table
t1
;
drop
table
t1
;
#
# Bug #7331
#
create
table
t1
(
`sid`
decimal
(
8
,
0
)
default
null
,
`wnid`
varchar
(
11
)
not
null
default
''
,
key
`wnid14`
(
`wnid`
(
4
)),
key
`wnid`
(
`wnid`
)
)
engine
=
myisam
default
charset
=
latin1
;
insert
into
t1
(
`sid`
,
`wnid`
)
values
(
'10100'
,
'01019000000'
),(
'37986'
,
'01019000000'
),(
'37987'
,
'01019010000'
),
(
'39560'
,
'01019090000'
),(
'37989'
,
'01019000000'
),(
'37990'
,
'01019011000'
),
(
'37991'
,
'01019011000'
),(
'37992'
,
'01019019000'
),(
'37993'
,
'01019030000'
),
(
'37994'
,
'01019090000'
),(
'475'
,
'02070000000'
),(
'25253'
,
'02071100000'
),
(
'25255'
,
'02071100000'
),(
'25256'
,
'02071110000'
),(
'25258'
,
'02071130000'
),
(
'25259'
,
'02071190000'
),(
'25260'
,
'02071200000'
),(
'25261'
,
'02071210000'
),
(
'25262'
,
'02071290000'
),(
'25263'
,
'02071300000'
),(
'25264'
,
'02071310000'
),
(
'25265'
,
'02071310000'
),(
'25266'
,
'02071320000'
),(
'25267'
,
'02071320000'
),
(
'25269'
,
'02071330000'
),(
'25270'
,
'02071340000'
),(
'25271'
,
'02071350000'
),
(
'25272'
,
'02071360000'
),(
'25273'
,
'02071370000'
),(
'25281'
,
'02071391000'
),
(
'25282'
,
'02071391000'
),(
'25283'
,
'02071399000'
),(
'25284'
,
'02071400000'
),
(
'25285'
,
'02071410000'
),(
'25286'
,
'02071410000'
),(
'25287'
,
'02071420000'
),
(
'25288'
,
'02071420000'
),(
'25291'
,
'02071430000'
),(
'25290'
,
'02071440000'
),
(
'25292'
,
'02071450000'
),(
'25293'
,
'02071460000'
),(
'25294'
,
'02071470000'
),
(
'25295'
,
'02071491000'
),(
'25296'
,
'02071491000'
),(
'25297'
,
'02071499000'
);
explain
select
*
from
t1
where
wnid
like
'0101%'
order
by
wnid
;
select
*
from
t1
where
wnid
like
'0101%'
order
by
wnid
;
drop
table
t1
;
sql/sql_select.cc
View file @
bb77b2e5
...
@@ -10426,13 +10426,22 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
...
@@ -10426,13 +10426,22 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
}
else
else
{
{
select
->
quick
->
head
->
file
->
ha_index_end
();
/*
/*
The range optimizer constructed QUICK_RANGE for ref_key, and
We have verified above that select->quick is not
we want to use instead new_ref_key as the index. We can't
index_merge quick select.
just change the index of the quick select, because this may
*/
result in an incosistent QUICK_SELECT object. Below we
select
->
quick
->
index
=
new_ref_key
;
create a new QUICK_SELECT from scratch so that all its
select
->
quick
->
init
();
parameres are set correctly by the range optimizer.
*/
key_map
new_ref_key_map
;
new_ref_key_map
.
clear_all
();
/* Force the creation of quick select */
new_ref_key_map
.
set_bit
(
new_ref_key
);
/* only for new_ref_key. */
if
(
select
->
test_quick_select
(
tab
->
join
->
thd
,
new_ref_key_map
,
0
,
(
tab
->
join
->
select_options
&
OPTION_FOUND_ROWS
)
?
HA_POS_ERROR
:
tab
->
join
->
unit
->
select_limit_cnt
)
<=
0
)
DBUG_RETURN
(
0
);
}
}
ref_key
=
new_ref_key
;
ref_key
=
new_ref_key
;
}
}
...
...
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