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

Function write_parameter

sql/parse_file.cc:104–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102
103
104static my_bool
105write_parameter(IO_CACHE *file, uchar* base, File_option *parameter)
106{
107 char num_buf[20]; // buffer for numeric operations
108 // string for numeric operations
109 String num(num_buf, sizeof(num_buf), &my_charset_bin);
110 DBUG_ENTER("write_parameter");
111
112 switch (parameter->type) {
113 case FILE_OPTIONS_STRING:
114 {
115 LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset);
116 if (my_b_append(file, (const uchar *)val_s->str, val_s->length))
117 DBUG_RETURN(TRUE);
118 break;
119 }
120 case FILE_OPTIONS_ESTRING:
121 {
122 if (write_escaped_string(file, (LEX_STRING *)(base + parameter->offset)))
123 DBUG_RETURN(TRUE);
124 break;
125 }
126 case FILE_OPTIONS_ULONGLONG:
127 {
128 num.set(*((ulonglong *)(base + parameter->offset)), &my_charset_bin);
129 if (my_b_append(file, (const uchar *)num.ptr(), num.length()))
130 DBUG_RETURN(TRUE);
131 break;
132 }
133 case FILE_OPTIONS_TIMESTAMP:
134 {
135 /* string have to be allocated already */
136 LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset);
137 time_t tm= my_time(0);
138
139 get_date(val_s->str, GETDATE_DATE_TIME|GETDATE_GMT|GETDATE_FIXEDLENGTH,
140 tm);
141 val_s->length= PARSE_FILE_TIMESTAMPLENGTH;
142 if (my_b_append(file, (const uchar *)val_s->str,
143 PARSE_FILE_TIMESTAMPLENGTH))
144 DBUG_RETURN(TRUE);
145 break;
146 }
147 case FILE_OPTIONS_STRLIST:
148 {
149 List_iterator_fast<LEX_STRING> it(*((List<LEX_STRING>*)
150 (base + parameter->offset)));
151 bool first= 1;
152 LEX_STRING *str;
153 while ((str= it++))
154 {
155 // We need ' ' after string to detect list continuation
156 if ((!first && my_b_append(file, (const uchar *)STRING_WITH_LEN(" "))) ||
157 my_b_append(file, (const uchar *)STRING_WITH_LEN("\'")) ||
158 write_escaped_string(file, str) ||
159 my_b_append(file, (const uchar *)STRING_WITH_LEN("\'")))
160 {
161 DBUG_RETURN(TRUE);

Callers

nothing calls this directly

Calls 7

my_b_appendFunction · 0.85
write_escaped_stringFunction · 0.85
my_timeFunction · 0.85
get_dateFunction · 0.85
setMethod · 0.45
ptrMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected