Error reporting issue in SimpleParameterList - Mailing list pgsql-jdbc

From
Subject Error reporting issue in SimpleParameterList
Date
Msg-id B998A44C8986644EA8029CFE6396A9246F4C9D@exqld2-bne.nexus.csiro.au
Whole thread Raw
Responses Re: Error reporting issue in SimpleParameterList  (Kris Jurka <books@ejurka.com>)
List 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

pgsql-jdbc by date:

Previous
From: "Kalle Hallivuori"
Date:
Subject: Re: FYI: porting Copy API to 8.x
Next
From: "LITTLE Nelson"
Date:
Subject: Using INET types in prepared statements in Java?