jackc / pglogrepl

PostgreSQL logical replication library for Go.
MIT License
330 stars 62 forks source link

OldTuple in UpdateMessage is nil ! #48

Open seyedmo30 opened 1 year ago

seyedmo30 commented 1 year ago

i copy and run logical exampe code , but after update , OldTuple print nil

     case *pglogrepl.UpdateMessage:

            log.Printf("%+v  \n", logicalMsg.OldTuple)

print :

    {baseMessage:{msgType:85} RelationID:33230 OldTupleType:0 OldTuple:<nil> NewTuple:0xc0000650e0} 
ubombi commented 1 year ago

works as intended. @seyedmo30, You need to configure REPLICA IDENTITY for a table, to instruct PostgreSQL sending this data.

By default in OldTuple you will receive only primary key(s) and only if it was changed during update. Otherwise nil.

check this short explanation (promoting my project) and official docs.

if needed, example with index based replica identity.

seyedmo30 commented 1 year ago

@ubombi thanks a lot , it working