pg 8.16.2 in binary mode produces incorrect row values
@hjr3 ya está trabajando en esto.
Desde el 20/6/2025.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 13.2k
- Forks
- 1.4k
- Merge medio
- 6 d 15 h
- PR fusionados (30 d)
- 6
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de brianc/node-postgres
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
brianc/node-postgres#3770 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
brianc/node-postgres#3716 · 1 comentario ·
-
# remove bring your own promise Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
brianc/node-postgres#3631 · 1 comentario ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 62/100
brianc/node-postgres#2857 ·
-
can't view docs for old versions Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
brianc/node-postgres#2433 ·
Todos los issues de brianc/node-postgres
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
mksglu/context-mode#1200 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
neondatabase/website#5944 ·
-
module: core
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
bigbluebutton/bigbluebutton#25849 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
jaegertracing/jaeger-ui#4506 ·