ability to return number of rows inserted into child partition tables request - Mailing list pgsql-general

From Roger Pack
Subject ability to return number of rows inserted into child partition tables request
Date
Msg-id CAL1QdWdAq44onx=Vcvz0GSZf668jokZt2hs-S+0wrLpkvrCA3Q@mail.gmail.com
Whole thread Raw
List pgsql-general
Hello.

I was trying to get postgres to return the "correct" number of rows inserted for batch inserts to a partitioned table [using the triggers as suggested here http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html results in it always returning 0 by default].

What I ideally wanted it to do is to be able to insert into just the child partitions, and return number of rows updated.

It seems the state of the art is either to return the NEW row from the insert trigger [which causes it to also be saved to the parent master table], then define an extra trigger to remove the parent table.  So 2 inserts and 1 delete for an insert. [1]

Or you can use an unconditional rule and it will return the number of rows updated [however, in this case, since we're using partitioning, we I think need multiple rules, once for each child table].  

It is possible for a view to use a trigger and still return the number of rows updated, which provides another work around. (See bottom of [1]).

Is there some more elegant way here?  It seems odd that partitioned tables basically cannot, without a *lot* of massaging, return number of rows updated, am I missing something or do I understand ok? [Today this requires people to put in lots of work arounds, like *not* checking for number of rows returned for batch inserts, etc.-- potentially dangerous as well]

Is there, for instance, some work around, like a way to manually cause the count of the number of rows affected by the command to be incremented here?  Or possibly conditional rules could be made possible to return the output string with number of rows affected (feature request)?


Thanks!
-roger-


PS if no response I'll forward this on to pghackers.

pgsql-general by date:

Previous
From: Dev Kumkar
Date:
Subject: Re: [SQL] pg_multixact issues
Next
From: Jonathan Vanasco
Date:
Subject: improving speed of query that uses a multi-column "filter" ?