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
d575196c
Commit
d575196c
authored
Aug 30, 2006
by
cmiller@zippy.cornsilk.net
Browse files
Options
Browse Files
Download
Plain Diff
Manual merge.
parents
0f025681
f864c06e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
38 deletions
+60
-38
libmysql/CMakeLists.txt
libmysql/CMakeLists.txt
+1
-1
mysql-test/r/distinct.result
mysql-test/r/distinct.result
+11
-0
mysql-test/t/distinct.test
mysql-test/t/distinct.test
+11
-0
sql/sql_select.cc
sql/sql_select.cc
+34
-34
storage/innobase/os/os0file.c
storage/innobase/os/os0file.c
+1
-1
tests/mysql_client_test.c
tests/mysql_client_test.c
+2
-2
No files found.
libmysql/CMakeLists.txt
View file @
d575196c
...
@@ -11,7 +11,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
...
@@ -11,7 +11,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${
CMAKE_SOURCE_DIR
}
/sql
${
CMAKE_SOURCE_DIR
}
/sql
${
CMAKE_SOURCE_DIR
}
/strings
)
${
CMAKE_SOURCE_DIR
}
/strings
)
ADD_LIBRARY
(
libmysql
MODULE
dll.c libmysql.def
ADD_LIBRARY
(
libmysql
SHARED
dll.c libmysql.def
../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../mysys/array.c ../strings/bchange.c ../strings/bmove.c
../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c
../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c
../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c
../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c
...
...
mysql-test/r/distinct.result
View file @
d575196c
...
@@ -563,6 +563,17 @@ id IFNULL(dsc, '-')
...
@@ -563,6 +563,17 @@ id IFNULL(dsc, '-')
2 line number two
2 line number two
3 line number three
3 line number three
drop table t1;
drop table t1;
CREATE TABLE t1 (a int primary key, b int);
INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
SELECT DISTINCT a, b FROM t1 ORDER BY b;
a b
1 1
3 2
2 3
DROP TABLE t1;
CREATE TABLE t1 (
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
ID int(11) NOT NULL auto_increment,
x varchar(20) default NULL,
x varchar(20) default NULL,
...
...
mysql-test/t/distinct.test
View file @
d575196c
...
@@ -385,6 +385,17 @@ insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line
...
@@ -385,6 +385,17 @@ insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line
select
distinct
id
,
IFNULL
(
dsc
,
'-'
)
from
t1
;
select
distinct
id
,
IFNULL
(
dsc
,
'-'
)
from
t1
;
drop
table
t1
;
drop
table
t1
;
#
# Bug 21456: SELECT DISTINCT(x) produces incorrect results when using order by
#
CREATE
TABLE
t1
(
a
int
primary
key
,
b
int
);
INSERT
INTO
t1
(
a
,
b
)
values
(
1
,
1
),
(
2
,
3
),
(
3
,
2
);
explain
SELECT
DISTINCT
a
,
b
FROM
t1
ORDER
BY
b
;
SELECT
DISTINCT
a
,
b
FROM
t1
ORDER
BY
b
;
DROP
TABLE
t1
;
# End of 4.1 tests
# End of 4.1 tests
...
...
sql/sql_select.cc
View file @
d575196c
...
@@ -822,6 +822,40 @@ JOIN::optimize()
...
@@ -822,6 +822,40 @@ JOIN::optimize()
if
(
!
order
&&
org_order
)
if
(
!
order
&&
org_order
)
skip_sort_order
=
1
;
skip_sort_order
=
1
;
}
}
/*
Check if we can optimize away GROUP BY/DISTINCT.
We can do that if there are no aggregate functions and the
fields in DISTINCT clause (if present) and/or columns in GROUP BY
(if present) contain direct references to all key parts of
an unique index (in whatever order).
Note that the unique keys for DISTINCT and GROUP BY should not
be the same (as long as they are unique).
The FROM clause must contain a single non-constant table.
*/
if
(
tables
-
const_tables
==
1
&&
(
group_list
||
select_distinct
)
&&
!
tmp_table_param
.
sum_func_count
&&
(
!
join_tab
[
const_tables
].
select
||
!
join_tab
[
const_tables
].
select
->
quick
||
join_tab
[
const_tables
].
select
->
quick
->
get_type
()
!=
QUICK_SELECT_I
::
QS_TYPE_GROUP_MIN_MAX
))
{
if
(
group_list
&&
list_contains_unique_index
(
join_tab
[
const_tables
].
table
,
find_field_in_order_list
,
(
void
*
)
group_list
))
{
group_list
=
0
;
group
=
0
;
}
if
(
select_distinct
&&
list_contains_unique_index
(
join_tab
[
const_tables
].
table
,
find_field_in_item_list
,
(
void
*
)
&
fields_list
))
{
select_distinct
=
0
;
}
}
if
(
group_list
||
tmp_table_param
.
sum_func_count
)
if
(
group_list
||
tmp_table_param
.
sum_func_count
)
{
{
if
(
!
hidden_group_fields
&&
rollup
.
state
==
ROLLUP
::
STATE_NONE
)
if
(
!
hidden_group_fields
&&
rollup
.
state
==
ROLLUP
::
STATE_NONE
)
...
@@ -891,40 +925,6 @@ JOIN::optimize()
...
@@ -891,40 +925,6 @@ JOIN::optimize()
if
(
old_group_list
&&
!
group_list
)
if
(
old_group_list
&&
!
group_list
)
select_distinct
=
0
;
select_distinct
=
0
;
}
}
/*
Check if we can optimize away GROUP BY/DISTINCT.
We can do that if there are no aggregate functions and the
fields in DISTINCT clause (if present) and/or columns in GROUP BY
(if present) contain direct references to all key parts of
an unique index (in whatever order).
Note that the unique keys for DISTINCT and GROUP BY should not
be the same (as long as they are unique).
The FROM clause must contain a single non-constant table.
*/
if
(
tables
-
const_tables
==
1
&&
(
group_list
||
select_distinct
)
&&
!
tmp_table_param
.
sum_func_count
&&
(
!
join_tab
[
const_tables
].
select
||
!
join_tab
[
const_tables
].
select
->
quick
||
join_tab
[
const_tables
].
select
->
quick
->
get_type
()
!=
QUICK_SELECT_I
::
QS_TYPE_GROUP_MIN_MAX
))
{
if
(
group_list
&&
list_contains_unique_index
(
join_tab
[
const_tables
].
table
,
find_field_in_order_list
,
(
void
*
)
group_list
))
{
group_list
=
0
;
group
=
0
;
}
if
(
select_distinct
&&
list_contains_unique_index
(
join_tab
[
const_tables
].
table
,
find_field_in_item_list
,
(
void
*
)
&
fields_list
))
{
select_distinct
=
0
;
}
}
if
(
!
group_list
&&
group
)
if
(
!
group_list
&&
group
)
{
{
order
=
0
;
// The output has only one row
order
=
0
;
// The output has only one row
...
...
storage/innobase/os/os0file.c
View file @
d575196c
...
@@ -2613,7 +2613,7 @@ os_file_get_status(
...
@@ -2613,7 +2613,7 @@ os_file_get_status(
The function os_file_dirname returns a directory component of a
The function os_file_dirname returns a directory component of a
null-terminated pathname string. In the usual case, dirname returns
null-terminated pathname string. In the usual case, dirname returns
the string up to, but not including, the final '/', and basename
the string up to, but not including, the final '/', and basename
is the component following the final '/'. Trailing '/' charac
is the component following the final '/'. Trailing '/' charac
ters are not counted as part of the pathname.
ters are not counted as part of the pathname.
If path does not contain a slash, dirname returns the string ".".
If path does not contain a slash, dirname returns the string ".".
...
...
tests/mysql_client_test.c
View file @
d575196c
...
@@ -10444,8 +10444,8 @@ static void test_ps_i18n()
...
@@ -10444,8 +10444,8 @@ static void test_ps_i18n()
const
char
*
stmt_text
;
const
char
*
stmt_text
;
MYSQL_BIND
bind_array
[
2
];
MYSQL_BIND
bind_array
[
2
];
const
char
*
koi8
=
"
,
"
;
const
char
*
koi8
=
"
îÕ, ÚÁ ÒÙÂÁÌËÕ
"
;
const
char
*
cp1251
=
"
,
"
;
const
char
*
cp1251
=
"
Íó, çà ðûáàëêó
"
;
char
buf1
[
16
],
buf2
[
16
];
char
buf1
[
16
],
buf2
[
16
];
ulong
buf1_len
,
buf2_len
;
ulong
buf1_len
,
buf2_len
;
...
...
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