pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDBC error codes to detect duplicates?
12+ messages / 6 participants
[nested] [flat]

* JDBC error codes to detect duplicates?
@ 2001-03-01 18:20  David Wall <d.wall@computer.org>
  0 siblings, 2 replies; 12+ messages in thread

From: David Wall @ 2001-03-01 18:20 UTC (permalink / raw)
  To: pgsql-interfaces

It seems that when an INSERT causes a duplicate key exception for
unique/primary keys, the JDBC library is throwing the SQL exception but
there is no code that lets my program detect a duplicate key error, or which
key caused the duplicate error.

Is there a plan for the JDBC to return the codes for postgres back to the
program?  I running 7.1beta4 now.

David




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-01 18:41  Max Khon <fjoe@iclub.nsu.ru>
  parent: David Wall <d.wall@computer.org>
  1 sibling, 2 replies; 12+ messages in thread

From: Max Khon @ 2001-03-01 18:41 UTC (permalink / raw)
  To: David Wall <d.wall@computer.org>; +Cc: pgsql-interfaces

hi, there!

On Thu, 1 Mar 2001, David Wall wrote:

> It seems that when an INSERT causes a duplicate key exception for
> unique/primary keys, the JDBC library is throwing the SQL exception but
> there is no code that lets my program detect a duplicate key error, or which
> key caused the duplicate error.
> 
> Is there a plan for the JDBC to return the codes for postgres back to the
> program?  I running 7.1beta4 now.

AFAIK clean implementation of such feature is not possible because backend
protocol does not have error codes (only error messages)

/fjoe




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-01 19:06  David Wall <d.wall@computer.org>
  parent: Max Khon <fjoe@iclub.nsu.ru>
  1 sibling, 0 replies; 12+ messages in thread

From: David Wall @ 2001-03-01 19:06 UTC (permalink / raw)
  To: pgsql-interfaces

> Is there a plan for the JDBC to return the codes for postgres back to
the program?  I running 7.1beta4 now.
>
>> AFAIK clean implementation of such feature is not possible because
backend
>> protocol does not have error codes (only error messages)

Too bad.  Is the definitive list of error messages documented? (Probably
yes, but where?)  Perhaps we could write an ugly implementation that would
parse the error message and return meaningful errors codes so that all users
don't suffer the same problem.

Thoughts?

David





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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-01 21:07  Peter Mount <peter@retep.org.uk>
  parent: David Wall <d.wall@computer.org>
  1 sibling, 2 replies; 12+ messages in thread

From: Peter Mount @ 2001-03-01 21:07 UTC (permalink / raw)
  To: Max Khon <fjoe@iclub.nsu.ru>; David Wall <d.wall@computer.org>; +Cc: pgsql-interfaces

At 00:41 02/03/01 +0600, Max Khon wrote:
>hi, there!
>
>On Thu, 1 Mar 2001, David Wall wrote:
>
> > It seems that when an INSERT causes a duplicate key exception for
> > unique/primary keys, the JDBC library is throwing the SQL exception but
> > there is no code that lets my program detect a duplicate key error, or 
> which
> > key caused the duplicate error.
> >
> > Is there a plan for the JDBC to return the codes for postgres back to the
> > program?  I running 7.1beta4 now.
>
>AFAIK clean implementation of such feature is not possible because backend
>protocol does not have error codes (only error messages)

Thats correct. It's also not practical to get the driver to translate 
because the format of the messages can change between releases as well.

Peter


>/fjoe




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-01 21:28  Peter Mount <peter@retep.org.uk>
  parent: Max Khon <fjoe@iclub.nsu.ru>
  1 sibling, 0 replies; 12+ messages in thread

From: Peter Mount @ 2001-03-01 21:28 UTC (permalink / raw)
  To: David Wall <d.wall@computer.org>; pgsql-interfaces

At 11:06 01/03/01 -0800, David Wall wrote:
> > Is there a plan for the JDBC to return the codes for postgres back to
>the program?  I running 7.1beta4 now.
> >
> >> AFAIK clean implementation of such feature is not possible because
>backend
> >> protocol does not have error codes (only error messages)
>
>Too bad.  Is the definitive list of error messages documented? (Probably
>yes, but where?)  Perhaps we could write an ugly implementation that would
>parse the error message and return meaningful errors codes so that all users
>don't suffer the same problem.

problem is two fold:

1: Enlarges the driver, which affects those who use the driver over a 
network connection (some people still use JDBC direct in applets)

2: It becomes sensitive to changes during development.

An example of  #2 is where the Timestamp format changed just slightly, then 
getTimestamp broke.

Peter




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-01 22:08  David Wall <d.wall@computer.org>
  parent: Peter Mount <peter@retep.org.uk>
  1 sibling, 1 reply; 12+ messages in thread

From: David Wall @ 2001-03-01 22:08 UTC (permalink / raw)
  To: Max Khon <fjoe@iclub.nsu.ru>; Peter Mount <peter@retep.org.uk>; +Cc: pgsql-interfaces

> >AFAIK clean implementation of such feature is not possible because
backend
> >protocol does not have error codes (only error messages)
>
> Thats correct. It's also not practical to get the driver to translate
> because the format of the messages can change between releases as well.

Practically speaking, how often do the messages really change between
releases?  It seems that we could create a pluggable translator that would
work based on the release version.  If the messages change too frequently,
then something's seriously wrong with Postgresql server since the main
sql-portion of the system has been in place and there aren't too many things
a program really needs to detect about a database (missing row, duplicate
key, constraint violation, transaction error, deadlock detected, etc.).

David




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-01 22:54  Bruce Momjian <pgman@candle.pha.pa.us>
  parent: David Wall <d.wall@computer.org>
  0 siblings, 2 replies; 12+ messages in thread

From: Bruce Momjian @ 2001-03-01 22:54 UTC (permalink / raw)
  To: David Wall <d.wall@computer.org>; +Cc: Max Khon <fjoe@iclub.nsu.ru>; Peter Mount <peter@retep.org.uk>; pgsql-interfaces

I have ideas on how to do error codes and multiple languages.  I can
make a proposal for 7.2.

[ Charset ISO-8859-1 unsupported, converting... ]
> > >AFAIK clean implementation of such feature is not possible because
> backend
> > >protocol does not have error codes (only error messages)
> >
> > Thats correct. It's also not practical to get the driver to translate
> > because the format of the messages can change between releases as well.
> 
> Practically speaking, how often do the messages really change between
> releases?  It seems that we could create a pluggable translator that would
> work based on the release version.  If the messages change too frequently,
> then something's seriously wrong with Postgresql server since the main
> sql-portion of the system has been in place and there aren't too many things
> a program really needs to detect about a database (missing row, duplicate
> key, constraint violation, transaction error, deadlock detected, etc.).
> 
> David
> 
> 


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-02 08:56  Cedar Cox <cedarc@visionforisrael.com>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 1 reply; 12+ messages in thread

From: Cedar Cox @ 2001-03-02 08:56 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: David Wall <d.wall@computer.org>; Max Khon <fjoe@iclub.nsu.ru>; Peter Mount <peter@retep.org.uk>; pgsql-interfaces


As stated, the backend protocol doesn't pass error codes but error
messages.  My question is, are there enough of these kind of things to
create a new protocol version (7.2)?  After all, we are still using the
same protocol since (?)6.5.  I think adding error codes would not only
benefit JDBC but ODBC and possibly others also.  I know there have been
various discussions like this one about parsing error messages in the ODBC
driver.  As I remember, there were one or two other things that have been
discussed that would require a change in the protocol also.  Just my two
cents.

-Cedar

On Thu, 1 Mar 2001, Bruce Momjian wrote:

> I have ideas on how to do error codes and multiple languages.  I can
> make a proposal for 7.2.
> 
> [ Charset ISO-8859-1 unsupported, converting... ]
> > > >AFAIK clean implementation of such feature is not possible because
> > backend
> > > >protocol does not have error codes (only error messages)
> > >
> > > Thats correct. It's also not practical to get the driver to translate
> > > because the format of the messages can change between releases as well.
> > 
> > Practically speaking, how often do the messages really change between
> > releases?  It seems that we could create a pluggable translator that would
> > work based on the release version.  If the messages change too frequently,
> > then something's seriously wrong with Postgresql server since the main
> > sql-portion of the system has been in place and there aren't too many things
> > a program really needs to detect about a database (missing row, duplicate
> > key, constraint violation, transaction error, deadlock detected, etc.).
> > 
> > David
> > 
> > 
> 
> 
> -- 
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
> 




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-02 09:09  Peter T Mount <peter@retep.org.uk>
  parent: Cedar Cox <cedarc@visionforisrael.com>
  0 siblings, 0 replies; 12+ messages in thread

From: Peter T Mount @ 2001-03-02 09:09 UTC (permalink / raw)
  To: Cedar Cox <cedarc@visionforisrael.com>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; David Wall <d.wall@computer.org>; Max Khon <fjoe@iclub.nsu.ru>; Peter Mount <peter@retep.org.uk>; pgsql-interfaces

Quoting Cedar Cox <cedarc@visionforisrael.com>:

> 
> As stated, the backend protocol doesn't pass error codes but error
> messages.  My question is, are there enough of these kind of things to
> create a new protocol version (7.2)?  After all, we are still using the
> same protocol since (?)6.5.  I think adding error codes would not only
> benefit JDBC but ODBC and possibly others also.  I know there have been
> various discussions like this one about parsing error messages in the
> ODBC
> driver.  As I remember, there were one or two other things that have
> been
> discussed that would require a change in the protocol also.  Just my
> two
> cents.

I totally agree. Putting the error codes (an extra 2 or 4 bytes) in the 
protocol shouldn't be too much hardship, and does mean several benefits:

1: No parsing of error messages on the client side
2: Small clients (embeded systems) can ignore the textual side of the message
3: It would be optional not to send the textual message - just the error 
number. Again good for non-human clients
4: Codes would be language independent (human that is). Currently AFAIK only 
JDBC supports it's own error messages in non-english languages. Having the 
codes would mean the backend ones could also be in non-english format and the 
clients would still work fine.

Virtually every interface would benefit from it.

Peter

> 
> -Cedar
> 
> On Thu, 1 Mar 2001, Bruce Momjian wrote:
> 
> > I have ideas on how to do error codes and multiple languages.  I can
> > make a proposal for 7.2.
> > 
> > [ Charset ISO-8859-1 unsupported, converting... ]
> > > > >AFAIK clean implementation of such feature is not possible
> because
> > > backend
> > > > >protocol does not have error codes (only error messages)
> > > >
> > > > Thats correct. It's also not practical to get the driver to
> translate
> > > > because the format of the messages can change between releases as
> well.
> > > 
> > > Practically speaking, how often do the messages really change
> between
> > > releases?  It seems that we could create a pluggable translator that
> would
> > > work based on the release version.  If the messages change too
> frequently,
> > > then something's seriously wrong with Postgresql server since the
> main
> > > sql-portion of the system has been in place and there aren't too
> many things
> > > a program really needs to detect about a database (missing row,
> duplicate
> > > key, constraint violation, transaction error, deadlock detected,
> etc.).
> > > 
> > > David
> > > 
> > > 
> > 
> > 
> > -- 
> >   Bruce Momjian                        |  http://candle.pha.pa.us
> >   pgman@candle.pha.pa.us               |  (610) 853-3000
> >   +  If your life is a hard drive,     |  830 Blythe Avenue
> >   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania
> 19026
> > 
> 
> 



-- 
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/



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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-02 09:34  Max Khon <fjoe@iclub.nsu.ru>
  parent: Peter Mount <peter@retep.org.uk>
  1 sibling, 1 reply; 12+ messages in thread

From: Max Khon @ 2001-03-02 09:34 UTC (permalink / raw)
  To: Peter Mount <peter@retep.org.uk>; +Cc: David Wall <d.wall@computer.org>; pgsql-interfaces

hi, there!

On Thu, 1 Mar 2001, Peter Mount wrote:

> > > It seems that when an INSERT causes a duplicate key exception for
> > > unique/primary keys, the JDBC library is throwing the SQL exception but
> > > there is no code that lets my program detect a duplicate key error, or 
> > which
> > > key caused the duplicate error.
> > >
> > > Is there a plan for the JDBC to return the codes for postgres back to the
> > > program?  I running 7.1beta4 now.
> >
> >AFAIK clean implementation of such feature is not possible because backend
> >protocol does not have error codes (only error messages)
> 
> Thats correct. It's also not practical to get the driver to translate 
> because the format of the messages can change between releases as well.

can we consider adding error code prepended to error message and
separated with e.g. one single space? seems that this will not break
anything but will allow JDBC/ODBC drivers to return meaningful error
codes.

/fjoe




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-02 09:46  Max Khon <fjoe@iclub.nsu.ru>
  parent: Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 12+ messages in thread

From: Max Khon @ 2001-03-02 09:46 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: David Wall <d.wall@computer.org>; Peter Mount <peter@retep.org.uk>; pgsql-interfaces

hi, there!

On Thu, 1 Mar 2001, Bruce Momjian wrote:

> I have ideas on how to do error codes and multiple languages.  I can
> make a proposal for 7.2.

that would be great

/fjoe




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

* Re: JDBC error codes to detect duplicates?
@ 2001-03-02 14:26  Peter T Mount <peter@retep.org.uk>
  parent: Max Khon <fjoe@iclub.nsu.ru>
  0 siblings, 0 replies; 12+ messages in thread

From: Peter T Mount @ 2001-03-02 14:26 UTC (permalink / raw)
  To: Max Khon <fjoe@iclub.nsu.ru>; +Cc: Peter Mount <peter@retep.org.uk>; David Wall <d.wall@computer.org>; pgsql-interfaces

Quoting Max Khon <fjoe@iclub.nsu.ru>:

> hi, there!
> 
> On Thu, 1 Mar 2001, Peter Mount wrote:
> 
> > > > It seems that when an INSERT causes a duplicate key exception for
> > > > unique/primary keys, the JDBC library is throwing the SQL
> exception but
> > > > there is no code that lets my program detect a duplicate key
> error, or 
> > > which
> > > > key caused the duplicate error.
> > > >
> > > > Is there a plan for the JDBC to return the codes for postgres back
> to the
> > > > program?  I running 7.1beta4 now.
> > >
> > >AFAIK clean implementation of such feature is not possible because
> backend
> > >protocol does not have error codes (only error messages)
> > 
> > Thats correct. It's also not practical to get the driver to translate
> 
> > because the format of the messages can change between releases as
> well.
> 
> can we consider adding error code prepended to error message and
> separated with e.g. one single space? seems that this will not break
> anything but will allow JDBC/ODBC drivers to return meaningful error
> codes.

That is the other alternative, and one that could be implemented pretty quickly.

Peter

-- 
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/



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


end of thread, other threads:[~2001-03-02 14:26 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-01 18:20 JDBC error codes to detect duplicates? David Wall <d.wall@computer.org>
2001-03-01 18:41 ` Max Khon <fjoe@iclub.nsu.ru>
2001-03-01 19:06   ` David Wall <d.wall@computer.org>
2001-03-01 21:28   ` Peter Mount <peter@retep.org.uk>
2001-03-01 21:07 ` Peter Mount <peter@retep.org.uk>
2001-03-01 22:08   ` David Wall <d.wall@computer.org>
2001-03-01 22:54     ` Bruce Momjian <pgman@candle.pha.pa.us>
2001-03-02 08:56       ` Cedar Cox <cedarc@visionforisrael.com>
2001-03-02 09:09         ` Peter T Mount <peter@retep.org.uk>
2001-03-02 09:46       ` Max Khon <fjoe@iclub.nsu.ru>
2001-03-02 09:34   ` Max Khon <fjoe@iclub.nsu.ru>
2001-03-02 14:26     ` Peter T Mount <peter@retep.org.uk>

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