1

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?

1
  • None I know of, which is a pity. Commented Nov 5, 2015 at 3:50

1 Answer 1

1

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
2
  • no, this won't work if b is a partitioned table.
    – J-16 SDiZ
    Commented Nov 9, 2015 at 7:54
  • @J-16SDiZ Sure. If b is a partitioned table, there is possibly a trigger redirecting the INSERTs - 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 INSERTs and so on... Commented Nov 9, 2015 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.