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
a147eea6
Commit
a147eea6
authored
Apr 27, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12607 Hybrid functions create wrong VARBINARY length when mixing character and binary data
parent
93469395
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
1 deletion
+45
-1
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+16
-0
mysql-test/t/ctype_utf8.test
mysql-test/t/ctype_utf8.test
+12
-0
sql/item_func.cc
sql/item_func.cc
+16
-1
sql/item_func.h
sql/item_func.h
+1
-0
No files found.
mysql-test/r/ctype_utf8.result
View file @
a147eea6
...
@@ -11184,5 +11184,21 @@ SET NAMES utf8;
...
@@ -11184,5 +11184,21 @@ SET NAMES utf8;
CREATE TABLE t1 (a SET('a,bü'));
CREATE TABLE t1 (a SET('a,bü'));
ERROR 22007: Illegal set 'a,bü' value found during parsing
ERROR 22007: Illegal set 'a,bü' value found during parsing
#
#
# MDEV-12607 Hybrid functions create wrong VARBINARY length when mixing character and binary data
#
SET sql_mode='';
SET NAMES utf8;
CREATE OR REPLACE TABLE t1 AS SELECT COALESCE('ßa',_binary 'a');
SELECT * FROM t1;
COALESCE('ßa',_binary 'a')
ßa
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`COALESCE('ßa',_binary 'a')` varbinary(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# End of 10.3 tests
# End of 10.3 tests
#
#
mysql-test/t/ctype_utf8.test
View file @
a147eea6
...
@@ -2109,6 +2109,18 @@ SET NAMES utf8;
...
@@ -2109,6 +2109,18 @@ SET NAMES utf8;
--
error
ER_ILLEGAL_VALUE_FOR_TYPE
--
error
ER_ILLEGAL_VALUE_FOR_TYPE
CREATE
TABLE
t1
(
a
SET
(
'a,bü'
));
CREATE
TABLE
t1
(
a
SET
(
'a,bü'
));
--
echo
#
--
echo
# MDEV-12607 Hybrid functions create wrong VARBINARY length when mixing character and binary data
--
echo
#
SET
sql_mode
=
''
;
SET
NAMES
utf8
;
CREATE
OR
REPLACE
TABLE
t1
AS
SELECT
COALESCE
(
'ßa'
,
_binary
'a'
);
SELECT
*
FROM
t1
;
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
#
--
echo
# End of 10.3 tests
--
echo
# End of 10.3 tests
--
echo
#
--
echo
#
sql/item_func.cc
View file @
a147eea6
...
@@ -632,6 +632,18 @@ void Item_func::count_only_length(Item **item, uint nitems)
...
@@ -632,6 +632,18 @@ void Item_func::count_only_length(Item **item, uint nitems)
}
}
void
Item_func
::
count_octet_length
(
Item
**
item
,
uint
nitems
)
{
max_length
=
0
;
unsigned_flag
=
0
;
for
(
uint
i
=
0
;
i
<
nitems
;
i
++
)
{
set_if_bigger
(
max_length
,
item
[
i
]
->
max_length
);
set_if_bigger
(
unsigned_flag
,
item
[
i
]
->
unsigned_flag
);
}
}
/**
/**
Set max_length/decimals of function if function is floating point and
Set max_length/decimals of function if function is floating point and
result length/precision depends on argument ones.
result length/precision depends on argument ones.
...
@@ -681,7 +693,10 @@ bool Item_func::count_string_length(Item **items, uint nitems)
...
@@ -681,7 +693,10 @@ bool Item_func::count_string_length(Item **items, uint nitems)
DBUG_ASSERT
(
!
is_temporal_type
(
field_type
()));
DBUG_ASSERT
(
!
is_temporal_type
(
field_type
()));
if
(
agg_arg_charsets_for_string_result
(
collation
,
items
,
nitems
,
1
))
if
(
agg_arg_charsets_for_string_result
(
collation
,
items
,
nitems
,
1
))
return
true
;
return
true
;
count_only_length
(
items
,
nitems
);
if
(
collation
.
collation
==
&
my_charset_bin
)
count_octet_length
(
items
,
nitems
);
else
count_only_length
(
items
,
nitems
);
decimals
=
max_length
?
NOT_FIXED_DEC
:
0
;
decimals
=
max_length
?
NOT_FIXED_DEC
:
0
;
return
false
;
return
false
;
}
}
...
...
sql/item_func.h
View file @
a147eea6
...
@@ -43,6 +43,7 @@ class Item_func :public Item_func_or_sum
...
@@ -43,6 +43,7 @@ class Item_func :public Item_func_or_sum
String
*
val_str_from_val_str_ascii
(
String
*
str
,
String
*
str2
);
String
*
val_str_from_val_str_ascii
(
String
*
str
,
String
*
str2
);
void
count_only_length
(
Item
**
item
,
uint
nitems
);
void
count_only_length
(
Item
**
item
,
uint
nitems
);
void
count_octet_length
(
Item
**
item
,
uint
nitems
);
void
count_real_length
(
Item
**
item
,
uint
nitems
);
void
count_real_length
(
Item
**
item
,
uint
nitems
);
void
count_decimal_length
(
Item
**
item
,
uint
nitems
);
void
count_decimal_length
(
Item
**
item
,
uint
nitems
);
bool
count_string_length
(
Item
**
item
,
uint
nitems
);
bool
count_string_length
(
Item
**
item
,
uint
nitems
);
...
...
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