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
c73a0638
Commit
c73a0638
authored
Mar 26, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove append_escaped(), use String::append_for_single_quote() instead
parent
d0c6a05e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
70 deletions
+22
-70
sql/sql_analyse.cc
sql/sql_analyse.cc
+1
-54
sql/sql_analyse.h
sql/sql_analyse.h
+0
-2
sql/sql_partition.cc
sql/sql_partition.cc
+1
-3
sql/sql_string.h
sql/sql_string.h
+9
-0
storage/federated/ha_federated.cc
storage/federated/ha_federated.cc
+3
-3
storage/federatedx/ha_federatedx.cc
storage/federatedx/ha_federatedx.cc
+3
-3
storage/spider/spd_db_conn.cc
storage/spider/spd_db_conn.cc
+4
-4
storage/spider/spd_db_mysql.cc
storage/spider/spd_db_mysql.cc
+1
-1
No files found.
sql/sql_analyse.cc
View file @
c73a0638
...
...
@@ -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
;
}
sql/sql_analyse.h
View file @
c73a0638
...
...
@@ -365,6 +365,4 @@ class analyse: public Procedure
List
<
Item
>
&
field_list
);
};
bool
append_escaped
(
String
*
to_str
,
String
*
from_str
);
#endif
/* SQL_ANALYSE_INCLUDED */
sql/sql_partition.cc
View file @
c73a0638
...
...
@@ -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
,
&
org
str
);
err
+=
escapedstr
.
append_for_single_quote
(
quote
str
);
err
+=
add_string
(
fptr
,
escapedstr
.
c_ptr_safe
());
return
err
+
add_string
(
fptr
,
"'"
);
}
...
...
sql/sql_string.h
View file @
c73a0638
...
...
@@ -496,7 +496,16 @@ class String
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
);
...
...
storage/federated/ha_federated.cc
View file @
c73a0638
...
...
@@ -1004,7 +1004,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
uint
blob_length
=
uint2korr
(
ptr
);
blob
.
set_quick
((
char
*
)
ptr
+
HA_KEY_BLOB_LENGTH
,
blob_length
,
&
my_charset_bin
);
if
(
append_escaped
(
to
,
&
blob
))
if
(
to
->
append_for_single_quote
(
&
blob
))
DBUG_RETURN
(
1
);
}
else
if
(
part
->
key_part_flag
&
HA_VAR_LENGTH_PART
)
...
...
@@ -1013,7 +1013,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
uint
var_length
=
uint2korr
(
ptr
);
varchar
.
set_quick
((
char
*
)
ptr
+
HA_KEY_BLOB_LENGTH
,
var_length
,
&
my_charset_bin
);
if
(
append_escaped
(
to
,
&
varchar
))
if
(
to
->
append_for_single_quote
(
&
varchar
))
DBUG_RETURN
(
1
);
}
else
...
...
@@ -1025,7 +1025,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
if
(
field
->
result_type
()
==
STRING_RESULT
)
{
if
(
append_escaped
(
to
,
res
))
if
(
to
->
append_for_single_quote
(
res
))
DBUG_RETURN
(
1
);
}
else
if
(
to
->
append
(
res
->
ptr
(),
res
->
length
()))
...
...
storage/federatedx/ha_federatedx.cc
View file @
c73a0638
...
...
@@ -925,7 +925,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
uint
blob_length
=
uint2korr
(
ptr
);
blob
.
set_quick
((
char
*
)
ptr
+
HA_KEY_BLOB_LENGTH
,
blob_length
,
&
my_charset_bin
);
if
(
append_escaped
(
to
,
&
blob
))
if
(
to
->
append_for_single_quote
(
&
blob
))
DBUG_RETURN
(
1
);
}
else
if
(
part
->
key_part_flag
&
HA_VAR_LENGTH_PART
)
...
...
@@ -934,7 +934,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
uint
var_length
=
uint2korr
(
ptr
);
varchar
.
set_quick
((
char
*
)
ptr
+
HA_KEY_BLOB_LENGTH
,
var_length
,
&
my_charset_bin
);
if
(
append_escaped
(
to
,
&
varchar
))
if
(
to
->
append_for_single_quote
(
&
varchar
))
DBUG_RETURN
(
1
);
}
else
...
...
@@ -946,7 +946,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
if
(
field
->
result_type
()
==
STRING_RESULT
)
{
if
(
append_escaped
(
to
,
res
))
if
(
to
->
append_for_single_quote
(
res
))
DBUG_RETURN
(
1
);
}
else
if
(
to
->
append
(
res
->
ptr
(),
res
->
length
()))
...
...
storage/spider/spd_db_conn.cc
View file @
c73a0638
...
...
@@ -7909,7 +7909,7 @@ int spider_db_open_item_string(
tmp_str
.
mem_calc
();
str
->
q_append
(
SPIDER_SQL_VALUE_QUOTE_STR
,
SPIDER_SQL_VALUE_QUOTE_LEN
);
if
(
append_escaped
(
str
->
get_str
(),
tmp_str2
)
||
str
->
get_str
()
->
append_for_single_quote
(
tmp_str2
)
||
str
->
reserve
(
SPIDER_SQL_VALUE_QUOTE_LEN
)
)
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
...
...
@@ -9029,7 +9029,7 @@ int spider_db_udf_ping_table_append_mon_next(
str
->
q_append
(
SPIDER_SQL_SELECT_STR
,
SPIDER_SQL_SELECT_LEN
);
str
->
q_append
(
SPIDER_SQL_PING_TABLE_STR
,
SPIDER_SQL_PING_TABLE_LEN
);
str
->
q_append
(
SPIDER_SQL_VALUE_QUOTE_STR
,
SPIDER_SQL_VALUE_QUOTE_LEN
);
append_escaped
(
str
->
get_str
(),
child_table_name_str
.
get_str
());
str
->
get_str
()
->
append_for_single_quote
(
child_table_name_str
.
get_str
());
str
->
mem_calc
();
str
->
q_append
(
SPIDER_SQL_VALUE_QUOTE_STR
,
SPIDER_SQL_VALUE_QUOTE_LEN
);
str
->
q_append
(
SPIDER_SQL_COMMA_STR
,
SPIDER_SQL_COMMA_LEN
);
...
...
@@ -9040,7 +9040,7 @@ int spider_db_udf_ping_table_append_mon_next(
str
->
q_append
(
limit_str
,
limit_str_length
);
str
->
q_append
(
SPIDER_SQL_COMMA_STR
,
SPIDER_SQL_COMMA_LEN
);
str
->
q_append
(
SPIDER_SQL_VALUE_QUOTE_STR
,
SPIDER_SQL_VALUE_QUOTE_LEN
);
append_escaped
(
str
->
get_str
(),
where_clause_str
.
get_str
());
str
->
get_str
()
->
append_for_single_quote
(
where_clause_str
.
get_str
());
str
->
mem_calc
();
str
->
q_append
(
SPIDER_SQL_VALUE_QUOTE_STR
,
SPIDER_SQL_VALUE_QUOTE_LEN
);
str
->
q_append
(
SPIDER_SQL_COMMA_STR
,
SPIDER_SQL_COMMA_LEN
);
...
...
@@ -9093,7 +9093,7 @@ int spider_db_udf_ping_table_append_select(
))
DBUG_RETURN
(
HA_ERR_OUT_OF_MEM
);
if
(
use_where
)
append_escaped
(
str
->
get_str
(),
where_str
->
get_str
());
str
->
get_str
()
->
append_for_single_quote
(
where_str
->
get_str
());
str
->
mem_calc
();
str
->
q_append
(
SPIDER_SQL_LIMIT_STR
,
SPIDER_SQL_LIMIT_LEN
);
str
->
q_append
(
limit_str
,
limit_str_length
);
...
...
storage/spider/spd_db_mysql.cc
View file @
c73a0638
...
...
@@ -3717,7 +3717,7 @@ int spider_db_mysql_util::append_escaped_util(
)
{
DBUG_ENTER
(
"spider_db_mysql_util::append_escaped_util"
);
DBUG_PRINT
(
"info"
,(
"spider this=%p"
,
this
));
append_escaped
(
to
->
get_str
(),
from
);
to
->
get_str
()
->
append_for_single_quote
(
from
);
to
->
mem_calc
();
DBUG_RETURN
(
0
);
}
...
...
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