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
f8935260
Commit
f8935260
authored
Jun 02, 2005
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug #9669 Ordering on IF function with FROM_UNIXTIME function fails
Integer overflow results in wrong field sortlength.
parent
95484f79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
1 deletion
+39
-1
mysql-test/r/func_if.result
mysql-test/r/func_if.result
+17
-0
mysql-test/t/func_if.test
mysql-test/t/func_if.test
+14
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+8
-1
No files found.
mysql-test/r/func_if.result
View file @
f8935260
...
...
@@ -91,3 +91,20 @@ drop table t1;
SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL;
NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL
1 0
CREATE TABLE `t1` (
`id` int(11) NOT NULL ,
`date` int(10) default NULL,
`text` varchar(32) NOT NULL
);
INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3');
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC;
id date_ord text
1 05-03-2005 Day 1
2 16-03-2005 Day 2
3 28-03-2005 Day 3
SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC;
id date_ord text
3 28-03-2005 Day 3
2 16-03-2005 Day 2
1 05-03-2005 Day 1
DROP TABLE t1;
mysql-test/t/func_if.test
View file @
f8935260
...
...
@@ -61,3 +61,17 @@ drop table t1;
# Bug #5595 NULLIF() IS NULL returns false if NULLIF() returns NULL
#
SELECT
NULLIF
(
5
,
5
)
IS
NULL
,
NULLIF
(
5
,
5
)
IS
NOT
NULL
;
#
# Bug #9669 Ordering on IF function with FROM_UNIXTIME function fails
#
CREATE
TABLE
`t1`
(
`id`
int
(
11
)
NOT
NULL
,
`date`
int
(
10
)
default
NULL
,
`text`
varchar
(
32
)
NOT
NULL
);
INSERT
INTO
t1
VALUES
(
1
,
1110000000
,
'Day 1'
),(
2
,
1111000000
,
'Day 2'
),(
3
,
1112000000
,
'Day 3'
);
SELECT
id
,
IF
(
date
IS
NULL
,
'-'
,
FROM_UNIXTIME
(
date
,
'%d-%m-%Y'
))
AS
date_ord
,
text
FROM
t1
ORDER
BY
date_ord
ASC
;
SELECT
id
,
IF
(
date
IS
NULL
,
'-'
,
FROM_UNIXTIME
(
date
,
'%d-%m-%Y'
))
AS
date_ord
,
text
FROM
t1
ORDER
BY
date_ord
DESC
;
DROP
TABLE
t1
;
sql/item_cmpfunc.cc
View file @
f8935260
...
...
@@ -1227,9 +1227,16 @@ Item_func_if::fix_length_and_dec()
{
maybe_null
=
args
[
1
]
->
maybe_null
||
args
[
2
]
->
maybe_null
;
decimals
=
max
(
args
[
1
]
->
decimals
,
args
[
2
]
->
decimals
);
max_length
=
(
max
(
args
[
1
]
->
max_length
-
args
[
1
]
->
decimals
,
if
(
decimals
==
NOT_FIXED_DEC
)
{
max_length
=
max
(
args
[
1
]
->
max_length
,
args
[
2
]
->
max_length
);
}
else
{
max_length
=
(
max
(
args
[
1
]
->
max_length
-
args
[
1
]
->
decimals
,
args
[
2
]
->
max_length
-
args
[
2
]
->
decimals
)
+
decimals
);
}
enum
Item_result
arg1_type
=
args
[
1
]
->
result_type
();
enum
Item_result
arg2_type
=
args
[
2
]
->
result_type
();
bool
null1
=
args
[
1
]
->
const_item
()
&&
args
[
1
]
->
null_value
;
...
...
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