pg 8.16.2 in binary mode produces incorrect row values
@hjr3 ci sta già lavorando.
Dal 20/6/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di brianc/node-postgres
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
brianc/node-postgres#3770 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
brianc/node-postgres#3716 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
brianc/node-postgres#3631 · 1 commento ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 62/100
brianc/node-postgres#2857 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
brianc/node-postgres#2433 ·
Tutte le issue di brianc/node-postgres
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mksglu/context-mode#1200 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
neondatabase/website#5944 ·
-
module: core
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
bigbluebutton/bigbluebutton#25849 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jaegertracing/jaeger-ui#4506 ·