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
07143a73
Commit
07143a73
authored
May 02, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12659 Add THD::make_string_literal()
parent
85b73e22
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
42 deletions
+36
-42
sql/sql_class.cc
sql/sql_class.cc
+20
-0
sql/sql_class.h
sql/sql_class.h
+14
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-21
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+1
-21
No files found.
sql/sql_class.cc
View file @
07143a73
...
...
@@ -2352,6 +2352,26 @@ bool THD::convert_string(String *s, CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
}
Item_string
*
THD
::
make_string_literal
(
const
char
*
str
,
size_t
length
,
uint
repertoire
)
{
if
(
!
charset_is_collation_connection
&&
(
repertoire
!=
MY_REPERTOIRE_ASCII
||
!
my_charset_is_ascii_based
(
variables
.
collation_connection
)))
{
LEX_STRING
to
;
if
(
convert_string
(
&
to
,
variables
.
collation_connection
,
str
,
length
,
variables
.
character_set_client
))
return
NULL
;
str
=
to
.
str
;
length
=
to
.
length
;
}
return
new
(
mem_root
)
Item_string
(
this
,
str
,
length
,
variables
.
collation_connection
,
DERIVATION_COERCIBLE
,
repertoire
);
}
/*
Update some cache variables when character set changes
*/
...
...
sql/sql_class.h
View file @
07143a73
...
...
@@ -3423,6 +3423,20 @@ class THD :public Statement,
bool
convert_string
(
String
*
s
,
CHARSET_INFO
*
from_cs
,
CHARSET_INFO
*
to_cs
);
/*
Create a string literal with optional client->connection conversion.
@param str - the string in the client character set
@param length - length of the string
@param repertoire - the repertoire of the string
*/
Item_string
*
make_string_literal
(
const
char
*
str
,
size_t
length
,
uint
repertoire
);
Item_string
*
make_string_literal
(
const
Lex_string_with_metadata_st
&
str
)
{
uint
repertoire
=
str
.
repertoire
(
variables
.
character_set_client
);
return
make_string_literal
(
str
.
str
,
str
.
length
,
repertoire
);
}
void
add_changed_table
(
TABLE
*
table
);
void
add_changed_table
(
const
char
*
key
,
long
key_length
);
CHANGED_TABLE_LIST
*
changed_table_dup
(
const
char
*
key
,
long
key_length
);
...
...
sql/sql_yacc.yy
View file @
07143a73
...
...
@@ -13712,27 +13712,7 @@ load_data_set_elem:
text_literal:
TEXT_STRING
{
LEX_CSTRING tmp;
CHARSET_INFO *cs_con= thd->variables.collation_connection;
CHARSET_INFO *cs_cli= thd->variables.character_set_client;
uint repertoire= $1.repertoire(cs_cli);
if (thd->charset_is_collation_connection ||
(repertoire == MY_REPERTOIRE_ASCII &&
my_charset_is_ascii_based(cs_con)))
tmp= $1;
else
{
LEX_STRING to;
if (thd->convert_string(&to, cs_con, $1.str, $1.length, cs_cli))
MYSQL_YYABORT;
tmp.str= to.str;
tmp.length= to.length;
}
$$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length,
cs_con,
DERIVATION_COERCIBLE,
repertoire);
if ($$ == NULL)
if (!($$= thd->make_string_literal($1)))
MYSQL_YYABORT;
}
| NCHAR_STRING
...
...
sql/sql_yacc_ora.yy
View file @
07143a73
...
...
@@ -13836,27 +13836,7 @@ load_data_set_elem:
text_literal:
TEXT_STRING
{
LEX_CSTRING tmp;
CHARSET_INFO *cs_con= thd->variables.collation_connection;
CHARSET_INFO *cs_cli= thd->variables.character_set_client;
uint repertoire= $1.repertoire(cs_cli);
if (thd->charset_is_collation_connection ||
(repertoire == MY_REPERTOIRE_ASCII &&
my_charset_is_ascii_based(cs_con)))
tmp= $1;
else
{
LEX_STRING to;
if (thd->convert_string(&to, cs_con, $1.str, $1.length, cs_cli))
MYSQL_YYABORT;
tmp.str= to.str;
tmp.length= to.length;
}
$$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length,
cs_con,
DERIVATION_COERCIBLE,
repertoire);
if ($$ == NULL)
if (!($$= thd->make_string_literal($1)))
MYSQL_YYABORT;
}
| NCHAR_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