Herman J. Radtke III e00aac1398
Fixes for binary protocol array handling (#3494)
* fix(pg-protocol): specify number of result column format codes

Fixes a bug when binary format. We must specify both:

- the number of result column format codes
- the result column format codes

The text format case was working by accident. When using text format, the
intention was to set the format code to 0. Instead, we set the number
of result column format codes was set to 0. This is valid because it indicates
that all result columns should use the default format (text).

When using binary format, the intention was to set the format code to 1.
Instead, we set the number of result column format codes to 1.
Importantly, we never set a result column format code. This caused an
error: 'insufficient data left in message'. 

We now always set the number of result column format codes to '1'. The
value of '1' has special meaning:

> or one, in which case the specified format code is applied to all result columns (if any)

We then set a single column format code based on whether the connection
(or query) is set to binary.


Fixes #3487

* fix(pg): use a Buffer when parsing binary

The call to parseArray was not working as expected because the value was
being sent as a string instead of a Buffer. The binary parsers in
pg-types all assume the incoming value is a Buffer.
2025-06-19 15:37:04 -05:00
..
2025-06-18 10:46:26 -05:00
2021-01-19 23:24:44 +00:00
2025-04-22 10:53:22 -05:00

pg-protocol

Low level postgres wire protocol parser and serializer written in Typescript. Used by node-postgres. Needs more documentation. 😄