Error reporting issue in SimpleParameterList

Lists: pgsql-jdbc
From: <Nathan(dot)Keynes(at)csiro(dot)au>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Error reporting issue in SimpleParameterList
Date: 2007-06-13 03:36:54
Message-ID: B998A44C8986644EA8029CFE6396A9246F4C9D@exqld2-bne.nexus.csiro.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

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).

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?

Cheers,
Nathan


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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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