Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

pg 8.16.2 in binary mode produces incorrect row values

Aperta
#3,495 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@hjr3 ci sta già lavorando.

Dal 20/6/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

I have recently have been experimenting with pg's binary mode for performance reasons and tried the latest change, and I found that it delivers incorrect results sometimes for various non-string fields.
For example, a "int32" column with value "1000" is incorrectly returned as 1007.

This is caused by the parser converting the buffer slice into an utf8 string:
https://github.com/brianc/node-postgres/blob/1a25d128177dd7c54dc4652bbb92ac7986306e3f/packages/pg-protocol/src/parser.ts#L287

and then the result converts it back into a buffer in binary mode
https://github.com/brianc/node-postgres/blob/1a25d128177dd7c54dc4652bbb92ac7986306e3f/packages/pg/lib/result.js#L69-L70

This is incorrect, however, because roundtrips with random binary data from and to utf8, does not work all the time - for example the int32 value "1000" (0x3e8)

> Buffer.from(Buffer.from([0,0,0x03,0xe8]).toString())
<Buffer 00 00 03 ef bf bd>
> readInt32BE()
< 1007

I was able to fix this by performing the conversion the other way around, but this does not seem great performance-wise.

Lingua principale
JavaScript
Stelle
13.2k
Fork
1.4k
Merge medio
6g 15h
PR unite (30g)
6

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di brianc/node-postgres

Tutte le issue di brianc/node-postgres

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.