| 102 | |
| 103 | |
| 104 | static my_bool |
| 105 | write_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); |
nothing calls this directly
no test coverage detected