| 515 | */ |
| 516 | |
| 517 | int append_query_string(CHARSET_INFO *csinfo, String *to, |
| 518 | const char *str, size_t len, bool no_backslash) |
| 519 | { |
| 520 | char *beg, *ptr; |
| 521 | my_bool overflow; |
| 522 | uint32 const orig_len= to->length(); |
| 523 | if (to->reserve(orig_len + len * 2 + 4)) |
| 524 | return 1; |
| 525 | |
| 526 | beg= (char*) to->ptr() + to->length(); |
| 527 | ptr= beg; |
| 528 | if (csinfo->escape_with_backslash_is_dangerous) |
| 529 | ptr= str_to_hex(ptr, (uchar*)str, len); |
| 530 | else |
| 531 | { |
| 532 | *ptr++= '\''; |
| 533 | if (!no_backslash) |
| 534 | { |
| 535 | ptr+= escape_string_for_mysql(csinfo, ptr, 0, str, len, &overflow); |
| 536 | } |
| 537 | else |
| 538 | { |
| 539 | const char *frm_str= str; |
| 540 | |
| 541 | for (; frm_str < (str + len); frm_str++) |
| 542 | { |
| 543 | /* Using '' way to represent "'" */ |
| 544 | if (*frm_str == '\'') |
| 545 | *ptr++= *frm_str; |
| 546 | |
| 547 | *ptr++= *frm_str; |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | *ptr++= '\''; |
| 552 | } |
| 553 | to->length((uint32)(orig_len + ptr - beg)); |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | |
| 558 | /************************************************************************** |
no test coverage detected