Re: [PATCHES] minor error reporting fixes

Lists: pgsql-jdbcpgsql-patches
From: Liam Stewart <liams(at)redhat(dot)com>
To: PostgreSQL JDBC List <pgsql-jdbc(at)postgresql(dot)org>, PostgreSQL Patches List <pgsql-patches(at)postgresql(dot)org>
Subject: minor error reporting fixes
Date: 2002-03-08 17:53:11
Message-ID: 20020308125311.A15759@redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc pgsql-patches


Here is a small patch that cleans up some error reporting in the JDBC
driver. PSQLExceptions are thrown instead of SQLExceptions and if a
warning is received while waiting for the backend secret key, that
warning is chained to the new Connection object instead of generating an
exception. A couple new error messages have been added.

Liam

--
Liam Stewart :: Red Hat Canada, Ltd. :: liams(at)redhat(dot)com

Attachment Content-Type Size
patch.txt text/plain 5.8 KB

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Liam Stewart <liams(at)redhat(dot)com>
Cc: PostgreSQL JDBC List <pgsql-jdbc(at)postgresql(dot)org>, PostgreSQL Patches List <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [PATCHES] minor error reporting fixes
Date: 2002-03-13 20:10:05
Message-ID: 200203132010.g2DKA5c05777@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc pgsql-patches


Patch applied. Thanks.

---------------------------------------------------------------------------

Liam Stewart wrote:
>
> Here is a small patch that cleans up some error reporting in the JDBC
> driver. PSQLExceptions are thrown instead of SQLExceptions and if a
> warning is received while waiting for the backend secret key, that
> warning is chained to the new Connection object instead of generating an
> exception. A couple new error messages have been added.
>
> Liam
>
> --
> Liam Stewart :: Red Hat Canada, Ltd. :: liams(at)redhat(dot)com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

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


From: Michael Adler <adler(at)glimpser(dot)org>
To: PostgreSQL JDBC List <pgsql-jdbc(at)postgresql(dot)org>
Subject: mishandling of NOTICE?
Date: 2002-03-18 18:47:21
Message-ID: Pine.NEB.4.44.0203181332220.13132-100000@reva.sixgirls.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc pgsql-patches


I am not very familiar with this driver, but I thought I should point out
a potential bug. I wish I had time to do more investigationn, testing and
debugging...

I encountered a situation in which I could access the database using psql
but not the JDBC driver. This is what I think happened:

The backend issued a NOTICE message. psql handled it gracefully by
printing the message to STDOUT and providing a fine connection. JDBC
driver throws a fatal SQLException.

The following case statements may need to handle NOTICEs differently:

org.postgresql.Connection line 265:

// As of protocol version 2.0, we should now receive the cancellation key and the pid
int beresp = pg_stream.ReceiveChar();
switch (beresp)
{
case 'K':
pid = pg_stream.ReceiveInteger(4);
ckey = pg_stream.ReceiveInteger(4);
break;
case 'E':
case 'N':
throw new SQLException(pg_stream.ReceiveString(encoding));
default:
throw new PSQLException("postgresql.con.setup");
}

// Expect ReadyForQuery packet
beresp = pg_stream.ReceiveChar();
switch (beresp)
{
case 'Z':
break;
case 'E':
case 'N':
throw new SQLException(pg_stream.ReceiveString(encoding));
default:
throw new PSQLException("postgresql.con.setup");
}

Once again, sorry for the uninformed vaugeries. I hope this helps
somewhat.

Mike Adler


From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "'Michael Adler'" <adler(at)glimpser(dot)org>, "'PostgreSQL JDBC List'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: mishandling of NOTICE?
Date: 2002-03-18 19:20:13
Message-ID: 006401c1ceb1$ee0f7c10$807ba8c0@inspiron
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc pgsql-patches

Michael,

Try the development driver off the site, I had a look at the source and
it doesn't do this anymore.

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Michael Adler
> Sent: Monday, March 18, 2002 1:47 PM
> To: PostgreSQL JDBC List
> Subject: [JDBC] mishandling of NOTICE?
>
>
>
> I am not very familiar with this driver, but I thought I
> should point out a potential bug. I wish I had time to do
> more investigationn, testing and debugging...
>
> I encountered a situation in which I could access the
> database using psql but not the JDBC driver. This is what I
> think happened:
>
> The backend issued a NOTICE message. psql handled it
> gracefully by printing the message to STDOUT and providing a
> fine connection. JDBC driver throws a fatal SQLException.
>
> The following case statements may need to handle NOTICEs differently:
>
> org.postgresql.Connection line 265:
>
> // As of protocol version 2.0, we should now
> receive the cancellation key and the pid
> int beresp = pg_stream.ReceiveChar();
> switch (beresp)
> {
> case 'K':
> pid = pg_stream.ReceiveInteger(4);
> ckey = pg_stream.ReceiveInteger(4);
> break;
> case 'E':
> case 'N':
> throw new
> SQLException(pg_stream.ReceiveString(encoding));
> default:
> throw new
> PSQLException("postgresql.con.setup");
> }
>
> // Expect ReadyForQuery packet
> beresp = pg_stream.ReceiveChar();
> switch (beresp)
> {
> case 'Z':
> break;
> case 'E':
> case 'N':
> throw new
> SQLException(pg_stream.ReceiveString(encoding));
> default:
> throw new
> PSQLException("postgresql.con.setup");
> }
>
>
>
>
> Once again, sorry for the uninformed vaugeries. I hope this
> helps somewhat.
>
> Mike Adler
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)
>
>