Re: Using \errverbose through JDBC

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jorge Solórzano <jorsol(at)gmail(dot)com>
Cc: Thomas Kellerer <spam_eater(at)gmx(dot)net>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Using \errverbose through JDBC
Date: 2017-02-01 15:24:01
Message-ID: 7868.1485962641@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

=?UTF-8?Q?Jorge_Sol=C3=B3rzano?= <jorsol(at)gmail(dot)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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas Kellerer 2017-02-01 15:50:33 Re: Using \errverbose through JDBC
Previous Message Jorge Solórzano 2017-02-01 15:11:16 Re: Using \errverbose through JDBC