Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> writes:
> => with t as (delete from foo returning *)
> -> insert into bar
> -> select * from t;
> INSERT 0 2
> It correctly reports 2 affected rows (one deleted and one inserted), but
> is this the answer we want?
No. The returned tag should consider only the top-level operation,
not what happened inside any CTEs.
regards, tom lane