Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-09 Thread Tom Lane
"Daniel Verite" writes: > Tom Lane wrote: >> 1. Performance. The cost of #2 is very large, and the number of cases >> where you actually need it is not. > Per Dean's explanation upthread, It looks like an additional cost for #2 > would occur mostly when temporary conflicts occur, that is,

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-09 Thread Daniel Verite
Tom Lane wrote: > "Daniel Verite" writes: > > But still I wonder why there is that difference in behavior between NON > > DEFERRABLE and DEFERRABLE INITIALLY IMMEDIATE, when the unique constraint > > doesn't get deferred by using SET CONSTRAINTS. > > In the first case, we get the "after e

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-06 Thread Tom Lane
"Daniel Verite" writes: > But still I wonder why there is that difference in behavior between NON > DEFERRABLE and DEFERRABLE INITIALLY IMMEDIATE, when the unique constraint > doesn't get deferred by using SET CONSTRAINTS. > In the first case, we get the "after each row" behavior with the pk=pk+1

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-06 Thread Dean Rasheed
2010/1/6 Daniel Verite : >        Dean Rasheed wrote: > >> So there is quite a bit of flexibility - you may choose to have the >> constraint checked at any of these times: >>  - after each row (the default for NON DEFERRABLE constraints) >>  - after each statement (DEFERRABLE [INITIALLY IMMEDIATE])

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-06 Thread Dean Rasheed
2010/1/5 Roman Neuhauser : > # jayadevan.maym...@ibsplc.com / 2010-01-04 10:03:29 +0530: >> This seems to work.. >> UPDATE x  set i=i+1 >> from  (select i as m from x order by m desc) y   where x.i = y.m >> Jayadevan > > Thanks, that nicely achieves the illusion of atomic immediate checking. > > --

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-06 Thread Daniel Verite
Dean Rasheed wrote: > So there is quite a bit of flexibility - you may choose to have the > constraint checked at any of these times: > - after each row (the default for NON DEFERRABLE constraints) > - after each statement (DEFERRABLE [INITIALLY IMMEDIATE]) > - at the end of the transac

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-05 Thread Roman Neuhauser
# jayadevan.maym...@ibsplc.com / 2010-01-04 10:03:29 +0530: > From: neuhauser+pgsql-general#postgresql@sigpipe.cz > > > > this fails with "duplicate key value": > > > > CREATE TABLE x ( > > i INT NOT NULL UNIQUE > > ); > > INSERT INTO x (i) VALUES (1), (2), (3); > > UP

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-05 Thread Dean Rasheed
2010/1/4 Daniel Verite : >        David Fetter wrote: > >> The DEFERRED uniqueness constraints in 8.5alpha3 fix this problem > > That fix has a drawback: when the unique constraint is violated, the rest of > the transaction runs with data that is somehow corrupted, with duplicate > values being vis

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-04 Thread Daniel Verite
David Fetter wrote: > The DEFERRED uniqueness constraints in 8.5alpha3 fix this problem That fix has a drawback: when the unique constraint is violated, the rest of the transaction runs with data that is somehow corrupted, with duplicate values being visible. It may be uneasy to predict i

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-03 Thread Jayadevan M
Hi, This seems to work.. UPDATE x set i=i+1 from (select i as m from x order by m desc) y where x.i = y.m Jayadevan From: neuhauser+pgsql-general#postgresql@sigpipe.cz To: pgsql-general@postgresql.org Date: 12/31/2009 09:15 PM Subject:[GENERAL] set-level update fails

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-03 Thread David Fetter
On Sun, Jan 03, 2010 at 10:16:10AM +0100, Roman Neuhauser wrote: > # scott.marl...@gmail.com / 2010-01-02 11:23:24 -0700: > > On Sat, Jan 2, 2010 at 1:40 AM, Roman Neuhauser > > wrote: > > > # da...@fetter.org / 2009-12-31 08:04:58 -0800: > > >> On Thu, Dec 31, 2009 at 10:52:20AM +0100, > > >> n

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-03 Thread Roman Neuhauser
# scott.marl...@gmail.com / 2010-01-02 11:23:24 -0700: > On Sat, Jan 2, 2010 at 1:40 AM, Roman Neuhauser wrote: > > # da...@fetter.org / 2009-12-31 08:04:58 -0800: > >> On Thu, Dec 31, 2009 at 10:52:20AM +0100, > >> neuhauser+pgsql-general#postgresql@sigpipe.cz wrote: > >> > Hello, > >> > > >

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-02 Thread Scott Marlowe
On Sat, Jan 2, 2010 at 1:40 AM, Roman Neuhauser wrote: > # da...@fetter.org / 2009-12-31 08:04:58 -0800: >> On Thu, Dec 31, 2009 at 10:52:20AM +0100, >> neuhauser+pgsql-general#postgresql@sigpipe.cz wrote: >> > Hello, >> > >> > this fails with "duplicate key value": >> > >> >     CREATE TABLE

Re: [GENERAL] set-level update fails with unique constraint violation

2010-01-02 Thread Roman Neuhauser
# da...@fetter.org / 2009-12-31 08:04:58 -0800: > On Thu, Dec 31, 2009 at 10:52:20AM +0100, > neuhauser+pgsql-general#postgresql@sigpipe.cz wrote: > > Hello, > > > > this fails with "duplicate key value": > > > > CREATE TABLE x ( > > i INT NOT NULL UNIQUE > > ); > > INSERT

Re: [GENERAL] set-level update fails with unique constraint violation

2009-12-31 Thread David Fetter
On Thu, Dec 31, 2009 at 10:52:20AM +0100, neuhauser+pgsql-general#postgresql@sigpipe.cz wrote: > Hello, > > this fails with "duplicate key value": > > CREATE TABLE x ( > i INT NOT NULL UNIQUE > ); > INSERT INTO x (i) VALUES (1), (2), (3); > UPDATE x SET i = i + 1; > >

Re: [GENERAL] set-level update fails with unique constraint violation

2009-12-31 Thread Magnus Hagander
2009/12/31 neuhauser+pgsql-general#postgresql.org : > Hello, > > this fails with "duplicate key value": > >    CREATE TABLE x ( >      i INT NOT NULL UNIQUE >    ); >    INSERT INTO x (i) VALUES (1), (2), (3); >    UPDATE x SET i = i + 1; > > are there any plans to make this work? Sure. 8.5 (curre

[GENERAL] set-level update fails with unique constraint violation

2009-12-31 Thread neuhauser+pgsql-general#postgresql . org
Hello, this fails with "duplicate key value": CREATE TABLE x ( i INT NOT NULL UNIQUE ); INSERT INTO x (i) VALUES (1), (2), (3); UPDATE x SET i = i + 1; are there any plans to make this work? -- Roman Neuhauser -- Sent via pgsql-general mailing list (pgsql-general@postgr