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
c6beb583
Commit
c6beb583
authored
Jan 29, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed functions to be able work with group function as argument
made bisone 1.75 compatible code
parent
710ffb2d
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
416 additions
and
38 deletions
+416
-38
BitKeeper/etc/logging_ok
BitKeeper/etc/logging_ok
+1
-0
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+18
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+23
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+42
-1
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+2
-0
sql/item_func.cc
sql/item_func.cc
+11
-0
sql/item_func.h
sql/item_func.h
+1
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+39
-0
sql/item_strfunc.h
sql/item_strfunc.h
+4
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+275
-36
No files found.
BitKeeper/etc/logging_ok
View file @
c6beb583
...
...
@@ -3,6 +3,7 @@ Sinisa@sinisa.nasamreza.org
arjen@fred.bitbike.com
bar@bar.mysql.r18.ru
bar@bar.udmsearch.izhnet.ru
bell@sanja.is.com.ua
bk@admin.bk
heikki@donna.mysql.fi
heikki@hundin.mysql.fi
...
...
mysql-test/r/group_by.result
View file @
c6beb583
...
...
@@ -110,3 +110,21 @@ a count(*)
NULL 9
3
b 1
a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000)
1 4 2
10 43 6
a MAX(b) CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end
1 4 4
10 43 43
a MAX(b) FIELD(MAX(b), '43', '4', '5')
1 4 2
10 43 1
a MAX(b) CONCAT_WS(MAX(b), '43', '4', '5')
1 4 434445
10 43 43434435
a MAX(b) ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f')
1 4 d
10 43 NULL
a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
1 4 c
10 43 a,b,d,f
mysql-test/t/group_by.test
View file @
c6beb583
...
...
@@ -323,3 +323,26 @@ select a,count(*) from t1 group by a;
set
option
sql_big_tables
=
1
;
select
a
,
count
(
*
)
from
t1
group
by
a
;
drop
table
t1
;
#
# group function arguments in some functions
#
create
table
t1
(
a
int
,
b
int
);
insert
into
t1
values
(
1
,
4
);
insert
into
t1
values
(
10
,
40
);
insert
into
t1
values
(
1
,
4
);
insert
into
t1
values
(
10
,
43
);
insert
into
t1
values
(
1
,
4
);
insert
into
t1
values
(
10
,
41
);
insert
into
t1
values
(
1
,
4
);
insert
into
t1
values
(
10
,
43
);
insert
into
t1
values
(
1
,
4
);
select
a
,
MAX
(
b
),
INTERVAL
(
MAX
(
b
),
1
,
3
,
10
,
30
,
39
,
40
,
50
,
60
,
100
,
1000
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
CASE
MAX
(
b
)
when
4
then
4
when
43
then
43
else
0
end
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
FIELD
(
MAX
(
b
),
'43'
,
'4'
,
'5'
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
CONCAT_WS
(
MAX
(
b
),
'43'
,
'4'
,
'5'
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
ELT
(
MAX
(
b
),
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
MAKE_SET
(
MAX
(
b
),
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
)
from
t1
group
by
a
;
drop
table
t1
;
sql/item_cmpfunc.cc
View file @
c6beb583
...
...
@@ -287,6 +287,19 @@ void Item_func_interval::fix_length_and_dec()
}
maybe_null
=
0
;
max_length
=
2
;
used_tables_cache
|=
item
->
used_tables
();
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
}
void
Item_func_interval
::
split_sum_func
(
List
<
Item
>
&
fields
)
{
if
(
item
->
with_sum_func
&&
item
->
type
()
!=
SUM_FUNC_ITEM
)
item
->
split_sum_func
(
fields
);
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
item
);
item
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
item
->
name
);
}
Item_int_func
::
split_sum_func
(
fields
);
}
/*
...
...
@@ -739,17 +752,45 @@ Item_func_case::fix_fields(THD *thd,TABLE_LIST *tables)
{
used_tables_cache
|=
(
first_expr
)
->
used_tables
();
const_item_cache
&=
(
first_expr
)
->
const_item
();
with_sum_func
=
with_sum_func
||
(
first_expr
)
->
with_sum_func
;
}
if
(
else_expr
)
{
used_tables_cache
|=
(
else_expr
)
->
used_tables
();
const_item_cache
&=
(
else_expr
)
->
const_item
();
with_sum_func
=
with_sum_func
||
(
else_expr
)
->
with_sum_func
;
}
if
(
!
else_expr
||
else_expr
->
maybe_null
)
maybe_null
=
1
;
// The result may be NULL
return
0
;
}
void
Item_func_case
::
split_sum_func
(
List
<
Item
>
&
fields
)
{
if
(
first_expr
)
{
if
(
first_expr
->
with_sum_func
&&
first_expr
->
type
()
!=
SUM_FUNC_ITEM
)
first_expr
->
split_sum_func
(
fields
);
else
if
(
first_expr
->
used_tables
()
||
first_expr
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
first_expr
);
first_expr
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
first_expr
->
name
);
}
}
if
(
else_expr
)
{
if
(
else_expr
->
with_sum_func
&&
else_expr
->
type
()
!=
SUM_FUNC_ITEM
)
else_expr
->
split_sum_func
(
fields
);
else
if
(
else_expr
->
used_tables
()
||
else_expr
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
else_expr
);
else_expr
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
else_expr
->
name
);
}
}
Item_func
::
split_sum_func
(
fields
);
}
void
Item_func_case
::
update_used_tables
()
{
Item_func
::
update_used_tables
();
...
...
@@ -1038,7 +1079,7 @@ void Item_func_in::split_sum_func(List<Item> &fields)
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
item
);
item
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
item
->
name
);
item
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
item
->
name
);
}
Item_func
::
split_sum_func
(
fields
);
}
...
...
sql/item_cmpfunc.h
View file @
c6beb583
...
...
@@ -180,6 +180,7 @@ class Item_func_interval :public Item_int_func
{
return
(
item
->
fix_fields
(
thd
,
tlist
)
||
Item_func
::
fix_fields
(
thd
,
tlist
));
}
void
split_sum_func
(
List
<
Item
>
&
fields
);
void
fix_length_and_dec
();
~
Item_func_interval
()
{
delete
item
;
}
const
char
*
func_name
()
const
{
return
"interval"
;
}
...
...
@@ -259,6 +260,7 @@ class Item_func_case :public Item_func
const
char
*
func_name
()
const
{
return
"case"
;
}
void
print
(
String
*
str
);
bool
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tlist
);
void
split_sum_func
(
List
<
Item
>
&
fields
);
Item
*
find_item
(
String
*
str
);
};
...
...
sql/item_func.cc
View file @
c6beb583
...
...
@@ -864,6 +864,17 @@ longlong Item_func_field::val_int()
return
0
;
}
void
Item_func_field
::
split_sum_func
(
List
<
Item
>
&
fields
)
{
if
(
item
->
with_sum_func
&&
item
->
type
()
!=
SUM_FUNC_ITEM
)
item
->
split_sum_func
(
fields
);
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
item
);
item
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
item
->
name
);
}
Item_func
::
split_sum_func
(
fields
);
}
longlong
Item_func_ascii
::
val_int
()
{
...
...
sql/item_func.h
View file @
c6beb583
...
...
@@ -517,6 +517,7 @@ class Item_func_field :public Item_int_func
{
return
(
item
->
fix_fields
(
thd
,
tlist
)
||
Item_func
::
fix_fields
(
thd
,
tlist
));
}
void
split_sum_func
(
List
<
Item
>
&
fields
);
void
update_used_tables
()
{
item
->
update_used_tables
()
;
Item_func
::
update_used_tables
();
...
...
sql/item_strfunc.cc
View file @
c6beb583
...
...
@@ -310,6 +310,17 @@ String *Item_func_concat_ws::val_str(String *str)
return
0
;
}
void
Item_func_concat_ws
::
split_sum_func
(
List
<
Item
>
&
fields
)
{
if
(
separator
->
with_sum_func
&&
separator
->
type
()
!=
SUM_FUNC_ITEM
)
separator
->
split_sum_func
(
fields
);
else
if
(
separator
->
used_tables
()
||
separator
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
separator
);
separator
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
separator
->
name
);
}
Item_str_func
::
split_sum_func
(
fields
);
}
void
Item_func_concat_ws
::
fix_length_and_dec
()
{
...
...
@@ -323,6 +334,7 @@ void Item_func_concat_ws::fix_length_and_dec()
}
used_tables_cache
|=
separator
->
used_tables
();
const_item_cache
&=
separator
->
const_item
();
with_sum_func
=
with_sum_func
||
separator
->
with_sum_func
;
}
void
Item_func_concat_ws
::
update_used_tables
()
...
...
@@ -1221,6 +1233,19 @@ void Item_func_elt::fix_length_and_dec()
}
void
Item_func_elt
::
split_sum_func
(
List
<
Item
>
&
fields
)
{
if
(
item
->
with_sum_func
&&
item
->
type
()
!=
SUM_FUNC_ITEM
)
item
->
split_sum_func
(
fields
);
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
item
);
item
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
item
->
name
);
}
Item_str_func
::
split_sum_func
(
fields
);
}
void
Item_func_elt
::
update_used_tables
()
{
Item_func
::
update_used_tables
();
...
...
@@ -1267,6 +1292,19 @@ String *Item_func_elt::val_str(String *str)
}
void
Item_func_make_set
::
split_sum_func
(
List
<
Item
>
&
fields
)
{
if
(
item
->
with_sum_func
&&
item
->
type
()
!=
SUM_FUNC_ITEM
)
item
->
split_sum_func
(
fields
);
else
if
(
item
->
used_tables
()
||
item
->
type
()
==
SUM_FUNC_ITEM
)
{
fields
.
push_front
(
item
);
item
=
new
Item_ref
((
Item
**
)
fields
.
head_ref
(),
0
,
item
->
name
);
}
Item_str_func
::
split_sum_func
(
fields
);
}
void
Item_func_make_set
::
fix_length_and_dec
()
{
max_length
=
arg_count
-
1
;
...
...
@@ -1274,6 +1312,7 @@ void Item_func_make_set::fix_length_and_dec()
max_length
+=
args
[
i
]
->
max_length
;
used_tables_cache
|=
item
->
used_tables
();
const_item_cache
&=
item
->
const_item
();
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
}
...
...
sql/item_strfunc.h
View file @
c6beb583
...
...
@@ -75,6 +75,7 @@ class Item_func_concat_ws :public Item_str_func
return
(
separator
->
fix_fields
(
thd
,
tlist
)
||
Item_func
::
fix_fields
(
thd
,
tlist
));
}
void
split_sum_func
(
List
<
Item
>
&
fields
);
const
char
*
func_name
()
const
{
return
"concat_ws"
;
}
};
...
...
@@ -296,6 +297,7 @@ class Item_func_elt :public Item_str_func
{
return
(
item
->
fix_fields
(
thd
,
tlist
)
||
Item_func
::
fix_fields
(
thd
,
tlist
));
}
void
split_sum_func
(
List
<
Item
>
&
fields
);
void
fix_length_and_dec
();
void
update_used_tables
();
const
char
*
func_name
()
const
{
return
"elt"
;
}
...
...
@@ -315,6 +317,7 @@ class Item_func_make_set :public Item_str_func
{
return
(
item
->
fix_fields
(
thd
,
tlist
)
||
Item_func
::
fix_fields
(
thd
,
tlist
));
}
void
split_sum_func
(
List
<
Item
>
&
fields
);
void
fix_length_and_dec
();
void
update_used_tables
();
const
char
*
func_name
()
const
{
return
"make_set"
;
}
...
...
sql/sql_yacc.yy
View file @
c6beb583
This diff is collapsed.
Click to expand it.
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