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
3e8e4d06
Commit
3e8e4d06
authored
Nov 10, 2004
by
ram@gw.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A fix (bug #6475: Another server crash in 5.0.2
bug #6515: count(distinct...) crashes the server)
parent
a3f4bd28
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
11 deletions
+64
-11
mysql-test/r/count_distinct.result
mysql-test/r/count_distinct.result
+7
-0
mysql-test/r/func_gconcat.result
mysql-test/r/func_gconcat.result
+7
-0
mysql-test/t/count_distinct.test
mysql-test/t/count_distinct.test
+8
-0
mysql-test/t/func_gconcat.test
mysql-test/t/func_gconcat.test
+9
-0
sql/sql_select.cc
sql/sql_select.cc
+33
-11
No files found.
mysql-test/r/count_distinct.result
View file @
3e8e4d06
...
...
@@ -53,3 +53,10 @@ select count(distinct f) from t1;
count(distinct f)
0
drop table t1;
create table t1 (a char(3), b char(20), primary key (a, b));
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
select count(distinct a) from t1 group by b;
count(distinct a)
1
1
drop table t1;
mysql-test/r/func_gconcat.result
View file @
3e8e4d06
...
...
@@ -457,3 +457,10 @@ group_concat(distinct b order by b)
Warnings:
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
drop table t1;
create table t1 (a char(3), b char(20), primary key (a, b));
insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English');
select group_concat(a) from t1 group by b;
group_concat(a)
ABW
ABW
drop table t1;
mysql-test/t/count_distinct.test
View file @
3e8e4d06
...
...
@@ -55,3 +55,11 @@ create table t1 (f int);
select
count
(
distinct
f
)
from
t1
;
drop
table
t1
;
#
# Bug #6515
#
create
table
t1
(
a
char
(
3
),
b
char
(
20
),
primary
key
(
a
,
b
));
insert
into
t1
values
(
'ABW'
,
'Dutch'
),
(
'ABW'
,
'English'
);
select
count
(
distinct
a
)
from
t1
group
by
b
;
drop
table
t1
;
mysql-test/t/func_gconcat.test
View file @
3e8e4d06
...
...
@@ -277,3 +277,12 @@ select group_concat(b order by b) from t1 group by a;
select
group_concat
(
distinct
b
order
by
b
)
from
t1
group
by
a
;
drop
table
t1
;
#
# Bug #6475
#
create
table
t1
(
a
char
(
3
),
b
char
(
20
),
primary
key
(
a
,
b
));
insert
into
t1
values
(
'ABW'
,
'Dutch'
),
(
'ABW'
,
'English'
);
select
group_concat
(
a
)
from
t1
group
by
b
;
drop
table
t1
;
sql/sql_select.cc
View file @
3e8e4d06
...
...
@@ -192,6 +192,7 @@ static void init_tmptable_sum_functions(Item_sum **func);
static
void
update_tmptable_sum_func
(
Item_sum
**
func
,
TABLE
*
tmp_table
);
static
void
copy_sum_funcs
(
Item_sum
**
func_ptr
);
static
bool
add_ref_to_table_cond
(
THD
*
thd
,
JOIN_TAB
*
join_tab
);
static
bool
setup_sum_funcs
(
THD
*
thd
,
Item_sum
**
func_ptr
);
static
bool
init_sum_functions
(
Item_sum
**
func
,
Item_sum
**
end
);
static
bool
update_sum_func
(
Item_sum
**
func
);
static
void
select_describe
(
JOIN
*
join
,
bool
need_tmp_table
,
bool
need_order
,
...
...
@@ -990,13 +991,15 @@ JOIN::optimize()
if
(
create_sort_index
(
thd
,
this
,
group_list
,
HA_POS_ERROR
,
HA_POS_ERROR
)
||
alloc_group_fields
(
this
,
group_list
)
||
make_sum_func_list
(
all_fields
,
fields_list
,
1
))
make_sum_func_list
(
all_fields
,
fields_list
,
1
)
||
setup_sum_funcs
(
thd
,
sum_funcs
))
DBUG_RETURN
(
1
);
group_list
=
0
;
}
else
{
if
(
make_sum_func_list
(
all_fields
,
fields_list
,
0
))
if
(
make_sum_func_list
(
all_fields
,
fields_list
,
0
)
||
setup_sum_funcs
(
thd
,
sum_funcs
))
DBUG_RETURN
(
1
);
if
(
!
group_list
&&
!
exec_tmp_table1
->
distinct
&&
order
&&
simple_order
)
{
...
...
@@ -1372,6 +1375,7 @@ JOIN::exec()
}
if
(
curr_join
->
make_sum_func_list
(
*
curr_all_fields
,
*
curr_fields_list
,
1
,
TRUE
)
||
setup_sum_funcs
(
curr_join
->
thd
,
curr_join
->
sum_funcs
)
||
(
tmp_error
=
do_select
(
curr_join
,
(
List
<
Item
>
*
)
0
,
curr_tmp_table
,
0
)))
{
...
...
@@ -1459,7 +1463,9 @@ JOIN::exec()
set_items_ref_array
(
items3
);
if
(
curr_join
->
make_sum_func_list
(
*
curr_all_fields
,
*
curr_fields_list
,
1
,
TRUE
)
||
thd
->
is_fatal_error
)
1
,
TRUE
)
||
setup_sum_funcs
(
curr_join
->
thd
,
curr_join
->
sum_funcs
)
||
thd
->
is_fatal_error
)
DBUG_VOID_RETURN
;
}
if
(
curr_join
->
group_list
||
curr_join
->
order
)
...
...
@@ -11794,9 +11800,6 @@ bool JOIN::alloc_func_list()
before_group_by Set to 1 if this is called before GROUP BY handling
recompute Set to TRUE if sum_funcs must be recomputed
NOTES
Calls ::setup() for all item_sum objects in field_list
RETURN
0 ok
1 error
...
...
@@ -11817,12 +11820,7 @@ bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_fields,
while
((
item
=
it
++
))
{
if
(
item
->
type
()
==
Item
::
SUM_FUNC_ITEM
&&
!
item
->
const_item
())
{
*
func
++=
(
Item_sum
*
)
item
;
/* let COUNT(DISTINCT) create the temporary table */
if
(((
Item_sum
*
)
item
)
->
setup
(
thd
))
DBUG_RETURN
(
TRUE
);
}
}
if
(
before_group_by
&&
rollup
.
state
==
ROLLUP
::
STATE_INITED
)
{
...
...
@@ -11967,6 +11965,30 @@ change_refs_to_tmp_fields(THD *thd, Item **ref_pointer_array,
Code for calculating functions
******************************************************************************/
/*
Call ::setup for all sum functions
SYNOPSIS
setup_sum_funcs()
thd thread handler
func_ptr sum function list
RETURN
FALSE ok
TRUE error
*/
static
bool
setup_sum_funcs
(
THD
*
thd
,
Item_sum
**
func_ptr
)
{
Item_sum
*
func
;
while
((
func
=
*
(
func_ptr
++
)))
if
(
func
->
setup
(
thd
))
return
TRUE
;
return
FALSE
;
}
static
void
init_tmptable_sum_functions
(
Item_sum
**
func_ptr
)
{
...
...
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