(These are some notes I took while studying Citus code, so it is probably more detail oriented than higher picture oriented).
CopyToExistingShards() uses the
postgres/src/include/commands/copy.h API to read tuples:
and it uses the
CitusCopyDestReceiver API to write tuples.
CitusCopyDestReceiver is a specialization of postgres’ DataReceiver, which contains the following methods:
rShutdown: per-executor-run initialization and shutdown
rDestroy: destroy the object itself.
receiveSlot: called for each tuple to be output.