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
7777f759
Commit
7777f759
authored
Sep 07, 2004
by
igor@rurik.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
func_group.test, func_group.result:
Added test case for bug #5406. opt_sum.cc: Fixed bug #5406.
parent
c26246b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
10 deletions
+33
-10
mysql-test/r/func_group.result
mysql-test/r/func_group.result
+9
-0
mysql-test/t/func_group.test
mysql-test/t/func_group.test
+16
-0
sql/opt_sum.cc
sql/opt_sum.cc
+8
-10
No files found.
mysql-test/r/func_group.result
View file @
7777f759
...
@@ -684,3 +684,12 @@ max(a)
...
@@ -684,3 +684,12 @@ max(a)
2
2
deallocate prepare stmt1;
deallocate prepare stmt1;
drop table t1;
drop table t1;
CREATE TABLE t1 (a int primary key);
INSERT INTO t1 VALUES (1),(2),(3),(4);
SELECT MAX(a) FROM t1 WHERE a > 5;
MAX(a)
NULL
SELECT MIN(a) FROM t1 WHERE a < 0;
MIN(a)
NULL
DROP TABLE t1;
mysql-test/t/func_group.test
View file @
7777f759
...
@@ -418,3 +418,19 @@ execute stmt1;
...
@@ -418,3 +418,19 @@ execute stmt1;
execute
stmt1
;
execute
stmt1
;
deallocate
prepare
stmt1
;
deallocate
prepare
stmt1
;
drop
table
t1
;
drop
table
t1
;
#
# Bug #5406 min/max optimization for empty set
#
CREATE
TABLE
t1
(
a
int
primary
key
);
INSERT
INTO
t1
VALUES
(
1
),(
2
),(
3
),(
4
);
SELECT
MAX
(
a
)
FROM
t1
WHERE
a
>
5
;
SELECT
MIN
(
a
)
FROM
t1
WHERE
a
<
0
;
DROP
TABLE
t1
;
sql/opt_sum.cc
View file @
7777f759
...
@@ -186,16 +186,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
...
@@ -186,16 +186,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if
(
!
ref
.
key_length
)
if
(
!
ref
.
key_length
)
error
=
table
->
file
->
index_first
(
table
->
record
[
0
]);
error
=
table
->
file
->
index_first
(
table
->
record
[
0
]);
else
else
{
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
key_buff
,
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
key_buff
,
ref
.
key_length
,
ref
.
key_length
,
range_fl
&
NEAR_MIN
?
range_fl
&
NEAR_MIN
?
HA_READ_AFTER_KEY
:
HA_READ_AFTER_KEY
:
HA_READ_KEY_OR_NEXT
);
HA_READ_KEY_OR_NEXT
);
if
(
!
error
&&
reckey_in_range
(
0
,
&
ref
,
item_field
->
field
,
if
((
!
error
||
error
==
HA_ERR_KEY_NOT_FOUND
)
&&
conds
,
range_fl
,
prefix_len
))
reckey_in_range
(
0
,
&
ref
,
item_field
->
field
,
error
=
HA_ERR_KEY_NOT_FOUND
;
conds
,
range_fl
,
prefix_len
))
}
error
=
HA_ERR_KEY_NOT_FOUND
;
if
(
table
->
key_read
)
if
(
table
->
key_read
)
{
{
table
->
key_read
=
0
;
table
->
key_read
=
0
;
...
@@ -260,16 +259,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
...
@@ -260,16 +259,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if
(
!
ref
.
key_length
)
if
(
!
ref
.
key_length
)
error
=
table
->
file
->
index_last
(
table
->
record
[
0
]);
error
=
table
->
file
->
index_last
(
table
->
record
[
0
]);
else
else
{
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
key_buff
,
error
=
table
->
file
->
index_read
(
table
->
record
[
0
],
key_buff
,
ref
.
key_length
,
ref
.
key_length
,
range_fl
&
NEAR_MAX
?
range_fl
&
NEAR_MAX
?
HA_READ_BEFORE_KEY
:
HA_READ_BEFORE_KEY
:
HA_READ_PREFIX_LAST_OR_PREV
);
HA_READ_PREFIX_LAST_OR_PREV
);
if
(
!
error
&&
reckey_in_range
(
1
,
&
ref
,
item_field
->
field
,
if
((
!
error
||
error
==
HA_ERR_KEY_NOT_FOUND
)
&&
conds
,
range_fl
,
prefix_len
))
reckey_in_range
(
1
,
&
ref
,
item_field
->
field
,
error
=
HA_ERR_KEY_NOT_FOUND
;
conds
,
range_fl
,
prefix_len
))
}
error
=
HA_ERR_KEY_NOT_FOUND
;
if
(
table
->
key_read
)
if
(
table
->
key_read
)
{
{
table
->
key_read
=
0
;
table
->
key_read
=
0
;
...
...
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