db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <ma...@Remulak.Net>
Subject Re: Prepared statement's parameter's width is not getting checked....
Date Fri, 21 Jan 2005 20:23:29 GMT

Mamta Satoor wrote:

> Hi,
> I have a simple test case where Derby doesn't throw a truncation exception.
>    //the following Formatters just loads cData with 32700 'c' characters
>   String cData = org.apache.derbyTesting.functionTests.util.Formatters.repeatChar("c",32700);
>    pSt = con.prepareStatement("insert into ct values (cast (? as varchar(32672)))");
//notice that ? is bound to length
> 32672
>    pSt.setString(1, cData);
>    pSt.execute();//Derby doesn't throw an exception here for 32700 characters into 32672
parameter. It silently
> truncates it to 32672
> I think it is a bug that we accept 32700 characters, truncate it to 32672 characters
> and insert those 32672 characters into table ct.
> This behavior is because ParameterNode.generateExpression() doesn't generate the
> method "setWidth" to validate the width at run time. Before I file a Jira entry, I want
> to make sure that community agrees that it is a bug.
> thanks,
> Mamta

I have entered a JIRA entry Derby-129 for this issue. If it is decided that it is an
acceptable behavior to ignore truncation during casting of constant or parameter,
we can put comments indicating so in the bug and close it.


View raw message