Wednesday, March 16. 2011Upserting via Writeable CTETrackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
With a new implementation of SERIALIZABLE level, there should not be a race condition.
Our SERIALIZABLE implementation just throws an error here; a UNIQUE index would do the same trick.
CREATE RULE insert_ignore AS
ON INSERT TO actor WHERE (EXISTS (SELECT true FROM actor as ul WHERE ( ul.first_name,ul.last_name) = (NEW.first_name, NEW.last_name))) DO INSTEAD NOTHING; and you can just use plain INSERT !
You really, REALLY should not use rules for anything like this. While in this case the rule might accidentally work (sans the race condition), it will fail horribly if you attempt to implement the UPSERT idea in the original post.
|
QuicksearchHi! I'm Robert Treat, COO of OmniTI, perhaps the best internet technology consulting company on the planet. A veteran open source developer and advocate, I have been recognized as a major contributor to the PostgreSQL project, and can often be found speaking on open source, databases, and large scale web operations. Upcoming Events
PGDay DC 2012 March 30th At Reston, VirginiaPGCon 2012 May 15th - 18th At Ottawa, CanadaVelocity 2012 June 25th - 27th At Santa Clara, CaliforniaSurge 2012 September At Baltimore, MarylandRecent MusingsI built a node site
Tuesday Intrest free (technical) debt is risky Monday Monitoring for "E-Tailers" Wednesday You were saying? about Intrest free (technical) debt is risky Tue, 07.02.2012 05:16 Hi Robert, Tanks for your t houghtful interest in my lates t post. You are absolutely right about the underlyi [...] about Checkpoints, Buffers, and Graphs Sun, 27.11.2011 15:42 And the slides are up at http: //www.2ndquadrant.com/en/talks / Blog Administration |