peerdb
peerdb copied to clipboard
CDC for PG box[] type is not working
Steps to reproduce:
create table test_box (id serial primary key, b box[]);- Create a mirror with
test_boxas a source insert into test_box(b) values(array['((3,3),(1,1))','((6,6),(4,4))']::box[]);- Row doesn't show up, logs say
failed in pull records when: error processing message: error converting tuple to map: error decoding text column data: invalid length for Box: 2
The error is coming from pgx: https://github.com/jackc/pgx/blob/d2ee7464e8e5c49f0caea95b825b1bb169a47cbc/pgtype/box.go#L184
if len(src) < 11 {
return fmt.Errorf("invalid length for Box: %v", len(src))
}
This seems to be an incompatibility somewhere between Postgres, pglogrepl and pgtype. pglogrepl returns {(3,3),(1,1);(6,6),(4,4)} as a text representation and the substring passed to the code above is (3. Encoding the same []pgtype.Box through pgtype.Map.Encode() results in {"(3,3),(1,1)","(6,6),(4,4)"} which has no problem decoding and has 11 characters in the first element, which a minimal box would have.
https://github.com/jackc/pgx/issues/2086