(data []byte)
| 158 | } |
| 159 | |
| 160 | func (d *stringFieldDescriptor) ParseValue(data []byte) ( |
| 161 | value interface{}, |
| 162 | remaining []byte, |
| 163 | err error) { |
| 164 | |
| 165 | value, remaining, err = d.parseValue(data) |
| 166 | if d.fieldType != mysql_proto.FieldType_STRING || err != nil { |
| 167 | return value, remaining, err |
| 168 | } |
| 169 | |
| 170 | bytesValue, ok := value.([]byte) |
| 171 | if !ok { |
| 172 | return value, remaining, nil |
| 173 | } |
| 174 | |
| 175 | if len(bytesValue) < d.maxLength { |
| 176 | // NOTE: We have to allocate a new copy instead of padding it in place |
| 177 | // since it is a slice pointing to same backing array as remaining. |
| 178 | newBytesValue := bytes.Repeat([]byte("\x00"), d.maxLength) |
| 179 | copy(newBytesValue, bytesValue) |
| 180 | bytesValue = newBytesValue |
| 181 | } |
| 182 | |
| 183 | return bytesValue, remaining, nil |
| 184 | } |
| 185 | |
| 186 | // |
| 187 | // blobFieldDescriptor -------------------------------------------------------- |
nothing calls this directly
no test coverage detected