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
12da27da
Commit
12da27da
authored
Jul 16, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8472 BINARY, VARBINARY and BLOB return different warnings on CAST to DECIMAL
parent
94bc5065
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
32 deletions
+93
-32
mysql-test/r/type_binary.result
mysql-test/r/type_binary.result
+34
-0
mysql-test/suite/funcs_1/r/innodb_func_view.result
mysql-test/suite/funcs_1/r/innodb_func_view.result
+4
-4
mysql-test/suite/funcs_1/r/memory_func_view.result
mysql-test/suite/funcs_1/r/memory_func_view.result
+4
-4
mysql-test/suite/funcs_1/r/myisam_func_view.result
mysql-test/suite/funcs_1/r/myisam_func_view.result
+4
-4
mysql-test/t/type_binary.test
mysql-test/t/type_binary.test
+26
-0
sql/field.cc
sql/field.cc
+18
-20
sql/field.h
sql/field.h
+3
-0
No files found.
mysql-test/r/type_binary.result
View file @
12da27da
...
@@ -146,3 +146,37 @@ hex(f2) hex(f3)
...
@@ -146,3 +146,37 @@ hex(f2) hex(f3)
0000
0000
drop table t1;
drop table t1;
End of 5.0 tests
End of 5.0 tests
#
# Start of 10.0 tests
#
#
# MDEV-8472 BINARY, VARBINARY and BLOB return different warnings on CAST to DECIMAL
#
SET NAMES utf8;
CREATE TABLE t1 (a BINARY(30));
INSERT INTO t1 VALUES ('1äÖüß@µ*$');
SELECT CAST(a AS DECIMAL) FROM t1;
CAST(a AS DECIMAL)
1
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
DROP TABLE t1;
CREATE TABLE t1 (a VARBINARY(30));
INSERT INTO t1 VALUES ('1äÖüß@µ*$');
SELECT CAST(a AS DECIMAL) FROM t1;
CAST(a AS DECIMAL)
1
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$'
DROP TABLE t1;
CREATE TABLE t1 (a BLOB);
INSERT INTO t1 VALUES ('1äÖüß@µ*$');
SELECT CAST(a AS DECIMAL) FROM t1;
CAST(a AS DECIMAL)
1
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: '1\xC3\xA4\xC3\x96\xC3\xBC\xC3\x9F@\xC2\xB5*$'
DROP TABLE t1;
#
# End of 10.0 tests
#
mysql-test/suite/funcs_1/r/innodb_func_view.result
View file @
12da27da
No preview for this file type
mysql-test/suite/funcs_1/r/memory_func_view.result
View file @
12da27da
No preview for this file type
mysql-test/suite/funcs_1/r/myisam_func_view.result
View file @
12da27da
No preview for this file type
mysql-test/t/type_binary.test
View file @
12da27da
...
@@ -100,3 +100,29 @@ select hex(f2), hex(f3) from t1;
...
@@ -100,3 +100,29 @@ select hex(f2), hex(f3) from t1;
drop
table
t1
;
drop
table
t1
;
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
--
echo
#
--
echo
# Start of 10.0 tests
--
echo
#
--
echo
#
--
echo
# MDEV-8472 BINARY, VARBINARY and BLOB return different warnings on CAST to DECIMAL
--
echo
#
SET
NAMES
utf8
;
CREATE
TABLE
t1
(
a
BINARY
(
30
));
INSERT
INTO
t1
VALUES
(
'1äÖüß@µ*$'
);
SELECT
CAST
(
a
AS
DECIMAL
)
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
VARBINARY
(
30
));
INSERT
INTO
t1
VALUES
(
'1äÖüß@µ*$'
);
SELECT
CAST
(
a
AS
DECIMAL
)
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
BLOB
);
INSERT
INTO
t1
VALUES
(
'1äÖüß@µ*$'
);
SELECT
CAST
(
a
AS
DECIMAL
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.0 tests
--
echo
#
sql/field.cc
View file @
12da27da
...
@@ -6500,24 +6500,32 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
...
@@ -6500,24 +6500,32 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
}
}
my_decimal
*
Field_string
::
val_decimal
(
my_decimal
*
decimal_value
)
my_decimal
*
Field_longstr
::
val_decimal_from_str
(
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
my_decimal
*
decimal_value
)
{
{
ASSERT_COLUMN_MARKED_FOR_READ
;
int
err
=
str2my_decimal
(
E_DEC_FATAL_ERROR
,
str
,
length
,
cs
,
decimal_value
);
int
err
=
str2my_decimal
(
E_DEC_FATAL_ERROR
,
(
char
*
)
ptr
,
field_length
,
charset
(),
decimal_value
);
if
(
!
get_thd
()
->
no_errors
&&
err
)
if
(
!
get_thd
()
->
no_errors
&&
err
)
{
{
ErrConvString
errmsg
(
(
char
*
)
ptr
,
field_length
,
charset
()
);
ErrConvString
errmsg
(
str
,
length
,
cs
);
push_warning_printf
(
current_thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
push_warning_printf
(
current_thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
ER_TRUNCATED_WRONG_VALUE
,
ER_TRUNCATED_WRONG_VALUE
,
ER
(
ER_TRUNCATED_WRONG_VALUE
),
ER
(
ER_TRUNCATED_WRONG_VALUE
),
"DECIMAL"
,
errmsg
.
ptr
());
"DECIMAL"
,
errmsg
.
ptr
());
}
}
return
decimal_value
;
return
decimal_value
;
}
}
my_decimal
*
Field_string
::
val_decimal
(
my_decimal
*
decimal_value
)
{
ASSERT_COLUMN_MARKED_FOR_READ
;
return
val_decimal_from_str
((
const
char
*
)
ptr
,
field_length
,
Field_string
::
charset
(),
decimal_value
);
}
struct
Check_field_param
{
struct
Check_field_param
{
Field
*
field
;
Field
*
field
;
};
};
...
@@ -6942,18 +6950,9 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)),
...
@@ -6942,18 +6950,9 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)),
my_decimal
*
Field_varstring
::
val_decimal
(
my_decimal
*
decimal_value
)
my_decimal
*
Field_varstring
::
val_decimal
(
my_decimal
*
decimal_value
)
{
{
ASSERT_COLUMN_MARKED_FOR_READ
;
ASSERT_COLUMN_MARKED_FOR_READ
;
CHARSET_INFO
*
cs
=
charset
();
uint
length
=
length_bytes
==
1
?
(
uint
)
*
ptr
:
uint2korr
(
ptr
);
uint
length
=
length_bytes
==
1
?
(
uint
)
*
ptr
:
uint2korr
(
ptr
);
int
error
=
str2my_decimal
(
E_DEC_FATAL_ERROR
,
(
char
*
)
ptr
+
length_bytes
,
length
,
return
val_decimal_from_str
((
const
char
*
)
ptr
+
length_bytes
,
length
,
cs
,
decimal_value
);
Field_varstring
::
charset
(),
decimal_value
);
if
(
!
get_thd
()
->
no_errors
&&
error
)
{
push_numerical_conversion_warning
(
current_thd
,
(
char
*
)
ptr
+
length_bytes
,
length
,
cs
,
"DECIMAL"
,
ER_TRUNCATED_WRONG_VALUE
);
}
return
decimal_value
;
}
}
...
@@ -7474,9 +7473,8 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value)
...
@@ -7474,9 +7473,8 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value)
else
else
length
=
get_length
(
ptr
);
length
=
get_length
(
ptr
);
str2my_decimal
(
E_DEC_FATAL_ERROR
,
blob
,
length
,
charset
(),
return
val_decimal_from_str
(
blob
,
length
,
decimal_value
);
Field_blob
::
charset
(),
decimal_value
);
return
decimal_value
;
}
}
...
...
sql/field.h
View file @
12da27da
...
@@ -1161,6 +1161,9 @@ protected:
...
@@ -1161,6 +1161,9 @@ protected:
const
char
*
cannot_convert_error_pos
,
const
char
*
cannot_convert_error_pos
,
const
char
*
end
,
const
char
*
end
,
CHARSET_INFO
*
cs
);
CHARSET_INFO
*
cs
);
my_decimal
*
val_decimal_from_str
(
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
,
my_decimal
*
decimal_value
);
public:
public:
Field_longstr
(
uchar
*
ptr_arg
,
uint32
len_arg
,
uchar
*
null_ptr_arg
,
Field_longstr
(
uchar
*
ptr_arg
,
uint32
len_arg
,
uchar
*
null_ptr_arg
,
uchar
null_bit_arg
,
utype
unireg_check_arg
,
uchar
null_bit_arg
,
utype
unireg_check_arg
,
...
...
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