Re: Atomicity? - Mailing list pgsql-general

From Ron Johnson
Subject Re: Atomicity?
Date
Msg-id 44F464A3.3010900@cox.net
Whole thread Raw
In response to Atomicity?  (Naz Gassiep <naz@mira.net>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Naz Gassiep wrote:
> I am getting an error that I think I understand, but that I didn't think
> should happen.
>
> Below is the output from psql that I am getting to trigger this error.
> If the violation of the constraint really is being caused WITHIN the
> query, doesn't that violate the principle of atomicity? I.e., operations
> and entities should be considered a single entire construct rather than
> a collection of smaller, discrete parts. Or do I have my understanding
> all wrong?
>
> In any case, how do I get around this problem?
>
> conwatch=# UPDATE replies SET rgt = rgt + 2 WHERE postid = 18 AND rgt >=
> 11;

Another work-around would be a loop.

Pseudo-code:
  BEGIN
      FOR :X IN
          SELECT RGT, REPLYID
          FROM REPLIES
          WHERE POSTID = 18
            AND RGT >= 11
      DO
          UPDATE REPLIES
          SET RGT = RGT + 2
          WHERE REPLIYID = :X.REPLYID;
      END FOR;
  END;

- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE9GSjS9HxQb37XmcRArqiAJ90r+NPOzs312kav/682DiH16YBzgCgriDt
pCy0mK/74NvnHim5uaLeYrU=
=hJ1s
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Erik Jones
Date:
Subject: Re: Confused on a some deadlocks occuring...
Next
From: Ron Johnson
Date:
Subject: Anonymous stored procedures