MCPcopy Create free account
hub / github.com/MariaDB/server / append_query_string

Function append_query_string

sql/log_event_server.cc:517–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515*/
516
517int 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/**************************************************************************

Callers 5

append_for_logMethod · 0.85
append_for_logMethod · 0.85
value_query_val_strMethod · 0.85
append_userFunction · 0.85

Calls 5

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

Tested by

no test coverage detected