summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_analyse.cc55
-rw-r--r--sql/sql_analyse.h2
-rw-r--r--sql/sql_partition.cc4
-rw-r--r--sql/sql_string.h9
4 files changed, 11 insertions, 59 deletions
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index ac3f7f25518..9b7ea58bee6 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -1080,7 +1080,7 @@ int collect_string(String *element,
else
info->found = 1;
info->str->append('\'');
- if (append_escaped(info->str, element))
+ if (info->str->append_for_single_quote(element))
return 1;
info->str->append('\'');
return 0;
@@ -1239,56 +1239,3 @@ uint check_ulonglong(const char *str, uint length)
return ((uchar) str[-1] <= (uchar) cmp[-1]) ? smaller : bigger;
} /* check_ulonlong */
-
-/*
- Quote special characters in a string.
-
- SYNOPSIS
- append_escaped(to_str, from_str)
- to_str (in) A pointer to a String.
- from_str (to) A pointer to an allocated string
-
- DESCRIPTION
- append_escaped() takes a String type variable, where it appends
- escaped the second argument. Only characters that require escaping
- will be escaped.
-
- RETURN VALUES
- 0 Success
- 1 Out of memory
-*/
-
-bool append_escaped(String *to_str, String *from_str)
-{
- char *from, *end, c;
-
- if (to_str->realloc(to_str->length() + from_str->length()))
- return 1;
-
- from= (char*) from_str->ptr();
- end= from + from_str->length();
- for (; from < end; from++)
- {
- c= *from;
- switch (c) {
- case '\0':
- c= '0';
- break;
- case '\032':
- c= 'Z';
- break;
- case '\\':
- case '\'':
- break;
- default:
- goto normal_character;
- }
- if (to_str->append('\\'))
- return 1;
-
- normal_character:
- if (to_str->append(c))
- return 1;
- }
- return 0;
-}
diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h
index 8bac29de5a3..3d3662c3f4f 100644
--- a/sql/sql_analyse.h
+++ b/sql/sql_analyse.h
@@ -365,6 +365,4 @@ public:
List<Item> &field_list);
};
-bool append_escaped(String *to_str, String *from_str);
-
#endif /* SQL_ANALYSE_INCLUDED */
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index a9846df3b02..1ce952b9030 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -67,7 +67,6 @@
// table_to_filename
// mysql_*_alter_copy_data
#include "opt_range.h" // store_key_image_to_rec
-#include "sql_analyse.h" // append_escaped
#include "sql_alter.h" // Alter_table_ctx
#include <algorithm>
@@ -1935,10 +1934,9 @@ static int add_uint(File fptr, ulonglong number)
*/
static int add_quoted_string(File fptr, const char *quotestr)
{
- String orgstr(quotestr, system_charset_info);
String escapedstr;
int err= add_string(fptr, "'");
- err+= append_escaped(&escapedstr, &orgstr);
+ err+= escapedstr.append_for_single_quote(quotestr);
err+= add_string(fptr, escapedstr.c_ptr_safe());
return err + add_string(fptr, "'");
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 65c5961a1d0..77712c09805 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -496,7 +496,16 @@ public:
return FALSE;
}
void print(String *print);
+
bool append_for_single_quote(const char *st, uint len);
+ bool append_for_single_quote(const String *s)
+ {
+ return append_for_single_quote(s->ptr(), s->length());
+ }
+ bool append_for_single_quote(const char *st)
+ {
+ return append_for_single_quote(st, strlen(st));
+ }
/* Swap two string objects. Efficient way to exchange data without memcpy. */
void swap(String &s);