peerdb icon indicating copy to clipboard operation
peerdb copied to clipboard

CDC for PG box[] type is not working

Open ilidemi opened this issue 6 months ago • 1 comments

Steps to reproduce:

  1. create table test_box (id serial primary key, b box[]);
  2. Create a mirror with test_box as a source
  3. insert into test_box(b) values(array['((3,3),(1,1))','((6,6),(4,4))']::box[]);
  4. 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.

ilidemi avatar Jun 12 '25 06:06 ilidemi

https://github.com/jackc/pgx/issues/2086

serprex avatar Jun 23 '25 22:06 serprex