db-derby-dev mailing list archives

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

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


View raw message