Re: ERROR: Cannot insert a duplicate key into a unique

From: Rachit Siamwalla <rachit(at)ensim(dot)com>
To: "'Christopher Kings-Lynne'" <chriskl(at)familyhealth(dot)com(dot)au>, Haller Christoph <ch(at)rodos(dot)fzk(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ERROR: Cannot insert a duplicate key into a unique
Date: 2001-09-14 00:25:59
Message-ID: 9AC41B8C4781464695BB013F106FCA3102900C57@nasdaq.ms.ensim.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Count me in for error codes. You can just see part of the code i'm using to
deal with the problem (some of the error messages changed from 7.0 to 7.1 --
i had to fix that):

def parseError(self, errval):
# first compile all the exceptions. Ideally we don't have to compile
# all of them first, but this makes the code that much readable, and
# speed is not important in the error case.
re_refInt = re.compile('.*referential integrity.*')
re_dupKey = re.compile('.*duplicate key.*')
re_nullAttr = re.compile('.*Fail to add null value in not null
attribute (.*)')
re_nonInt = re.compile('.*pg_atoi: error in "(.*)": can\'t parse.*')
re_nonBool = re.compile('.*Bad boolean external representation
\'(.*)\'')
re_nonIP = re.compile('.*invalid INET value.*')
re_nonTimestamp = re.compile('.*Bad timestamp external
representation \'(.*)\'')
re_invalidAttribute = re.compile('.*Relation \'(.*)\' does not have
attribute \'(.*)\'.*')
re_deadlockDetected = re.compile('.*Deadlock detected.*')

# various errors captured from posgres
# ERROR: Relation 'users' does not have attribute 'blah'
# ERROR: <unnamed> referential integrity violation - key in
managedservers stillreferenced from managedserverstatus
#
# ERROR: Bad boolean external representation '3.4.5.6'
# ERROR: invalid INET value '3456' ## for ip
# ERROR: ExecAppend: Fail to add null value in not null attribute
mystr
# ERROR: Relation 'users' does not have attribute 'blah'
# pg_atoi: error in "hello": can't parse "hello"
# ERROR: Bad timestamp external representation 'fdsa'
# ERROR: Deadlock detected.

-----Original Message-----
From: Christopher Kings-Lynne [mailto:chriskl(at)familyhealth(dot)com(dot)au]
Sent: Thursday, September 13, 2001 3:31 AM
To: Haller Christoph; pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] ERROR: Cannot insert a duplicate key into a
unique index

In our PHP app, we are also forced to parse error messages to get that kind
of information. Register my vote for error codes (Tom Lane style...)

Chris

> -----Original Message-----
> From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)org]On Behalf Of Haller Christoph
> Sent: Thursday, 13 September 2001 7:18 PM
> To: pgsql-hackers(at)postgresql(dot)org
> Subject: [HACKERS] ERROR: Cannot insert a duplicate key into a unique
> index
>
>
> [HACKERS] ERROR: Cannot insert a duplicate key into a unique index
>
> I'm working on a C code application using loads of
> insert commands.
> It is essential to distinguish between an error
> coming from a misformed command or other fatal
> reasons and a duplicate key.
> In either case, the PQresultStatus() returns
> PGRES_FATAL_ERROR
> I can check PQresultErrorMessage() for the
> error message above, but then I have to rely
> on this string never be changed.
> This is no good programming style.
> Does anybody have another, better idea or is
> there at least a header file available, where
> all the error messages can be found?
>
> Regards, Christoph
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Browse pgsql-hackers by date

  From Date Subject
Next Message peace_flower 2001-09-14 01:57:34 Where do they find the time??? Great Bridge closed now!!!??
Previous Message Peter Eisentraut 2001-09-13 23:47:44 Proposed installation dir change