Partitoning not working with RETURNING and INSERT/UPDATE - Mailing list pgsql-sql

From Frank Jördens
Subject Partitoning not working with RETURNING and INSERT/UPDATE
Date
Msg-id 7d10d2df0902101955r341b0c25vf2f40055239aca36@mail.gmail.com
Whole thread Raw
List pgsql-sql
I created a partitioned table and am now finding that it won't (at
least not trivially) support the RETURNING syntax with insert or
update:

If I take the trigger approach (as in the online manual), allowing for
RETURNING to work means that I have to let the BEFORE INSERT trigger
return the row rather than NULL, which means it'll get inserted into
the base table as well as the partition, and I'll end up with 2 rows
per insert.

If I try to define rules (very much like the example in the docs), I get:

-- snip --
woome=# INSERT INTO "userstats_profileview" ("viewer_id", "viewed_id")
VALUES (94039, 60701) RETURNING id;
ERROR:  cannot perform INSERT RETURNING on relation "userstats_profileview"
HINT:  You need an unconditional ON INSERT DO INSTEAD rule with a
RETURNING clause.
-- snap --

Is there any way to make this work?

Regards,

Frank


pgsql-sql by date:

Previous
From: "Bart van Houdt"
Date:
Subject: RE: [SQL] Grass Root Protectionism
Next
From: Andreas
Date:
Subject: Funtion to clean up strings?