pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Using \errverbose through JDBC
9+ messages / 5 participants
[nested] [flat]

* Using \errverbose through JDBC
@ 2017-02-01 13:18 Thomas Kellerer <spam_eater@gmx.net>
  2017-02-01 13:28 ` Re: Using \errverbose through JDBC Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
  2017-02-01 13:39 ` Re: Using \errverbose through JDBC Dave Cramer <pg@fastcrypt.com>
  2017-02-01 15:11 ` Re: Using \errverbose through JDBC Jorge Solórzano <jorsol@gmail.com>
  0 siblings, 3 replies; 9+ messages in thread

From: Thomas Kellerer @ 2017-02-01 13:18 UTC (permalink / raw)
  To: pgsql-jdbc

Hello,

Postgres 9.6 introduced a new feature in libpq to get more detailed information about an error message. 

This can currently only be used in psql using the \errverbose command or by changing the VERBOSITY variable. 

I wonder if this is also available through JDBC somehow? 

Regards
Thomas



-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
@ 2017-02-01 13:28 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
  2017-02-01 15:50   ` Re: Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2 siblings, 1 reply; 9+ messages in thread

From: Vladimir Sitnikov @ 2017-02-01 13:28 UTC (permalink / raw)
  To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-jdbc

Thomas>This can currently only be used in psql using the \errverbose
command or by changing the VERBOSITY variable.

As far as I know, PSQLException (that is a base class of pgjdbc's
SQLExceptions) always has relevant data avaliable via getServerErrorMessage.

Is it something that you want?

https://github.com/pgjdbc/pgjdbc/blob/8be516d47ece60b7aeba5a9474b5cac1d538a04a/pgjdbc/src/main/java/...


Vladimir

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2017-02-01 13:28 ` Re: Using \errverbose through JDBC Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
@ 2017-02-01 15:50   ` Thomas Kellerer <spam_eater@gmx.net>
  0 siblings, 0 replies; 9+ messages in thread

From: Thomas Kellerer @ 2017-02-01 15:50 UTC (permalink / raw)
  To: pgsql-jdbc

Vladimir Sitnikov schrieb am 01.02.2017 um 14:28:
> Thomas>This can currently only be used in psql using the \errverbose command or by changing the VERBOSITY variable.
> 
> As far as I know, PSQLException (that is a base class of pgjdbc's SQLExceptions) always has relevant data avaliable via getServerErrorMessage.
> 
> Is it something that you want?
> 
> https://github.com/pgjdbc/pgjdbc/blob/8be516d47ece60b7aeba5a9474b5cac1d538a04a/pgjdbc/src/main/java/... 
> 
> Vladimir

Cool, this is what I was looking for. 

Thanks



-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
@ 2017-02-01 13:39 ` Dave Cramer <pg@fastcrypt.com>
  2017-02-01 13:41   ` Re: Using \errverbose through JDBC Dave Cramer <pg@fastcrypt.com>
  2 siblings, 1 reply; 9+ messages in thread

From: Dave Cramer @ 2017-02-01 13:39 UTC (permalink / raw)
  To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-jdbc

Interesting are there any more details about where we would hook into this ?

Dave Cramer

davec@postgresintl.com
www.postgresintl.com

On 1 February 2017 at 08:18, Thomas Kellerer <spam_eater@gmx.net> wrote:

> Hello,
>
> Postgres 9.6 introduced a new feature in libpq to get more detailed
> information about an error message.
>
> This can currently only be used in psql using the \errverbose command or
> by changing the VERBOSITY variable.
>
> I wonder if this is also available through JDBC somehow?
>
> Regards
> Thomas
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2017-02-01 13:39 ` Re: Using \errverbose through JDBC Dave Cramer <pg@fastcrypt.com>
@ 2017-02-01 13:41   ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Dave Cramer @ 2017-02-01 13:41 UTC (permalink / raw)
  To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-jdbc

Thomas,

This just changes the verbosity of logging, I would think you could do

set log_error_verbosity and it should (may) just work

Dave Cramer

davec@postgresintl.com
www.postgresintl.com

On 1 February 2017 at 08:39, Dave Cramer <pg@fastcrypt.com> wrote:

> Interesting are there any more details about where we would hook into this
> ?
>
> Dave Cramer
>
> davec@postgresintl.com
> www.postgresintl.com
>
> On 1 February 2017 at 08:18, Thomas Kellerer <spam_eater@gmx.net> wrote:
>
>> Hello,
>>
>> Postgres 9.6 introduced a new feature in libpq to get more detailed
>> information about an error message.
>>
>> This can currently only be used in psql using the \errverbose command or
>> by changing the VERBOSITY variable.
>>
>> I wonder if this is also available through JDBC somehow?
>>
>> Regards
>> Thomas
>>
>>
>>
>> --
>> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-jdbc
>>
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
@ 2017-02-01 15:11 ` Jorge Solórzano <jorsol@gmail.com>
  2017-02-01 15:24   ` Re: Using \errverbose through JDBC Tom Lane <tgl@sss.pgh.pa.us>
  2017-02-01 15:51   ` Re: Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2 siblings, 2 replies; 9+ messages in thread

From: Jorge Solórzano @ 2017-02-01 15:11 UTC (permalink / raw)
  To: Thomas Kellerer <spam_eater@gmx.net>; +Cc: pgsql-jdbc

The use case for this is?

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:

postgres=# select * from pg_catalog.pg_type;
> postgres=# \errverbose
> There is no previous error.
> postgres=# select * from pg_catalog.pg_types;
> ERROR:  relation "pg_catalog.pg_types" does not exist
> LÍNEA 1: select * from pg_catalog.pg_types;
>                        ^
> postgres=# \errverbose
> ERROR:  42P01: relation "pg_catalog.pg_types" does not exist
> LÍNEA 1: select * from pg_catalog.pg_types;
>                        ^
> UBICACIÓN:  parserOpenTable, parse_relation.c:1138
> postgres=# select 1/0;
> ERROR:  division by zero
> postgres=# \errverbose
> ERROR:  22012: division by zero
> UBICACIÓN:  int4div, int.c:719



Regards,


Jorge Solórzano
me.jorsol.com

On Wed, Feb 1, 2017 at 7:18 AM, Thomas Kellerer <spam_eater@gmx.net> wrote:

> Hello,
>
> Postgres 9.6 introduced a new feature in libpq to get more detailed
> information about an error message.
>
> This can currently only be used in psql using the \errverbose command or
> by changing the VERBOSITY variable.
>
> I wonder if this is also available through JDBC somehow?
>
> Regards
> Thomas
>
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2017-02-01 15:11 ` Re: Using \errverbose through JDBC Jorge Solórzano <jorsol@gmail.com>
@ 2017-02-01 15:24   ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-02-01 20:38     ` Re: Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  1 sibling, 1 reply; 9+ messages in thread

From: Tom Lane @ 2017-02-01 15:24 UTC (permalink / raw)
  To: Jorge Solórzano <jorsol@gmail.com>; +Cc: Thomas Kellerer <spam_eater@gmx.net>; 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


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2017-02-01 15:11 ` Re: Using \errverbose through JDBC Jorge Solórzano <jorsol@gmail.com>
  2017-02-01 15:24   ` Re: Using \errverbose through JDBC Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-02-01 20:38     ` Thomas Kellerer <spam_eater@gmx.net>
  0 siblings, 0 replies; 9+ messages in thread

From: Thomas Kellerer @ 2017-02-01 20:38 UTC (permalink / raw)
  To: pgsql-jdbc

Tom Lane schrieb am 01.02.2017 um 16:24:
> So really what would be appropriate for JDBC to provide, IMO, is
> some equivalent of libpq's PQresultErrorField().  Perhaps that's
> already there.

The JDBC driver already does that.

Vladimir pointed me to the correct location:

https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/util/ServerErrorMessage.html





-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Using \errverbose through JDBC
  2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
  2017-02-01 15:11 ` Re: Using \errverbose through JDBC Jorge Solórzano <jorsol@gmail.com>
@ 2017-02-01 15:51   ` Thomas Kellerer <spam_eater@gmx.net>
  1 sibling, 0 replies; 9+ messages in thread

From: Thomas Kellerer @ 2017-02-01 15:51 UTC (permalink / raw)
  To: pgsql-jdbc

Jorge Solórzano schrieb am 01.02.2017 um 16:11:
> The use case for this is?
> 
> 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:

I think it would: 

postgres> \set VERBOSITY verbose
postgres> insert into foobar (data) values ('x');
ERROR:  23502: null value in column "id" violates not-null constraint
DETAIL:  Failing row contains (null, x).
SCHEMA NAME:  public
TABLE NAME:  foobar
COLUMN NAME:  id
LOCATION:  ExecConstraints, execMain.c:1732
postgres>

When you run such an insert via JDBC, you'd only have "null value in column "id" violates not-null constraint" in the SQL Exception's message. 
But for logging purposes (on the client) it would be interesting to get details about the table into which the insert was done. 

This would enable to show those details (e.g. the table that was affected) in tools like SQL Workbench

Vladimir pointed me into the right direction. Those details are already available through the Postgres JDBC driver. 





-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2017-02-01 20:38 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-02-01 13:18 Using \errverbose through JDBC Thomas Kellerer <spam_eater@gmx.net>
2017-02-01 13:28 ` Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
2017-02-01 15:50   ` Thomas Kellerer <spam_eater@gmx.net>
2017-02-01 13:39 ` Dave Cramer <pg@fastcrypt.com>
2017-02-01 13:41   ` Dave Cramer <pg@fastcrypt.com>
2017-02-01 15:11 ` Jorge Solórzano <jorsol@gmail.com>
2017-02-01 15:24   ` Tom Lane <tgl@sss.pgh.pa.us>
2017-02-01 20:38     ` Thomas Kellerer <spam_eater@gmx.net>
2017-02-01 15:51   ` Thomas Kellerer <spam_eater@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox