Skip to content

could not parse "\\000x\\0ffyz" as type bytes: invalid bytea escape sequence #57367

@mniewrzal

Description

@mniewrzal

Describe the problem
I have a problem using SUBSTRING function on a column defined as BYTEA. For some values in a column, the function fails with an error:

ERROR: substring(): could not parse "���Q��=\nݻk�1\x10�O�j�%V\\\x12\rz����/\x02���'��z���w�b3EӍK�^��n\t٩�1��\f�$f �\x1e\\G�\x06: \x1a" as type bytes: invalid bytea escape sequence (SQLSTATE 22025)

I'm using pgx as a Go driver.

To Reproduce
This snippet can be used to reproduce this error:

root@localhost:26257/defaultdb> SELECT substring(x'02535497082f02bd395c', 1);
ERROR: substring(): could not parse "\x02ST�\b/\x02�9\\" as type bytes: bytea encoded value ends with escape character
SQLSTATE: 22025

The same snippet works fine for Postgres.

Expected behavior
No error.

Environment:
Build Tag: v20.2.2
Build Time: 2020/11/25 14:45:44
Distribution: CCL
Platform: linux amd64 (x86_64-unknown-linux-gnu)
Go Version: go1.13.14
C Compiler: gcc 6.3.0
Build Commit ID: 92d9495
Build Type: release

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityS-3-erroneous-edge-caseDatabase produces or stores erroneous data without visible error/warning, in rare edge cases.X-blathers-triagedblathers was able to find an owner

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions