pg 8.16.2 in binary mode produces incorrect row values
@hjr3 đang làm issue này rồi.
Từ ngày 20/6/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 13.2k
- Fork
- 1.4k
- Merge trung bình
- 6 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 6
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của brianc/node-postgres
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
brianc/node-postgres#3770 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
brianc/node-postgres#3716 · 1 bình luận ·
-
# remove bring your own promise Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
brianc/node-postgres#3631 · 1 bình luận ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
brianc/node-postgres#2857 ·
-
can't view docs for old versions Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
brianc/node-postgres#2433 ·
Tất cả issue của brianc/node-postgres
Issue tương tự
-
Update HugeIcons library Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
antfu-collective/icones#398 ·
-
ECmail.com Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
wesbos/burner-email-providers#554 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
components-web-app/docs#92 ·