Re: serialization errors when inserting new records - Mailing list pgsql-general

From Ralph van Etten
Subject Re: serialization errors when inserting new records
Date
Msg-id Pine.LNX.4.44.0501241153170.2282-100000@exp-toy.et10.loc
Whole thread Raw
In response to Re: serialization errors when inserting new records  (William Yu <wyu@talisys.com>)
List pgsql-general
On Mon, 24 Jan 2005, William Yu wrote:

> If you absolutely need the display field to be unique and it has to be a
> sequence starting from 1 -- it's simplicity itself. Use the
> serialization errors to your advantage. If you try to insert a record
> and you get a dupe key violation, just increment your seq counter by 1
> and try again. Keep trying until you succeed. No need to lock the tables
> at all.

Just trial and error ?
I don't think its a very good solution. Then you have to figure out
exactly which error it is and which column caused the violation. (How ? By
parsing the error string ???)
And if the correct error was returned you retry the query... But how many
times ? Just once ? or a 1000 times ?
I'm sorry but I think this solution is just a Q&D hack.


pgsql-general by date:

Previous
From: Stefan Sturm
Date:
Subject: Savepoint Problem
Next
From: Postgres General
Date:
Subject: disable trigger from transaction