MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / append_query_string

Function append_query_string

sql/item.cc:1940–1979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1938*/
1939
1940int
1941append_query_string(THD *thd, const CHARSET_INFO *csinfo,
1942 String const *from, String *to)
1943{
1944 char *beg, *ptr;
1945 uint32 const orig_len= to->length();
1946 if (to->reserve(orig_len + from->length()*2+3))
1947 return 1;
1948
1949 beg= to->c_ptr_quick() + to->length();
1950 ptr= beg;
1951 if (csinfo->escape_with_backslash_is_dangerous)
1952 ptr= str_to_hex(ptr, from->ptr(), from->length());
1953 else
1954 {
1955 *ptr++= '\'';
1956 if (!(thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES))
1957 {
1958 ptr+= escape_string_for_mysql(csinfo, ptr, 0,
1959 from->ptr(), from->length());
1960 }
1961 else
1962 {
1963 const char *frm_str= from->ptr();
1964
1965 for (; frm_str < (from->ptr() + from->length()); frm_str++)
1966 {
1967 /* Using '' way to represent "'" */
1968 if (*frm_str == '\'')
1969 *ptr++= *frm_str;
1970
1971 *ptr++= *frm_str;
1972 }
1973 }
1974
1975 *ptr++= '\'';
1976 }
1977 to->length(orig_len + ptr - beg);
1978 return 0;
1979}
1980#endif
1981
1982

Callers 1

query_val_strMethod · 0.85

Calls 6

str_to_hexFunction · 0.85
escape_string_for_mysqlFunction · 0.85
c_ptr_quickMethod · 0.80
lengthMethod · 0.45
reserveMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected