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
2913f615
Commit
2913f615
authored
Nov 13, 2017
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8949: COLUMN_CREATE unicode name breakage
Use utf-mb4 if it is possible.
parent
c0e10f37
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
16 deletions
+70
-16
include/ma_dyncol.h
include/ma_dyncol.h
+6
-0
mysql-test/r/ctype_utf8mb4.result
mysql-test/r/ctype_utf8mb4.result
+27
-0
mysql-test/t/ctype_utf8mb4.test
mysql-test/t/ctype_utf8mb4.test
+20
-0
mysys/ma_dyncol.c
mysys/ma_dyncol.c
+1
-2
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+3
-3
sql/item_strfunc.cc
sql/item_strfunc.cc
+9
-8
sql/item_strfunc.h
sql/item_strfunc.h
+4
-3
No files found.
include/ma_dyncol.h
View file @
2913f615
...
...
@@ -63,6 +63,12 @@ typedef struct st_mysql_lex_string LEX_STRING;
/* NO and OK is the same used just to show semantics */
#define ER_DYNCOL_NO ER_DYNCOL_OK
#ifdef HAVE_CHARSET_utf8mb4
#define DYNCOL_UTF (&my_charset_utf8mb4_general_ci)
#else
#define DYNCOL_UTF (&my_charset_utf8_general_ci)
#endif
enum
enum_dyncol_func_result
{
ER_DYNCOL_OK
=
0
,
...
...
mysql-test/r/ctype_utf8mb4.result
View file @
2913f615
...
...
@@ -3379,5 +3379,32 @@ F09F988E78
78F09F988E78
DROP TABLE t1;
#
# MDEV-8949: COLUMN_CREATE unicode name breakage
#
SET NAMES utf8mb4;
SELECT COLUMN_JSON(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1));
COLUMN_JSON(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1))
{"😎":1}
SELECT COLUMN_LIST(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1));
COLUMN_LIST(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1))
`😎`
SELECT COLUMN_GET(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1), _utf8mb4 0xF09F988E
as int);
COLUMN_GET(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1), _utf8mb4 0xF09F988E
as int)
1
CREATE TABLE t1 AS SELECT
COLUMN_LIST(COLUMN_CREATE('a',1)),
COLUMN_JSON(COLUMN_CREATE('b',1));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`COLUMN_LIST(COLUMN_CREATE('a',1))` longtext CHARACTER SET utf8mb4,
`COLUMN_JSON(COLUMN_CREATE('b',1))` longtext CHARACTER SET utf8mb4
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET NAMES default;
# End of 10.0 tests
#
# End of tests
#
mysql-test/t/ctype_utf8mb4.test
View file @
2913f615
...
...
@@ -1876,6 +1876,26 @@ LOAD DATA INFILE '../../std_data/loaddata/mdev-11343.txt' INTO TABLE t1 CHARACTE
SELECT
HEX
(
a
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-8949: COLUMN_CREATE unicode name breakage
--
echo
#
SET
NAMES
utf8mb4
;
SELECT
COLUMN_JSON
(
COLUMN_CREATE
(
_utf8mb4
0xF09F988E
,
1
));
SELECT
COLUMN_LIST
(
COLUMN_CREATE
(
_utf8mb4
0xF09F988E
,
1
));
SELECT
COLUMN_GET
(
COLUMN_CREATE
(
_utf8mb4
0xF09F988E
,
1
),
_utf8mb4
0xF09F988E
as
int
);
CREATE
TABLE
t1
AS
SELECT
COLUMN_LIST
(
COLUMN_CREATE
(
'a'
,
1
)),
COLUMN_JSON
(
COLUMN_CREATE
(
'b'
,
1
));
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
SET
NAMES
default
;
--
echo
# End of 10.0 tests
--
echo
#
--
echo
# End of tests
--
echo
#
mysys/ma_dyncol.c
View file @
2913f615
...
...
@@ -4184,8 +4184,7 @@ mariadb_dyncol_json_internal(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json,
}
else
{
if
((
rc
=
mariadb_dyncol_val_str
(
json
,
&
val
,
&
my_charset_utf8_general_ci
,
'"'
))
<
0
)
if
((
rc
=
mariadb_dyncol_val_str
(
json
,
&
val
,
DYNCOL_UTF
,
'"'
))
<
0
)
goto
err
;
}
}
...
...
sql/item_cmpfunc.cc
View file @
2913f615
...
...
@@ -6642,7 +6642,7 @@ longlong Item_func_dyncol_exists::val_int()
null_value
=
1
;
return
1
;
}
if
(
my_charset_same
(
nm
->
charset
(),
&
my_charset_utf8_general_ci
))
if
(
my_charset_same
(
nm
->
charset
(),
DYNCOL_UTF
))
{
buf
.
str
=
(
char
*
)
nm
->
ptr
();
buf
.
length
=
nm
->
length
();
...
...
@@ -6652,11 +6652,11 @@ longlong Item_func_dyncol_exists::val_int()
uint
strlen
;
uint
dummy_errors
;
buf
.
str
=
(
char
*
)
sql_alloc
((
strlen
=
nm
->
length
()
*
my_charset_utf8_general_ci
.
mbmaxlen
+
1
));
DYNCOL_UTF
->
mbmaxlen
+
1
));
if
(
buf
.
str
)
{
buf
.
length
=
copy_and_convert
(
buf
.
str
,
strlen
,
&
my_charset_utf8_general_ci
,
copy_and_convert
(
buf
.
str
,
strlen
,
DYNCOL_UTF
,
nm
->
ptr
(),
nm
->
length
(),
nm
->
charset
(),
&
dummy_errors
);
}
...
...
sql/item_strfunc.cc
View file @
2913f615
...
...
@@ -4444,7 +4444,7 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg)
if
(
res
)
{
// guaranty UTF-8 string for names
if
(
my_charset_same
(
res
->
charset
(),
&
my_charset_utf8_general_ci
))
if
(
my_charset_same
(
res
->
charset
(),
DYNCOL_UTF
))
{
keys_str
[
i
].
length
=
res
->
length
();
keys_str
[
i
].
str
=
sql_strmake
(
res
->
ptr
(),
res
->
length
());
...
...
@@ -4455,11 +4455,11 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg)
uint
dummy_errors
;
char
*
str
=
(
char
*
)
sql_alloc
((
strlen
=
res
->
length
()
*
my_charset_utf8_general_ci
.
mbmaxlen
+
1
));
DYNCOL_UTF
->
mbmaxlen
+
1
));
if
(
str
)
{
keys_str
[
i
].
length
=
copy_and_convert
(
str
,
strlen
,
&
my_charset_utf8_general_ci
,
copy_and_convert
(
str
,
strlen
,
DYNCOL_UTF
,
res
->
ptr
(),
res
->
length
(),
res
->
charset
(),
&
dummy_errors
);
keys_str
[
i
].
str
=
str
;
...
...
@@ -4680,9 +4680,10 @@ String *Item_func_dyncol_json::val_str(String *str)
size_t
length
,
alloc_length
;
dynstr_reassociate
(
&
json
,
&
ptr
,
&
length
,
&
alloc_length
);
str
->
reassociate
(
ptr
,
(
uint32
)
length
,
(
uint32
)
alloc_length
,
&
my_charset_utf8_general_ci
);
DYNCOL_UTF
);
null_value
=
FALSE
;
}
str
->
set_charset
(
DYNCOL_UTF
);
return
str
;
null:
...
...
@@ -4781,7 +4782,7 @@ bool Item_dyncol_get::get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp)
return
1
;
}
if
(
my_charset_same
(
nm
->
charset
(),
&
my_charset_utf8_general_ci
))
if
(
my_charset_same
(
nm
->
charset
(),
DYNCOL_UTF
))
{
buf
.
str
=
(
char
*
)
nm
->
ptr
();
buf
.
length
=
nm
->
length
();
...
...
@@ -4791,11 +4792,11 @@ bool Item_dyncol_get::get_dyn_value(DYNAMIC_COLUMN_VALUE *val, String *tmp)
uint
strlen
;
uint
dummy_errors
;
buf
.
str
=
(
char
*
)
sql_alloc
((
strlen
=
nm
->
length
()
*
my_charset_utf8_general_ci
.
mbmaxlen
+
1
));
DYNCOL_UTF
->
mbmaxlen
+
1
));
if
(
buf
.
str
)
{
buf
.
length
=
copy_and_convert
(
buf
.
str
,
strlen
,
&
my_charset_utf8_general_ci
,
copy_and_convert
(
buf
.
str
,
strlen
,
DYNCOL_UTF
,
nm
->
ptr
(),
nm
->
length
(),
nm
->
charset
(),
&
dummy_errors
);
}
...
...
@@ -5229,7 +5230,6 @@ String *Item_func_dyncol_list::val_str(String *str)
goto
null
;
str
->
length
(
0
);
str
->
set_charset
(
&
my_charset_utf8_general_ci
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
append_identifier
(
current_thd
,
str
,
names
[
i
].
str
,
names
[
i
].
length
);
...
...
@@ -5239,6 +5239,7 @@ String *Item_func_dyncol_list::val_str(String *str)
null_value
=
FALSE
;
if
(
names
)
my_free
(
names
);
str
->
set_charset
(
DYNCOL_UTF
);
return
str
;
null:
...
...
sql/item_strfunc.h
View file @
2913f615
...
...
@@ -1177,14 +1177,14 @@ class Item_func_dyncol_add: public Item_func_dyncol_create
class
Item_func_dyncol_json
:
public
Item_str_func
{
public:
Item_func_dyncol_json
(
Item
*
str
)
:
Item_str_func
(
str
)
{}
Item_func_dyncol_json
(
Item
*
str
)
:
Item_str_func
(
str
)
{
collation
.
set
(
DYNCOL_UTF
);}
const
char
*
func_name
()
const
{
return
"column_json"
;
}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
max_length
=
MAX_BLOB_WIDTH
;
maybe_null
=
1
;
collation
.
set
(
&
my_charset_bin
);
decimals
=
0
;
}
};
...
...
@@ -1218,7 +1218,8 @@ class Item_dyncol_get: public Item_str_func
class
Item_func_dyncol_list
:
public
Item_str_func
{
public:
Item_func_dyncol_list
(
Item
*
str
)
:
Item_str_func
(
str
)
{};
Item_func_dyncol_list
(
Item
*
str
)
:
Item_str_func
(
str
)
{
collation
.
set
(
DYNCOL_UTF
);};
void
fix_length_and_dec
()
{
maybe_null
=
1
;
max_length
=
MAX_BLOB_WIDTH
;
};
const
char
*
func_name
()
const
{
return
"column_list"
;
}
String
*
val_str
(
String
*
);
...
...
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