Skip to content

Fixes for binary protocol array handling #3494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2025
Merged

Fixes for binary protocol array handling #3494

merged 2 commits into from
Jun 19, 2025

Conversation

hjr3
Copy link
Collaborator

@hjr3 hjr3 commented Jun 19, 2025

No description provided.

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
Copy link

cloudflare-workers-and-pages bot commented Jun 19, 2025

Deploying node-postgres with  Cloudflare Pages  Cloudflare Pages

Latest commit: f63b23b
Status: ✅  Deploy successful!
Preview URL: https://c08f83cf.node-postgres.pages.dev
Branch Preview URL: https://push-nnlqqononklk.node-postgres.pages.dev

View logs

@hjr3 hjr3 force-pushed the push-nnlqqononklk branch from 85e7c7e to 5a9f5ad Compare June 19, 2025 18:45
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.
@hjr3 hjr3 force-pushed the push-nnlqqononklk branch from 5a9f5ad to f63b23b Compare June 19, 2025 18:48
@brianc
Copy link
Owner

brianc commented Jun 19, 2025

ohh nice is this a fix #3487?

@hjr3
Copy link
Collaborator Author

hjr3 commented Jun 19, 2025

The first commit fixes the reported error in #3487. I annotated that in the first commit, but it seems like Github did not pick it up.

While fixing the reported issue, I discovered that the binary array handling was not working. So, the second commit fixes that. I can split this into two commits if that is easier as well.

@brianc
Copy link
Owner

brianc commented Jun 19, 2025

So, the second commit fixes that. I can split this into two commits if that is easier as well.

one is totally fine!

@brianc
Copy link
Owner

brianc commented Jun 19, 2025

@hjr3 you're the best! 🫶

@brianc brianc merged commit e00aac1 into master Jun 19, 2025
15 checks passed
@hjr3 hjr3 deleted the push-nnlqqononklk branch June 19, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants