In a INSERT trigger based table partition, insert always give "0 row affected". I think this problem is well know, it is even in the todo.
Is there any workarounds for this issue in 9.4?
In a INSERT trigger based table partition, insert always give "0 row affected". I think this problem is well know, it is even in the todo.
Is there any workarounds for this issue in 9.4?
You can try to catch the number of inserted rows using GET DIAGNOSTICS
and then raise a notice/warning/whatever you prefer. Here is a small illustration:
DO $$
DECLARE cnt integer;
BEGIN
INSERT INTO b SELECT i FROM generate_series(1,9) t(i);
GET DIAGNOSTICS cnt := ROW_COUNT;
RAISE WARNING '% row(s) affected', cnt;
END;
$$;
-- gives:
WARNING: 9 row(s) affected
DO
b
is a partitioned table, there is possibly a trigger redirecting the INSERT
s - this is what you state in your question, too. This is an example for that trigger. If b
itself is a partitioned table, then you have subpartitions, which you should have mentioned in your question. But then there must be a trigger on b
to redirect INSERT
s and so on...
Commented
Nov 9, 2015 at 8:26