Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 205AE1BB1A63 for ; Fri, 18 Nov 2011 16:52:49 -0400 (AST) Received: from ns2.gransy.com ([89.187.132.100] helo=elizabeth.gransy.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RRVQV-0008Ml-Go for pgsql-bugs@postgresql.org; Fri, 18 Nov 2011 20:52:49 +0000 Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id D974D15E4136; Fri, 18 Nov 2011 21:52:33 +0100 (CET) Received: from 85.160.32.227 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Fri, 18 Nov 2011 21:52:33 +0100 Message-ID: In-Reply-To: References: <201111181642.pAIGgaLY007885@wwwmaster.postgresql.org> <2e0d250ae01ece58a2c387f52f3121fc.squirrel@sq.gransy.com> Date: Fri, 18 Nov 2011 21:52:33 +0100 Subject: Re: BUG #6300: duplicate key value violates unique constraint From: "Tomas Vondra" To: tigran.mkrtchyan@desy.de Cc: "Tomas Vondra" , pgsql-bugs@postgresql.org User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 X-Priority: 3 (Normal) Importance: Normal Content-Transfer-Encoding: quoted-printable X-Archive-Number: 201111/138 X-Sequence-Number: 31733 On 18 Listopad 2011, 20:38, Tigran Mkrtchyan wrote: > On Fri, Nov 18, 2011 at 6:52 PM, Tomas Vondra wrote: >> On 18 Listopad 2011, 17:42, Tigran Mkrtchyan wrote: >>> >>> The following bug has been logged online: >>> >>> Bug reference: =C2=A0 =C2=A0 =C2=A06300 >>> Logged by: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Tigran Mkrtchyan >>> Email address: =C2=A0 =C2=A0 =C2=A0tigran.mkrtchyan@desy.de >>> PostgreSQL version: 9.0.4 >>> Operating system: =C2=A0 Linux x86_64 >>> Description: =C2=A0 =C2=A0 =C2=A0 =C2=A0duplicate key value violates = unique constraint >>> Details: >>> >>> Hi, >>> >>> our application uses PostgreSQL as a backend and heavily >>> relays on transactions. We never check constrains in our application = as >>> DB >>> does is better than we can an in an atomic way. This works very-very >>> good! >>> Nevertheless the logfiles are full of 'duplicate key value violates >>> unique >>> constraint'. I have two questions: >> >> If it's a question, then why have you submitted it as a bug? > > Then let me re-phrase it: > > I think it's a bug to log with level ERROR absolute valid SQL > statement. You have error code returned to the client to handle it. If > I want to log statements then I can turned that on. This is client > appication debuggging and to error handling. The SQL command may be syntactically correct, but breaking a UNIQUE constraint is an error condition and therefore it's handled like an error condition - the user receives an exception and a message with ERROR level is written to the log. If you don't want to see those messages in the log, there are ways to do that correctly - e.g. by using database sequences. I personally think tha= t an application that generates significant amount of "duplicate values" during normal operation is somehow broken. Anyway this definitely is not a bug, so if you want to discuss it further (and how to fix you application), use pgsql-general mailing list. Tomas