| From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Atomicity? | 
| Date: | 2006-08-29 16:00:35 | 
| Message-ID: | 44F464A3.3010900@cox.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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-----
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ron Johnson | 2006-08-29 16:02:12 | Anonymous stored procedures | 
| Previous Message | Erik Jones | 2006-08-29 15:51:43 | Re: Confused on a some deadlocks occuring... |