*** a/contrib/postgres_fdw/deparse.c --- b/contrib/postgres_fdw/deparse.c *************** *** 1078,1085 **** deparseDeleteSql(StringInfo buf, PlannerInfo *root, deparseRelation(buf, rel); appendStringInfoString(buf, " WHERE ctid = $1"); ! deparseReturningList(buf, root, rtindex, rel, ! rel->trigdesc && rel->trigdesc->trig_delete_after_row, returningList, retrieved_attrs); } --- 1078,1085 ---- deparseRelation(buf, rel); appendStringInfoString(buf, " WHERE ctid = $1"); ! /* No need to retrieve columns for AFTER ROW DELETE triggers */ ! deparseReturningList(buf, root, rtindex, rel, false, returningList, retrieved_attrs); } *** a/doc/src/sgml/fdwhandler.sgml --- b/doc/src/sgml/fdwhandler.sgml *************** *** 606,613 **** ExecForeignDelete (EState *estate, The data in the returned slot is used only if the DELETE ! query has a RETURNING clause or the foreign table has ! an AFTER ROW trigger. Triggers require all columns, but the FDW could choose to optimize away returning some or all columns depending on the contents of the RETURNING clause. Regardless, some slot must be returned to indicate success, or the query's reported row --- 606,614 ---- The data in the returned slot is used only if the DELETE ! query has a RETURNING clause. (Note that the data is not ! referenced by AFTER ROW triggers on the foreign table in ! the DELETE case.) The FDW could choose to optimize away returning some or all columns depending on the contents of the RETURNING clause. Regardless, some slot must be returned to indicate success, or the query's reported row