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
4bf2408e
Commit
4bf2408e
authored
Sep 14, 2007
by
gshchepa@devsrv-b.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge gshchepa@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into devsrv-b.mysql.com:/data0/gshchepa/mysql-5.0-opt
parents
e6e56ccc
0133bc63
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
173 additions
and
1 deletion
+173
-1
mysql-test/r/innodb_mysql.result
mysql-test/r/innodb_mysql.result
+97
-0
mysql-test/r/type_bit.result
mysql-test/r/type_bit.result
+15
-0
mysql-test/t/innodb_mysql.test
mysql-test/t/innodb_mysql.test
+23
-0
mysql-test/t/type_bit.test
mysql-test/t/type_bit.test
+14
-0
sql/item_sum.cc
sql/item_sum.cc
+17
-0
sql/sql_select.cc
sql/sql_select.cc
+7
-1
No files found.
mysql-test/r/innodb_mysql.result
View file @
4bf2408e
...
...
@@ -1114,4 +1114,101 @@ c b
3 1
3 2
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), INDEX b (b)) ENGINE=InnoDB;
INSERT INTO t1(a,b) VALUES (1,1), (2,2), (3,2);
EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
id 1
select_type SIMPLE
table t1
type ref
possible_keys b
key b
key_len 5
ref const
rows 1
Extra Using where; Using index
SELECT * FROM t1 WHERE b=2 ORDER BY a ASC;
a b
2 2
3 2
EXPLAIN SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
id 1
select_type SIMPLE
table t1
type ref
possible_keys b
key b
key_len 5
ref const
rows 1
Extra Using where; Using index
SELECT * FROM t1 WHERE b=2 ORDER BY a DESC;
a b
3 2
2 2
EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a ASC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index
SELECT * FROM t1 ORDER BY b ASC, a ASC;
a b
1 1
2 2
3 2
EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a DESC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index
SELECT * FROM t1 ORDER BY b DESC, a DESC;
a b
3 2
2 2
1 1
EXPLAIN SELECT * FROM t1 ORDER BY b ASC, a DESC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index; Using filesort
SELECT * FROM t1 ORDER BY b ASC, a DESC;
a b
1 1
3 2
2 2
EXPLAIN SELECT * FROM t1 ORDER BY b DESC, a ASC;
id 1
select_type SIMPLE
table t1
type index
possible_keys NULL
key b
key_len 5
ref NULL
rows 3
Extra Using index; Using filesort
SELECT * FROM t1 ORDER BY b DESC, a ASC;
a b
2 2
3 2
1 1
DROP TABLE t1;
End of 5.0 tests
mysql-test/r/type_bit.result
View file @
4bf2408e
...
...
@@ -657,4 +657,19 @@ b
#
#
DROP TABLE t1;
CREATE TABLE t1 (a int, b bit(2));
INSERT INTO t1 VALUES (3, 2), (2, 3), (2, 0), (3, 2), (3, 1);
SELECT COUNT(DISTINCT b) FROM t1 GROUP BY a;
COUNT(DISTINCT b)
2
2
DROP TABLE t1;
create table t2 (a int, b bit(2), c char(10));
INSERT INTO t2 VALUES (3, 2, 'two'), (2, 3, 'three'), (2, 0, 'zero'),
(3, 2, 'two'), (3, 1, 'one');
SELECT COUNT(DISTINCT b,c) FROM t2 GROUP BY a;
COUNT(DISTINCT b,c)
2
2
DROP TABLE t2;
End of 5.0 tests
mysql-test/t/innodb_mysql.test
View file @
4bf2408e
...
...
@@ -937,4 +937,27 @@ SELECT c,b FROM t1 GROUP BY c,b;
DROP
TABLE
t1
;
#
# Bug #31001: ORDER BY DESC in InnoDB not working
#
CREATE
TABLE
t1
(
a
INT
,
b
INT
,
PRIMARY
KEY
(
a
),
INDEX
b
(
b
))
ENGINE
=
InnoDB
;
INSERT
INTO
t1
(
a
,
b
)
VALUES
(
1
,
1
),
(
2
,
2
),
(
3
,
2
);
#The two queries below should produce different results, but they don't.
query_vertical
EXPLAIN
SELECT
*
FROM
t1
WHERE
b
=
2
ORDER
BY
a
ASC
;
SELECT
*
FROM
t1
WHERE
b
=
2
ORDER
BY
a
ASC
;
query_vertical
EXPLAIN
SELECT
*
FROM
t1
WHERE
b
=
2
ORDER
BY
a
DESC
;
SELECT
*
FROM
t1
WHERE
b
=
2
ORDER
BY
a
DESC
;
query_vertical
EXPLAIN
SELECT
*
FROM
t1
ORDER
BY
b
ASC
,
a
ASC
;
SELECT
*
FROM
t1
ORDER
BY
b
ASC
,
a
ASC
;
query_vertical
EXPLAIN
SELECT
*
FROM
t1
ORDER
BY
b
DESC
,
a
DESC
;
SELECT
*
FROM
t1
ORDER
BY
b
DESC
,
a
DESC
;
query_vertical
EXPLAIN
SELECT
*
FROM
t1
ORDER
BY
b
ASC
,
a
DESC
;
SELECT
*
FROM
t1
ORDER
BY
b
ASC
,
a
DESC
;
query_vertical
EXPLAIN
SELECT
*
FROM
t1
ORDER
BY
b
DESC
,
a
ASC
;
SELECT
*
FROM
t1
ORDER
BY
b
DESC
,
a
ASC
;
DROP
TABLE
t1
;
--
echo
End
of
5.0
tests
mysql-test/t/type_bit.test
View file @
4bf2408e
...
...
@@ -304,4 +304,18 @@ SELECT b FROM t1 GROUP BY b;
--
disable_metadata
DROP
TABLE
t1
;
#
# BUG#30324 Wrong query result for COUNT(DISTINCT(bit_column))
#
CREATE
TABLE
t1
(
a
int
,
b
bit
(
2
));
INSERT
INTO
t1
VALUES
(
3
,
2
),
(
2
,
3
),
(
2
,
0
),
(
3
,
2
),
(
3
,
1
);
SELECT
COUNT
(
DISTINCT
b
)
FROM
t1
GROUP
BY
a
;
DROP
TABLE
t1
;
create
table
t2
(
a
int
,
b
bit
(
2
),
c
char
(
10
));
INSERT
INTO
t2
VALUES
(
3
,
2
,
'two'
),
(
2
,
3
,
'three'
),
(
2
,
0
,
'zero'
),
(
3
,
2
,
'two'
),
(
3
,
1
,
'one'
);
SELECT
COUNT
(
DISTINCT
b
,
c
)
FROM
t2
GROUP
BY
a
;
DROP
TABLE
t2
;
--
echo
End
of
5.0
tests
sql/item_sum.cc
View file @
4bf2408e
...
...
@@ -2464,6 +2464,23 @@ bool Item_sum_count_distinct::setup(THD *thd)
count_field_types
(
select_lex
,
tmp_table_param
,
list
,
0
);
tmp_table_param
->
force_copy_fields
=
force_copy_fields
;
DBUG_ASSERT
(
table
==
0
);
/*
Make create_tmp_table() convert BIT columns to BIGINT.
This is needed because BIT fields store parts of their data in table's
null bits, and we don't have methods to compare two table records, which
is needed by Unique which is used when HEAP table is used.
*/
{
List_iterator_fast
<
Item
>
li
(
list
);
Item
*
item
;
while
((
item
=
li
++
))
{
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
&&
((
Item_field
*
)
item
)
->
field
->
type
()
==
FIELD_TYPE_BIT
)
item
->
marker
=
4
;
}
}
if
(
!
(
table
=
create_tmp_table
(
thd
,
tmp_table_param
,
list
,
(
ORDER
*
)
0
,
1
,
0
,
(
select_lex
->
options
|
thd
->
options
),
...
...
sql/sql_select.cc
View file @
4bf2408e
...
...
@@ -12063,6 +12063,12 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
for
(;
const_key_parts
&
1
;
const_key_parts
>>=
1
)
key_part
++
;
/*
The primary and secondary key parts were all const (i.e. there's
one row). The sorting doesn't matter.
*/
if
(
key_part
==
key_part_end
&&
reverse
==
0
)
DBUG_RETURN
(
1
);
}
else
DBUG_RETURN
(
0
);
...
...
@@ -12480,7 +12486,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
}
DBUG_RETURN
(
1
);
}
if
(
tab
->
ref
.
key_parts
<
used_key_parts
)
if
(
tab
->
ref
.
key_parts
<
=
used_key_parts
)
{
/*
SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC
...
...
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