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
218280bc
Commit
218280bc
authored
Mar 26, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make append_query_string() more usable:
simplify the prototype and move it to sql_string.h
parent
c73a0638
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
20 deletions
+19
-20
sql/item.cc
sql/item.cc
+3
-3
sql/log_event.cc
sql/log_event.cc
+9
-11
sql/log_event.h
sql/log_event.h
+0
-3
sql/sp_head.cc
sql/sp_head.cc
+3
-2
sql/sql_string.cc
sql/sql_string.cc
+1
-1
sql/sql_string.h
sql/sql_string.h
+3
-0
No files found.
sql/item.cc
View file @
218280bc
...
...
@@ -41,7 +41,6 @@
// REPORT_EXCEPT_NOT_FOUND,
// find_item_in_list,
// RESOLVED_AGAINST_ALIAS, ...
#include "log_event.h" // append_query_string
#include "sql_expression_cache.h"
const
String
my_null_string
(
"NULL"
,
4
,
default_charset_info
);
...
...
@@ -3749,8 +3748,9 @@ const String *Item_param::query_val_str(THD *thd, String* str) const
case
LONG_DATA_VALUE
:
{
str
->
length
(
0
);
append_query_string
(
thd
,
value
.
cs_info
.
character_set_client
,
&
str_value
,
str
);
append_query_string
(
value
.
cs_info
.
character_set_client
,
str
,
str_value
.
ptr
(),
str_value
.
length
(),
thd
->
variables
.
sql_mode
&
MODE_NO_BACKSLASH_ESCAPES
);
break
;
}
case
NULL_VALUE
:
...
...
sql/log_event.cc
View file @
218280bc
...
...
@@ -687,37 +687,35 @@ char *str_to_hex(char *to, const char *from, uint len)
#ifndef MYSQL_CLIENT
/**
Append a version of the '
from
' string suitable for use in a query to
Append a version of the '
str
' string suitable for use in a query to
the 'to' string. To generate a correct escaping, the character set
information in 'csinfo' is used.
*/
int
append_query_string
(
THD
*
thd
,
CHARSET_INFO
*
csinfo
,
String
const
*
from
,
String
*
to
)
int
append_query_string
(
CHARSET_INFO
*
csinfo
,
String
*
to
,
const
char
*
str
,
size_t
len
,
bool
no_backslash
)
{
char
*
beg
,
*
ptr
;
uint32
const
orig_len
=
to
->
length
();
if
(
to
->
reserve
(
orig_len
+
from
->
length
()
*
2
+
4
))
if
(
to
->
reserve
(
orig_len
+
len
*
2
+
4
))
return
1
;
beg
=
(
char
*
)
to
->
ptr
()
+
to
->
length
();
ptr
=
beg
;
if
(
csinfo
->
escape_with_backslash_is_dangerous
)
ptr
=
str_to_hex
(
ptr
,
from
->
ptr
(),
from
->
length
()
);
ptr
=
str_to_hex
(
ptr
,
str
,
len
);
else
{
*
ptr
++=
'\''
;
if
(
!
(
thd
->
variables
.
sql_mode
&
MODE_NO_BACKSLASH_ESCAPES
)
)
if
(
!
no_backslash
)
{
ptr
+=
escape_string_for_mysql
(
csinfo
,
ptr
,
0
,
from
->
ptr
(),
from
->
length
());
ptr
+=
escape_string_for_mysql
(
csinfo
,
ptr
,
0
,
str
,
len
);
}
else
{
const
char
*
frm_str
=
from
->
ptr
()
;
const
char
*
frm_str
=
str
;
for
(;
frm_str
<
(
from
->
ptr
()
+
from
->
length
()
);
frm_str
++
)
for
(;
frm_str
<
(
str
+
len
);
frm_str
++
)
{
/* Using '' way to represent "'" */
if
(
*
frm_str
==
'\''
)
...
...
sql/log_event.h
View file @
218280bc
...
...
@@ -4766,9 +4766,6 @@ class Heartbeat_log_event: public Log_event
bool
slave_execute_deferred_events
(
THD
*
thd
);
#endif
int
append_query_string
(
THD
*
thd
,
CHARSET_INFO
*
csinfo
,
String
const
*
from
,
String
*
to
);
bool
rpl_get_position_info
(
const
char
**
log_file_name
,
ulonglong
*
log_pos
,
const
char
**
group_relay_log_name
,
ulonglong
*
relay_log_pos
);
...
...
sql/sp_head.cc
View file @
218280bc
...
...
@@ -27,7 +27,7 @@
// prepare_create_field
#include "sql_acl.h" // *_ACL
#include "sql_array.h" // Dynamic_array
#include "log_event.h" //
append_query_string,
Query_log_event
#include "log_event.h" // Query_log_event
#include "sql_derived.h" // mysql_handle_derived
#ifdef USE_PRAGMA_IMPLEMENTATION
...
...
@@ -160,7 +160,8 @@ sp_get_item_value(THD *thd, Item *item, String *str)
buf
.
append
(
result
->
charset
()
->
csname
);
if
(
cs
->
escape_with_backslash_is_dangerous
)
buf
.
append
(
' '
);
append_query_string
(
thd
,
cs
,
result
,
&
buf
);
append_query_string
(
cs
,
&
buf
,
result
->
ptr
(),
result
->
length
(),
thd
->
variables
.
sql_mode
&
MODE_NO_BACKSLASH_ESCAPES
);
buf
.
append
(
" COLLATE '"
);
buf
.
append
(
item
->
collation
.
collation
->
name
);
buf
.
append
(
'\''
);
...
...
sql/sql_string.cc
View file @
218280bc
...
...
@@ -1014,7 +1014,7 @@ well_formed_copy_nchars(CHARSET_INFO *to_cs,
/*
Append characters to a single-quoted string '...', escaping special
characters as necessary.
characters
with backslashes
as necessary.
Does not add the enclosing quotes, this is left up to caller.
*/
#define APPEND(X) if (append(X)) return 1; else break
...
...
sql/sql_string.h
View file @
218280bc
...
...
@@ -568,4 +568,7 @@ static inline bool check_if_only_end_space(CHARSET_INFO *cs,
return
str
+
cs
->
cset
->
scan
(
cs
,
str
,
end
,
MY_SEQ_SPACES
)
==
end
;
}
int
append_query_string
(
CHARSET_INFO
*
csinfo
,
String
*
to
,
const
char
*
str
,
size_t
len
,
bool
no_backslash
);
#endif
/* SQL_STRING_INCLUDED */
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