Skip site navigation (1) Skip section navigation (2)

Re: Error reporting issue in SimpleParameterList

From: Kris Jurka <books(at)ejurka(dot)com>
To: Nathan(dot)Keynes(at)csiro(dot)au
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Error reporting issue in SimpleParameterList
Date: 2007-06-13 07:27:53
Message-ID: Pine.BSO.4.64.0706130324400.18039@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-jdbc

On Wed, 13 Jun 2007, Nathan(dot)Keynes(at)csiro(dot)au wrote:

> In org.postgresql.core.v3.SimpleParameterList there is the following
> code:
>
>    void setResolvedType(int index, int oid) {
>        // only allow overwriting an unknown value
>        if (paramTypes[index-1] == Oid.UNSPECIFIED) {
>            paramTypes[index-1] = oid;
>        } else if (paramTypes[index-1] != oid) {
>            throw new IllegalArgumentException("Can't change resolved
> type for param: " + index + " from " + paramTypes[index] + " to " +
> oid);
>        }
>    }
>
> In the throw statement, paramTypes[index] should be paramTypes[index-1].
> (This was a little confusing until we spotted it).

Fix applied to CVS for 8.0, 8.1, 8.2, and 8.3dev.

> It's possible the message could be more explanatory as well, would
> something like "Param " + index + " type mismatch - expected " +
> getNameForOid(oid) + " but was bound to " +
> getNameForOid(paramTypes[index-1])  make sense?
>

Getting the names for the oids is tough from this part of the code so I 
don't think we can do that.  Also I think this is supposed to be a "can't 
happen" error that's more of an assert than a message for an end user. 
Do you have an example of how to trigger this condition?

Kris Jurka

In response to

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2007-06-13 08:16:35
Subject: Re: FYI: porting Copy API to 8.x
Previous:From: Thomas BurdaironDate: 2007-06-13 07:20:15
Subject: Re: Using INET types in prepared statements in Java?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group