From: Stephen Frost <sfrost@snowman.net>
To: Glenn Maynard <glenn@zewt.org>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Bit by "commands ignored until end of transaction block" again
Date: Thu, 23 Jul 2009 06:55:16 -0400
Message-ID: <20090723105516.GJ23840@tamriel.snowman.net> (raw)
In-Reply-To: <bd36f99e0907222304x38cfa50bkeba19f7c9b2694@mail.gmail.com>
References: <bd36f99e0907222158k6b4b3a0al65766c0d9c4906cf@mail.gmail.com>
<4A67F5B6.4080409@archonet.com>
<bd36f99e0907222304x38cfa50bkeba19f7c9b2694@mail.gmail.com>
* Glenn Maynard (glenn@zewt.org) wrote:
> > The ORM can't control transactions, can't call functions or can't set
> > savepoints?
>
> It can't write the necessary SQL to say "insert this unless it already
> exists", namely:
If it can't cleanly handle failure cases like this one, then I think
your issue is with your ORM and not with PG. An INSERT failing on a
uniqueness violation is actually a rather big deal in a relational
database and not erroring on it goes quite against data integrity
considerations.
If your ORM could call a function instead, you could handle the insert
and error-check in the function, to make up for the lack of intelligence
in the ORM. Another option would be to have a 'fake' table, which has
no rows in it and just has an 'ON INSERT' trigger that calls a function
to handle this. That could also be a view with a do-instead rule, if
the ORM has to query the same table.
I would think the time would better be spent fixing the ORM though.
Thanks,
Stephen
Attachments:
signature.asc (application/pgp-signature, 196B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sfrost@snowman.net, glenn@zewt.org, dev@archonet.com
Subject: Re: Bit by "commands ignored until end of transaction block" again
In-Reply-To: <20090723105516.GJ23840@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox