| 1938 | */ |
| 1939 | |
| 1940 | int |
| 1941 | append_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 |
no test coverage detected