Re: [GENERAL] Update violating constraint

2007-05-04 Thread Bruce Momjian
Alvaro Herrera wrote: > Alban Hertroys wrote: > > Richard Huxton wrote: > > > Alban Hertroys wrote: > > >> Naz Gassiep wrote: > > >>> Hi, > > >>> I'm trying to do an update on a table that has a unique constraint > > >>> on the field, I need to update the table by setting field = field+1 > > >

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Alvaro Herrera
Alban Hertroys wrote: > Richard Huxton wrote: > > Alban Hertroys wrote: > >> Naz Gassiep wrote: > >>> Hi, > >>> I'm trying to do an update on a table that has a unique constraint > >>> on the field, I need to update the table by setting field = field+1 > > > >> I think you're looking for defe

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Alban Hertroys
Richard Huxton wrote: > Alban Hertroys wrote: >> Naz Gassiep wrote: >>> Hi, >>> I'm trying to do an update on a table that has a unique constraint >>> on the field, I need to update the table by setting field = field+1 > >> I think you're looking for deferrable constraints; see: >> >> http://

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Csaba Nagy
> If you are updating a large portion of your tree, you will probably want to > throw in a vacuum in > between the two updates. This should reduce the bloat caused by dead tuples > in both your index > and table. ... but that will only work if you can commit the first set of changes before you

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Richard Broersma Jr
> > update foo > > set field = -1 * (field + 1); > > update foo > > set field = -1 * field > > where field < 0; > > > Yes, in fact I actually use option one already in the handling of sql > trees, so I'm annoyed with myself for not figuring that out. I don't > know why you'd ever use your second op

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Michael Glaesemann
On May 2, 2007, at 23:36 , Naz Gassiep wrote: I don't know why you'd ever use your second option ever, as it virtually guarantees problems at a random point in your DB's growth. There may be cases where the values are not all positive so you can't use the -1 * technique, but the offset will

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Richard Huxton
Alban Hertroys wrote: Naz Gassiep wrote: Hi, I'm trying to do an update on a table that has a unique constraint on the field, I need to update the table by setting field = field+1 I think you're looking for deferrable constraints; see: http://www.postgresql.org/docs/8.2/static/sql-set-c

Re: [GENERAL] Update violating constraint

2007-05-03 Thread Alban Hertroys
Naz Gassiep wrote: > Hi, > I'm trying to do an update on a table that has a unique constraint > on the field, I need to update the table by setting field = field+1 > however if this does not perform the updates on the table in a proper > order (from last to first) then the update will cause a

Re: [GENERAL] Update violating constraint

2007-05-02 Thread Naz Gassiep
Michael Glaesemann wrote: > > On May 2, 2007, at 23:01 , Naz Gassiep wrote: > >> I'm trying to do an update on a table that has a unique constraint >> on the field, I need to update the table by setting field = field+1 >> however if this does not perform the updates on the table in a proper >>

Re: [GENERAL] Update violating constraint

2007-05-02 Thread Michael Glaesemann
On May 2, 2007, at 23:01 , Naz Gassiep wrote: I'm trying to do an update on a table that has a unique constraint on the field, I need to update the table by setting field = field+1 however if this does not perform the updates on the table in a proper order (from last to first) then the upda