-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Describe the bug
When having a json/jsonb structure that contains large integers on the source database, the snapshot replicates the data to the target with precision loss.
Example:
Source: '{"number": 1234567890123456789}'
Target: '{"number": 1234567890123456800}'
This happens because the snapshot retrieves the row values via the pgx library, which uses json to unmarshal json/jsonb types under the hood. The encoding/json library unmarshals integers into float64 types, which is what's causing the loss of precision in very large integers (numbers > 2^53-1 (9,007,199,254,740,991) lose precision).
To Reproduce
Steps to reproduce the behavior:
CREATE TABLE test_json (id int, data jsonb);INSERT INTO test_json VALUES (1, '{"num": 1234567890123456789}');- Run pgstream snapshot
- Compare the value on source and target.
SELECT data->>'num' FROM test_json WHERE id = 1;
Expected behavior
Precision should not be lost between source and target.
Setup (please complete the following information):
- pgstream version: v0.9.5
- Postgres version: 18.1
- Postgres environment: self-hosted