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

Function write_escaped_string

sql/parse_file.cc:48–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46*/
47
48static my_bool
49write_escaped_string(IO_CACHE *file, LEX_STRING *val_s)
50{
51 char *eos= val_s->str + val_s->length;
52 char *ptr= val_s->str;
53
54 for (; ptr < eos; ptr++)
55 {
56 /*
57 Should be in sync with read_escaped_string() and
58 parse_quoted_escaped_string()
59 */
60 switch(*ptr) {
61 case '\\': // escape character
62 if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\\")))
63 return TRUE;
64 break;
65 case '\n': // parameter value delimiter
66 if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\n")))
67 return TRUE;
68 break;
69 case '\0': // problem for some string processing utilities
70 if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\0")))
71 return TRUE;
72 break;
73 case 26: // problem for windows utilities (Ctrl-Z)
74 if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\z")))
75 return TRUE;
76 break;
77 case '\'': // list of string delimiter
78 if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\'")))
79 return TRUE;
80 break;
81 default:
82 if (my_b_append(file, (const uchar *)ptr, 1))
83 return TRUE;
84 }
85 }
86 return FALSE;
87}
88
89
90/**

Callers 1

write_parameterFunction · 0.85

Calls 1

my_b_appendFunction · 0.85

Tested by

no test coverage detected