pglogrepl icon indicating copy to clipboard operation
pglogrepl copied to clipboard

OldTuple in UpdateMessage is nil !

Open seyedmo30 opened this issue 3 years ago • 2 comments

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} 

seyedmo30 avatar Jan 28 '23 06:01 seyedmo30

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.

ubombi avatar Jan 31 '23 11:01 ubombi

@ubombi thanks a lot , it working

seyedmo30 avatar Feb 12 '23 08:02 seyedmo30