Re: [JDBC] Using \errverbose through JDBC - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: [JDBC] Using \errverbose through JDBC
Date
Msg-id 7868.1485962641@sss.pgh.pa.us
Whole thread Raw
In response to Re: [JDBC] Using \errverbose through JDBC  (Jorge Solórzano <jorsol@gmail.com>)
Responses Re: [JDBC] Using \errverbose through JDBC  (Thomas Kellerer <spam_eater@gmx.net>)
Re: Using \errverbose through JDBC  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-jdbc
=?UTF-8?Q?Jorge_Sol=C3=B3rzano?= <jorsol@gmail.com> writes:
> AFAICT this is a libpq functionality, and since the JDBC driver is not
> libpq based then it can't use that functionality.

> And it doesn't looks to be that useful for JDBC users:

It's not really useful for programs, I think.  ISTM a program would prefer
to have access to the individual fields of the error message.  There
definitely are fields in there that are of interest, for some messages:

regression=# create table t1 (f1 int primary key);
CREATE TABLE
regression=# create table t2 (f2 int references t1);
CREATE TABLE
regression=# insert into t2 values(11);
ERROR:  insert or update on table "t2" violates foreign key constraint "t2_f2_fkey"
DETAIL:  Key (f2)=(11) is not present in table "t1".
regression=# \errverbose
ERROR:  23503: insert or update on table "t2" violates foreign key constraint "t2_f2_fkey"
DETAIL:  Key (f2)=(11) is not present in table "t1".
SCHEMA NAME:  public
TABLE NAME:  t2
CONSTRAINT NAME:  t2_f2_fkey
LOCATION:  ri_ReportViolation, ri_triggers.c:3324

So really what would be appropriate for JDBC to provide, IMO, is
some equivalent of libpq's PQresultErrorField().  Perhaps that's
already there.

            regards, tom lane


pgsql-jdbc by date:

Previous
From: Jorge Solórzano
Date:
Subject: Re: [JDBC] Using \errverbose through JDBC
Next
From: Thomas Kellerer
Date:
Subject: Re: Using \errverbose through JDBC