"duplicate key value": version 8.4 vs 8.1

Lists: pgsql-novice
From: mountain oaf <mountainoaf(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-20 21:59:50
Message-ID: AANLkTinFN4cT+D0jy4RaizPE4h5k82g=+jJg2MWeaxsA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hello,

I am a Postgres newbie using a C program to add records to a Postgres database.

When I run it against an 8.4.4 version of Postgres, data inserted into
a table which violate an unique index are reported back to the program
via sqlca.sqlcode as -403 ('duplicate key value violates unique
constraint "my_index"').

However, when I run the same program against an 8.1.2 database, the
error isn't trapped. I'm explicitly looking for a -403 code via
sqlca.sqlcode so am assuming that the error code is different in this
version of the database.

I've had a look on Teh Interwebs around to try and find out what the
equivalent code is for 8.1.2 but have had no success so far. Could
anyone point me in the right direction, please?

Thanks in advance for any assistance,

Mark


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mountain oaf <mountainoaf(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-20 22:25:51
Message-ID: 28237.1287613551@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

mountain oaf <mountainoaf(at)gmail(dot)com> writes:
> When I run it against an 8.4.4 version of Postgres, data inserted into
> a table which violate an unique index are reported back to the program
> via sqlca.sqlcode as -403 ('duplicate key value violates unique
> constraint "my_index"').

> However, when I run the same program against an 8.1.2 database, the
> error isn't trapped. I'm explicitly looking for a -403 code via
> sqlca.sqlcode so am assuming that the error code is different in this
> version of the database.

AFAICS the ecpg code around that hasn't changed since 8.1, so I think
your assumption is in error. You might try looking into the server
log to see what it thinks is happening.

regards, tom lane


From: mountain oaf <mountainoaf(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-21 00:35:13
Message-ID: AANLkTimHQ54aYHL+KyxNEFmZhBQab6UCu9MSBHjRhEv2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> AFAICS the ecpg code around that hasn't changed since 8.1, so I think
> your assumption is in error.  You might try looking into the server
> log to see what it thinks is happening.

I've just done a test on the 8.1.2 database where I purposely added a
duplicate record and the sqlca.sqlcode returned a -400 error.

Mark


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mountain oaf <mountainoaf(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-21 02:36:11
Message-ID: 9996.1287628571@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

mountain oaf <mountainoaf(at)gmail(dot)com> writes:
>> AFAICS the ecpg code around that hasn't changed since 8.1, so I think
>> your assumption is in error. You might try looking into the server
>> log to see what it thinks is happening.

> I've just done a test on the 8.1.2 database where I purposely added a
> duplicate record and the sqlca.sqlcode returned a -400 error.

So, the server is returning some error code, but it's not 23505.
Again, I'd suggest looking at the server log to see what it thinks
is happening. My bet is that you're trying to use some feature
that doesn't exist in 8.1 ...

regards, tom lane


From: mountain oaf <mountainoaf(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-21 02:58:57
Message-ID: AANLkTi=K36vRSBrJtTU=08_Af3O_4aVdNEUqtUSoP=UH@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> So, the server is returning some error code, but it's not 23505.
> Again, I'd suggest looking at the server log to see what it thinks
> is happening.  My bet is that you're trying to use some feature
> that doesn't exist in 8.1 ...

Not sure that I can gain access to the server logs, but thanks for the
suggestion.

I'm not doing anything arcane - as described, I a, just trying to
insert a record which breaks a unique index's integrity and using
sqlca.sqlcode to report the result return when doing so.

Mark


From: Kenneth Marshall <ktm(at)rice(dot)edu>
To: mountain oaf <mountainoaf(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-21 12:53:23
Message-ID: 20101021125323.GP4993@aart.is.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Oct 21, 2010 at 10:59:50AM +1300, mountain oaf wrote:
> Hello,
>
> I am a Postgres newbie using a C program to add records to a Postgres database.
>
> When I run it against an 8.4.4 version of Postgres, data inserted into
> a table which violate an unique index are reported back to the program
> via sqlca.sqlcode as -403 ('duplicate key value violates unique
> constraint "my_index"').
>
> However, when I run the same program against an 8.1.2 database, the
> error isn't trapped. I'm explicitly looking for a -403 code via
> sqlca.sqlcode so am assuming that the error code is different in this
> version of the database.
>
> I've had a look on Teh Interwebs around to try and find out what the
> equivalent code is for 8.1.2 but have had no success so far. Could
> anyone point me in the right direction, please?
>
> Thanks in advance for any assistance,
>
> Mark
>

Hi Mark,

You may want to try the latest version of 8.1, 8.1.22 or 20 bugfix
releases more current. As has been oft repeated here, they do not
release them for fun. They fix real and critical bugs.

Cheers,
Ken


From: mountain oaf <mountainoaf(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-21 20:29:46
Message-ID: AANLkTi=BNZOG53BH9MPLJwNyGr3LUq2sF28yXuZA_owA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> You may want to try the latest version of 8.1, 8.1.22 or 20 bugfix
> releases more current. As has been oft repeated here, they do not
> release them for fun. They fix real and critical bugs.

Thanks for the thought. Unfortunately this is not an option as it is
running a client's system at a remote site.

Mark


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mountain oaf <mountainoaf(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-21 20:55:13
Message-ID: 6278.1287694513@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

mountain oaf <mountainoaf(at)gmail(dot)com> writes:
>> You may want to try the latest version of 8.1, 8.1.22 or 20 bugfix
>> releases more current. As has been oft repeated here, they do not
>> release them for fun. They fix real and critical bugs.

> Thanks for the thought. Unfortunately this is not an option as it is
> running a client's system at a remote site.

You're being very irresponsible to your client if you're not leaning on
them, *hard*, to run a less obsolete version.

Or are you hoping to collect additional consulting fees to help them get
out of trouble when that old version eats their data?

regards, tom lane


From: Frank Bax <fbax(at)sympatico(dot)ca>
To: PostgreSQL List - Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: "duplicate key value": version 8.4 vs 8.1
Date: 2010-10-22 11:24:33
Message-ID: 4CC17471.8050801@sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

mountain oaf wrote:
>> You may want to try the latest version of 8.1, 8.1.22 or 20 bugfix
>> releases more current. As has been oft repeated here, they do not
>> release them for fun. They fix real and critical bugs.
>
> Thanks for the thought. Unfortunately this is not an option as it is
> running a client's system at a remote site.

Upgrades do not require on-site access.

Every production system should have a backup; so I keep a second server
on standby. For upgrades; I upgrade the backup system; test my apps on
the upgraded system; then with only a few minutes downtime I resync the
data and make backup hardware productions server. Then I upgrade the
original system; test it and migrate back again.

This process tests the disaster recovery process with every upgrade.

This process only requires on-site visit when upgrading the OS; never
packages like Postgresql.