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
faf4d99d
Commit
faf4d99d
authored
Apr 19, 2013
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
String::append_for_single_quote() should signal OOM condition,
just like other String::append() methods do
parent
4b169cd7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
22 deletions
+11
-22
sql/sql_string.cc
sql/sql_string.cc
+10
-21
sql/sql_string.h
sql/sql_string.h
+1
-1
No files found.
sql/sql_string.cc
View file @
faf4d99d
...
@@ -1079,7 +1079,8 @@ well_formed_copy_nchars(CHARSET_INFO *to_cs,
...
@@ -1079,7 +1079,8 @@ well_formed_copy_nchars(CHARSET_INFO *to_cs,
characters as necessary.
characters as necessary.
Does not add the enclosing quotes, this is left up to caller.
Does not add the enclosing quotes, this is left up to caller.
*/
*/
void
String
::
append_for_single_quote
(
const
char
*
st
,
uint
len
)
#define APPEND(X) if (append(X)) return 1; else break
bool
String
::
append_for_single_quote
(
const
char
*
st
,
uint
len
)
{
{
const
char
*
end
=
st
+
len
;
const
char
*
end
=
st
+
len
;
for
(;
st
<
end
;
st
++
)
for
(;
st
<
end
;
st
++
)
...
@@ -1087,28 +1088,16 @@ void String::append_for_single_quote(const char *st, uint len)
...
@@ -1087,28 +1088,16 @@ void String::append_for_single_quote(const char *st, uint len)
uchar
c
=
*
st
;
uchar
c
=
*
st
;
switch
(
c
)
switch
(
c
)
{
{
case
'\\'
:
case
'\\'
:
APPEND
(
STRING_WITH_LEN
(
"
\\\\
"
));
append
(
STRING_WITH_LEN
(
"
\\\\
"
));
case
'\0'
:
APPEND
(
STRING_WITH_LEN
(
"
\\
0"
));
break
;
case
'\''
:
APPEND
(
STRING_WITH_LEN
(
"
\\
'"
));
case
'\0'
:
case
'\n'
:
APPEND
(
STRING_WITH_LEN
(
"
\\
n"
));
append
(
STRING_WITH_LEN
(
"
\\
0"
));
case
'\r'
:
APPEND
(
STRING_WITH_LEN
(
"
\\
r"
));
break
;
case
'\032'
:
APPEND
(
STRING_WITH_LEN
(
"
\\
Z"
));
case
'\''
:
default:
APPEND
(
c
);
append
(
STRING_WITH_LEN
(
"
\\
'"
));
break
;
case
'\n'
:
append
(
STRING_WITH_LEN
(
"
\\
n"
));
break
;
case
'\r'
:
append
(
STRING_WITH_LEN
(
"
\\
r"
));
break
;
case
'\032'
:
// Ctrl-Z
append
(
STRING_WITH_LEN
(
"
\\
Z"
));
break
;
default:
append
(
c
);
}
}
}
}
return
0
;
}
}
void
String
::
print
(
String
*
str
)
void
String
::
print
(
String
*
str
)
...
...
sql/sql_string.h
View file @
faf4d99d
...
@@ -476,7 +476,7 @@ class String
...
@@ -476,7 +476,7 @@ class String
return
FALSE
;
return
FALSE
;
}
}
void
print
(
String
*
print
);
void
print
(
String
*
print
);
void
append_for_single_quote
(
const
char
*
st
,
uint
len
);
bool
append_for_single_quote
(
const
char
*
st
,
uint
len
);
/* Swap two string objects. Efficient way to exchange data without memcpy. */
/* Swap two string objects. Efficient way to exchange data without memcpy. */
void
swap
(
String
&
s
);
void
swap
(
String
&
s
);
...
...
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