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
a662f7e1
Commit
a662f7e1
authored
Jan 29, 2003
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed row items with group functions
fixed layout
parent
9525a581
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
12 deletions
+64
-12
.bzrignore
.bzrignore
+3
-0
mysql-test/r/row.result
mysql-test/r/row.result
+15
-0
mysql-test/t/row.test
mysql-test/t/row.test
+12
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+2
-0
sql/item_func.cc
sql/item_func.cc
+3
-3
sql/item_row.cc
sql/item_row.cc
+28
-9
sql/item_row.h
sql/item_row.h
+1
-0
No files found.
.bzrignore
View file @
a662f7e1
...
...
@@ -591,3 +591,6 @@ help.c
vi.h
include/readline/readline.h
cmd-line-utils/libedit/common.h
stamp-h2
stamp-h3
stamp-h4
mysql-test/r/row.result
View file @
a662f7e1
...
...
@@ -144,3 +144,18 @@ Cardinality error (more/less than 1 columns)
select count(*) from t1 having (1,1) order by i;
Cardinality error (more/less than 1 columns)
drop table t1;
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), (1, MAX(b)) = (1, 4) from t1 group by a;
a MAX(b) (1, MAX(b)) = (1, 4)
1 4 1
10 43 0
drop table t1;
mysql-test/t/row.test
View file @
a662f7e1
...
...
@@ -67,3 +67,15 @@ select count(*) from t1 order by ROW(1,1);
select
count
(
*
)
from
t1
having
(
1
,
1
)
order
by
i
;
drop
table
t1
;
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
),
(
1
,
MAX
(
b
))
=
(
1
,
4
)
from
t1
group
by
a
;
drop
table
t1
;
sql/item_cmpfunc.cc
View file @
a662f7e1
...
...
@@ -1079,8 +1079,10 @@ in_string::in_string(uint elements,qsort_cmp cmp_func)
in_string
::~
in_string
()
{
if
(
base
)
{
for
(
uint
i
=
0
;
i
<
count
;
i
++
)
((
String
*
)
base
)[
i
].
free
();
}
}
void
in_string
::
set
(
uint
pos
,
Item
*
item
)
...
...
sql/item_func.cc
View file @
a662f7e1
...
...
@@ -157,8 +157,8 @@ void Item_func::set_outer_resolving()
void
Item_func
::
split_sum_func
(
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
)
{
Item
**
arg
,
**
arg_end
;
for
(
arg
=
args
,
arg_end
=
args
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
Item
**
arg
,
**
arg_end
;
for
(
arg
=
args
,
arg_end
=
args
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
{
if
((
*
arg
)
->
with_sum_func
&&
(
*
arg
)
->
type
()
!=
SUM_FUNC_ITEM
)
(
*
arg
)
->
split_sum_func
(
ref_pointer_array
,
fields
);
...
...
@@ -167,7 +167,7 @@ void Item_func::split_sum_func(Item **ref_pointer_array, List<Item> &fields)
uint
el
=
fields
.
elements
;
fields
.
push_front
(
*
arg
);
ref_pointer_array
[
el
]
=
*
arg
;
*
arg
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
(
*
arg
)
->
name
);
*
arg
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
(
*
arg
)
->
name
);
}
}
}
...
...
sql/item_row.cc
View file @
a662f7e1
...
...
@@ -48,26 +48,45 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref)
{
null_value
=
0
;
maybe_null
=
0
;
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
Item
**
arg
,
**
arg_end
;
for
(
arg
=
items
,
arg_end
=
items
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
{
if
(
items
[
i
]
->
fix_fields
(
thd
,
tabl
,
items
+
i
))
if
(
(
*
arg
)
->
fix_fields
(
thd
,
tabl
,
arg
))
return
1
;
used_tables_cache
|=
items
[
i
]
->
used_tables
();
if
(
const_item_cache
&=
items
[
i
]
->
const_item
()
&&
!
with_null
)
used_tables_cache
|=
(
*
arg
)
->
used_tables
();
if
(
const_item_cache
&=
(
*
arg
)
->
const_item
()
&&
!
with_null
)
{
if
(
items
[
i
]
->
cols
()
>
1
)
with_null
|=
items
[
i
]
->
null_inside
();
if
(
(
*
arg
)
->
cols
()
>
1
)
with_null
|=
(
*
arg
)
->
null_inside
();
else
{
items
[
i
]
->
val_int
();
with_null
|=
items
[
i
]
->
null_value
;
(
*
arg
)
->
val_int
();
with_null
|=
(
*
arg
)
->
null_value
;
}
}
maybe_null
|=
items
[
i
]
->
maybe_null
;
maybe_null
|=
(
*
arg
)
->
maybe_null
;
with_sum_func
=
with_sum_func
||
(
*
arg
)
->
with_sum_func
;
}
return
0
;
}
void
Item_row
::
split_sum_func
(
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
)
{
Item
**
arg
,
**
arg_end
;
for
(
arg
=
items
,
arg_end
=
items
+
arg_count
;
arg
!=
arg_end
;
arg
++
)
{
if
((
*
arg
)
->
with_sum_func
&&
(
*
arg
)
->
type
()
!=
SUM_FUNC_ITEM
)
(
*
arg
)
->
split_sum_func
(
ref_pointer_array
,
fields
);
else
if
((
*
arg
)
->
used_tables
()
||
(
*
arg
)
->
type
()
==
SUM_FUNC_ITEM
)
{
uint
el
=
fields
.
elements
;
fields
.
push_front
(
*
arg
);
ref_pointer_array
[
el
]
=
*
arg
;
*
arg
=
new
Item_ref
(
ref_pointer_array
+
el
,
0
,
(
*
arg
)
->
name
);
}
}
}
void
Item_row
::
update_used_tables
()
{
used_tables_cache
=
0
;
...
...
sql/item_row.h
View file @
a662f7e1
...
...
@@ -63,6 +63,7 @@ public:
return
0
;
};
bool
fix_fields
(
THD
*
thd
,
TABLE_LIST
*
tables
,
Item
**
ref
);
void
split_sum_func
(
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
);
table_map
used_tables
()
const
{
return
used_tables_cache
;
};
bool
const_item
()
const
{
return
const_item_cache
;
};
enum
Item_result
result_type
()
const
{
return
ROW_RESULT
;
}
...
...
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