Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key

From: Matti Aarnio <matti(dot)aarnio(at)methics(dot)fi>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key
Date: 2013-02-11 16:13:08
Message-ID: 51191894.4030703@methics.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 02/11/2013 05:34 PM, Matti Aarnio wrote:
> On 02/11/2013 02:11 PM, Heikki Linnakangas wrote:
>> Works for me:
>>
>> postgres=# do $$
>> begin
>> insert into example values ('2001-01-01', 'foo', 'bar');
>> insert into example values ('2001-01-01', 'foo', 'bar');
>> exception
>> when others then raise notice 'caught %', sqlstate;
>> end;
>> $$;
>> NOTICE: caught 23505
>> DO
>>
>> How exactly are you seeing the wrong status code? What client are you
>> using?
> I am calling PostgreSQL JDBC driver through Tomcat 7 Pool manager..
> Which could of course scramble the status code report (unlikely, but
> possible..)
>
> The driver binary I was using is: postgresql-9.0-801.jdbc3.jar
>
> Switching to jdbc4 driver binary of otherwise same version makes no
> difference.
> Neither switching to latest version makes any difference:
> postgresql-9.2-1002.jdbc4.jar

Catching the SQLException, and printing the backtrace shows:

2013-02-11 17:47:08,559 [http-bio-8080-exec-7] ERROR fi.methics.ExampleDatabase - Insert into example at jdbc:kiuru:pool:example resulted unexpected SQL Exception code: 0 ERROR: duplicate key value violates unique constraint "replay_attack_detector_pkey"
Detail: Key (a, b, c)=(a, b, 2013-02-11 17:47:08.163) already exists.
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "example_pkey"
Detail: Key (a, b, c)=(a, b, 2013-02-11 17:47:08.163) already exists.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:235)
at $Proxy7.executeUpdate(Unknown Source)
at fi.methics.ExampleDatabase.exampleInsert(ExampleDatabase.java:123)
....

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2013-02-11 17:52:57 Re: BUG #7865: Unexpected error code on insert of duplicate to composite primary key
Previous Message michele.baravalle 2013-02-11 16:09:44 BUG #7867: Similarity function fails