| 219 | } |
| 220 | |
| 221 | func decodeHexBytea(src []byte) ([]byte, error) { |
| 222 | if src == nil { |
| 223 | return nil, nil |
| 224 | } |
| 225 | |
| 226 | if len(src) < 2 || src[0] != '\\' || src[1] != 'x' { |
| 227 | return nil, fmt.Errorf("invalid hex format") |
| 228 | } |
| 229 | |
| 230 | buf := make([]byte, (len(src)-2)/2) |
| 231 | _, err := hex.Decode(buf, src[2:]) |
| 232 | if err != nil { |
| 233 | return nil, err |
| 234 | } |
| 235 | |
| 236 | return buf, nil |
| 237 | } |
| 238 | |
| 239 | func (c ByteaCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) { |
| 240 | return c.DecodeValue(m, oid, format, src) |