postgresql_16:8.8.2.5 FDW Routines for TRUNCATE
PostgreSQL 16 > Internals > Writing a Foreign Data Wrapper > Foreign Data Wrapper Callback Routines > FDW Routines for TRUNCATE
void ExecForeignTruncate(List *rels, DropBehavior behavior, bool restart_seqs); Truncate foreign tables. This function is called when (see postgresql_16:7.1.179) is executed on a foreign table. rels is a list of Relation data structures of foreign tables to truncate.
behavior is either DROP_RESTRICT or DROP_CASCADE indicating that the RESTRICT or CASCADE option was requested in the original TRUNCATE command, respectively.
If restart_seqs is true, the original TRUNCATE command requested the RESTART IDENTITY behavior, otherwise the CONTINUE IDENTITY behavior was requested.
Note that the ONLY options specified in the original TRUNCATE command are not passed to ExecForeignTruncate. This behavior is similar to the callback functions of SELECT, UPDATE and DELETE on a foreign table.
ExecForeignTruncate is invoked once per foreign server for which foreign tables are to be truncated. This means that all foreign tables included in rels must belong to the same server.
If the ExecForeignTruncate pointer is set to NULL, attempts to truncate foreign tables will fail with an error message.