Possible bug when extracting array elements
Hello 👋🏼
Thanks for all the enhancements to the text encoding.
I have a postgres server that uses the `FromSqlText` for decoding types. In the sent bytes for `bytearray` or `string` from a go client that uses lib/pq, it seems that the [backslash character](https://github.com/lib/pq/blob/b7ffbd3b47da4290a4af2ccd253c74c2c22bfabf/array.go#L765) is escaped even if it is within quotes but in pgwire we will push [both backlashes to the element string](https://github.com/sunng87/pgwire/blob/bebf870e003b2c1286f3e8dc49c1c9ff9e10e9bc/src/types/from_sql_text.rs#L418) if they are within a quote when extracting. [Same thing](https://github.com/lib/pq/blob/b7ffbd3b47da4290a4af2ccd253c74c2c22bfabf/array.go#L205) for the `\x` that is prepended to hex encoding for bytea (In the go client, each bytea in the array is quoted and the backlash is escaped, but `to_sql_text` for `Vec<[u8]>` produces a byte sequence with no quotes and backlask isn't escaped). Not sure if this is the standard behaviour defined by postgres.
The docs says:
> The text representation of values is whatever strings are produced and accepted by the input/output conversion functions for the particular data type.
And the input function does require a backslash.
```
postgres=# SELECT length(('{ "a\\b" }'::text[])[1])
postgres-# ;
length
--------
3
(1 row)
postgres=# SELECT length(('{ "a\b" }'::text[])[1]) ;
length
--------
2
(1 row)
```
Happy to send in a fix if this is a bug
1 条评论