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
8c8bee0a
Commit
8c8bee0a
authored
Apr 30, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-10307 CAST(11068046444225730969 AS SIGNED) does not return a warning
parent
447b8ba1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
1 deletion
+44
-1
mysql-test/main/cast.result
mysql-test/main/cast.result
+19
-0
mysql-test/main/cast.test
mysql-test/main/cast.test
+6
-0
mysql-test/main/default.result
mysql-test/main/default.result
+2
-0
sql/item.cc
sql/item.cc
+9
-0
sql/item.h
sql/item.h
+7
-0
sql/sql_type.cc
sql/sql_type.cc
+1
-1
No files found.
mysql-test/main/cast.result
View file @
8c8bee0a
No preview for this file type
mysql-test/main/cast.test
View file @
8c8bee0a
...
@@ -724,3 +724,9 @@ $$
...
@@ -724,3 +724,9 @@ $$
DELIMITER
;
$$
DELIMITER
;
$$
SET
sql_mode
=
DEFAULT
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
# MDEV-10307 CAST(11068046444225730969 AS SIGNED) does not return a warning
--
echo
#
SELECT
CAST
(
11068046444225730969
AS
SIGNED
);
mysql-test/main/default.result
View file @
8c8bee0a
...
@@ -2217,6 +2217,8 @@ t1 CREATE TABLE `t1` (
...
@@ -2217,6 +2217,8 @@ t1 CREATE TABLE `t1` (
`b` bigint(20) DEFAULT (cast(`a` as signed))
`b` bigint(20) DEFAULT (cast(`a` as signed))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (a) VALUES (0xFFFFFFFFFFFFFFFF);
INSERT INTO t1 (a) VALUES (0xFFFFFFFFFFFFFFFF);
Warnings:
Note 1105 Cast to signed converted positive out-of-range integer to it's negative complement
SELECT * FROM t1;
SELECT * FROM t1;
a b
a b
18446744073709551615 -1
18446744073709551615 -1
...
...
sql/item.cc
View file @
8c8bee0a
...
@@ -333,6 +333,15 @@ longlong Item::val_int_unsigned_typecast_from_int()
...
@@ -333,6 +333,15 @@ longlong Item::val_int_unsigned_typecast_from_int()
}
}
longlong
Item
::
val_int_signed_typecast_from_int
()
{
longlong
value
=
val_int
();
if
(
!
null_value
&&
unsigned_flag
&&
value
<
0
)
push_note_converted_to_negative_complement
(
current_thd
);
return
value
;
}
String
*
Item
::
val_string_from_date
(
String
*
str
)
String
*
Item
::
val_string_from_date
(
String
*
str
)
{
{
MYSQL_TIME
ltime
;
MYSQL_TIME
ltime
;
...
...
sql/item.h
View file @
8c8bee0a
...
@@ -1057,6 +1057,13 @@ class Item: public Value_source,
...
@@ -1057,6 +1057,13 @@ class Item: public Value_source,
longlong
val_int_unsigned_typecast_from_decimal
();
longlong
val_int_unsigned_typecast_from_decimal
();
longlong
val_int_unsigned_typecast_from_int
();
longlong
val_int_unsigned_typecast_from_int
();
longlong
val_int_unsigned_typecast_from_str
();
longlong
val_int_unsigned_typecast_from_str
();
/**
Get a value for CAST(x AS UNSIGNED).
Huge positive unsigned values are converted to negative complements.
*/
longlong
val_int_signed_typecast_from_int
();
/*
/*
This is just a shortcut to avoid the cast. You should still use
This is just a shortcut to avoid the cast. You should still use
unsigned_flag to check the sign of the item.
unsigned_flag to check the sign of the item.
...
...
sql/sql_type.cc
View file @
8c8bee0a
...
@@ -3380,7 +3380,7 @@ longlong Type_handler_real_result::
...
@@ -3380,7 +3380,7 @@ longlong Type_handler_real_result::
longlong
Type_handler_int_result
::
longlong
Type_handler_int_result
::
Item_val_int_signed_typecast
(
Item
*
item
)
const
Item_val_int_signed_typecast
(
Item
*
item
)
const
{
{
return
item
->
val_int
();
return
item
->
val_int
_signed_typecast_from_int
();
}
}
longlong
Type_handler_decimal_result
::
longlong
Type_handler_decimal_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