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
a64e56ac
Commit
a64e56ac
authored
Dec 16, 2009
by
Konstantin Osipov
Browse files
Options
Browse Files
Download
Plain Diff
Merge next-mr -> next-4284
parents
e931ef41
425157ee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
4 deletions
+58
-4
mysql-test/r/func_math.result
mysql-test/r/func_math.result
+12
-2
mysql-test/r/type_varchar.result
mysql-test/r/type_varchar.result
+3
-2
mysql-test/t/func_math.test
mysql-test/t/func_math.test
+11
-0
sql/item_func.cc
sql/item_func.cc
+32
-0
No files found.
mysql-test/r/func_math.result
View file @
a64e56ac
...
...
@@ -383,8 +383,10 @@ SELECT b DIV 900 y FROM t1 GROUP BY y;
y
0
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'str1'
Warning 1292 Truncated incorrect INTEGER value: 'str2'
Warning 1366 Incorrect decimal value: '' for column '' at row -1
Warning 1292 Truncated incorrect DECIMAL value: 'str1'
Warning 1366 Incorrect decimal value: '' for column '' at row -1
Warning 1292 Truncated incorrect DECIMAL value: 'str2'
SELECT c DIV 900 y FROM t1 GROUP BY y;
y
0
...
...
@@ -485,4 +487,12 @@ RAND(i)
0.155220427694936
DROP TABLE t1;
#
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
ERROR 22003: Out of range value for column 'x' at row 1
select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
ERROR 22003: Out of range value for column 'x' at row 1
SHOW WARNINGS;
Level Code Message
Warning 1292 Truncated incorrect DECIMAL value: ''
Error 1264 Out of range value for column 'x' at row 1
End of 5.1 tests
mysql-test/r/type_varchar.result
View file @
a64e56ac
...
...
@@ -475,8 +475,9 @@ a (a DIV 2)
60 30
t 0
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '1a'
Warning 1292 Truncated incorrect INTEGER value: 't '
Warning 1292 Truncated incorrect DECIMAL value: '1a'
Warning 1366 Incorrect decimal value: '' for column '' at row -1
Warning 1292 Truncated incorrect DECIMAL value: 't '
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
a CAST(a AS SIGNED)
10 10
...
...
mysql-test/t/func_math.test
View file @
a64e56ac
...
...
@@ -309,4 +309,15 @@ DROP TABLE t1;
--
echo
#
#
# Bug #8457: Precision math:
# DIV returns incorrect result with large decimal value
# Bug #46606:Casting error for large numbers in 5.4 when 'div' is used
--
error
ER_WARN_DATA_OUT_OF_RANGE
select
123456789012345678901234567890.123456789012345678901234567890
div
1
as
x
;
--
error
ER_WARN_DATA_OUT_OF_RANGE
select
"123456789012345678901234567890.123456789012345678901234567890"
div
1
as
x
;
SHOW
WARNINGS
;
--
echo
End
of
5.1
tests
sql/item_func.cc
View file @
a64e56ac
...
...
@@ -1384,6 +1384,38 @@ void Item_func_div::fix_length_and_dec()
longlong
Item_func_int_div
::
val_int
()
{
DBUG_ASSERT
(
fixed
==
1
);
/*
Perform division using DECIMAL math if either of the operands has a
non-integer type
*/
if
(
args
[
0
]
->
result_type
()
!=
INT_RESULT
||
args
[
1
]
->
result_type
()
!=
INT_RESULT
)
{
my_decimal
value0
,
value1
,
tmp
;
my_decimal
*
val0
,
*
val1
;
longlong
res
;
int
err
;
val0
=
args
[
0
]
->
val_decimal
(
&
value0
);
val1
=
args
[
1
]
->
val_decimal
(
&
value1
);
if
((
null_value
=
(
args
[
0
]
->
null_value
||
args
[
1
]
->
null_value
)))
return
0
;
if
((
err
=
my_decimal_div
(
E_DEC_FATAL_ERROR
&
~
E_DEC_DIV_ZERO
,
&
tmp
,
val0
,
val1
,
0
))
>
3
)
{
if
(
err
==
E_DEC_DIV_ZERO
)
signal_divide_by_null
();
return
0
;
}
if
(
my_decimal2int
(
E_DEC_FATAL_ERROR
,
&
tmp
,
unsigned_flag
,
&
res
)
&
E_DEC_OVERFLOW
)
my_error
(
ER_WARN_DATA_OUT_OF_RANGE
,
MYF
(
0
),
name
,
1
);
return
res
;
}
longlong
value
=
args
[
0
]
->
val_int
();
longlong
val2
=
args
[
1
]
->
val_int
();
if
((
null_value
=
(
args
[
0
]
->
null_value
||
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