Re: updating unique columns - Mailing list pgsql-bugs

From William ZHANG
Subject Re: updating unique columns
Date
Msg-id e5p20e$v1o$1@news.hub.org
Whole thread Raw
In response to  (claus.pruefer@webcodex.de)
List pgsql-bugs
""Greg Sabino Mullane"" <greg@turnstep.com>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> | UPDATE
> | orderby SET orderby = orderby +10
> | WHERE groupid = 1;
> | -> FAILS because of UNIQUE INDEX
>
> One workaround is to do it in two steps, assuming that
> orderby is > 0 for all rows you are changing:
>
> BEGIN;
> UPDATE mytable SET orderby = -orderby WHERE groupid = 1;
> UPDATE mytable SET orderby = -orderby+10 WHERE groupid = 1;
> COMMIT;

Should we invent something to defer the check of uniqueness
to the end of the SQL command?

Regards,
William ZHANG

pgsql-bugs by date:

Previous
From: "Stephen"
Date:
Subject: BUG #2462: pg_dump ftell mismatch error (cont'd)
Next
From: "Satya Prakash Tripathi"
Date:
Subject: BUG #2463: postgres server crashes on "select count(*) from table;"