Inserting into a master table with partitions does not return rows affected.

From: rverghese <riyav(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Inserting into a master table with partitions does not return rows affected.
Date: 2016-05-09 22:22:31
Message-ID: 1462832551784-5902708.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am moving towards a partitioned schema. I use a function to insert into the
table. If the INSERT fails because of duplicates I do an UPDATE. This works
fine currently on the non-partitioned table because I can use GET
DIAGNOSTICS to get the row count on the INSERT.

But when I use the Master table to insert into the partitions, GET
DIAGNOSTICS always returns 0. So there is no way of knowing whether a row
was inserted (I am catching the unique violation exception to do the
UPDATE).

What is a good alternative? We are on 9.4, so the UPSERT is not yet
available to me.
There should be some way to know if data was inserted into the partition.

Thanks
RV

--
View this message in context: http://postgresql.nabble.com/Inserting-into-a-master-table-with-partitions-does-not-return-rows-affected-tp5902708.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2016-05-10 02:43:53 Re: Using both ident and password in pg_hba.conf
Previous Message Tom Lane 2016-05-09 22:15:16 Re: Using both ident and password in pg_hba.conf