You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I have a struct that gets encoded to json before being sent with COPY to postgres, the encoded part ends up looking like this: \\x5b7b22.... The server then returns an error: invalid input syntax for type json.
Initially what triggered the issue was an upgrade of pq from 1.7.0 to 1.10.6. Testing different commits, it seemed this change one to be the trigger, but that is not the root cause: #979
Once the copy complete command is executed the server returns this:
And I thought the problem is the double backslash and made a change to remove it, but then the server seemed to parse the first two hex digits, but was then complaining for the next sequence:
Conclusion?
That leads me to believe the server wants me to send each byte hex escaped..
Any idea what might be going on? Is the double backslash \\x... how it's supposed to work.
The text was updated successfully, but these errors were encountered:
Description
When I have a struct that gets encoded to json before being sent with COPY to postgres, the encoded part ends up looking like this:
\\x5b7b22...
. The server then returns an error:invalid input syntax for type json
.Initially what triggered the issue was an upgrade of pq from 1.7.0 to 1.10.6. Testing different commits, it seemed this change one to be the trigger, but that is not the root cause: #979
And so far I've got to this part of the code which is the one producing the double backslash: https://github.com/lib/pq/blob/master/encode.go#L593
But I don't know if this is a problem with my postgres server (version 14.2) or with the encoding or even somewhere entirely different.
What the data looks like in Go
The data represented in Go looks like this:
So
items
is being json encoded since the field in the database for it is of type jsonb.(there's Value() and Scan() for the struct, just skipped them here for brevity)
The error in Go
Then I just issue a
and I get the error
Better view of the communication with Wireshark
The data sent to the server looks like this:
Once the copy complete command is executed the server returns this:
And I thought the problem is the double backslash and made a change to remove it, but then the server seemed to parse the first two hex digits, but was then complaining for the next sequence:
Conclusion?
That leads me to believe the server wants me to send each byte hex escaped..
Any idea what might be going on? Is the double backslash
\\x...
how it's supposed to work.The text was updated successfully, but these errors were encountered: