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

Error reporting issue in SimpleParameterList

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 (view raw or flat)
Thread:
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

Responses

pgsql-jdbc by date

Next:From: LITTLE NelsonDate: 2007-06-13 05:58:24
Subject: Using INET types in prepared statements in Java?
Previous:From: Kalle HallivuoriDate: 2007-06-11 19:55:41
Subject: Re: FYI: porting Copy API to 8.x

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