Skip to content

Instantly share code, notes, and snippets.

View macfanatic's full-sized avatar

Matthew Millsaps-Brewer macfanatic

View GitHub Profile
@copiousfreetime
copiousfreetime / gist:59067
Created February 5, 2009 22:34
Postgres Partitioning with RETURNING on insert
-- A method to have RETURNING work if you are partitioning data using trigger.
-- The method to this madness is:
--
-- 1) Use the normal trigger mechanism to insert the data into the child tables, but
-- Instead of the trigger function returning NULL so that the row does not get⋅
-- inserted into the master table, it returns the row inserted into the child
-- table
--
-- 2) Postgres will insert the new row from the trigger into the master table
--