Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
10.0.2.1
-
Low
-
Newcomer
Description
Derby doesn't throw a truncation exception/warning when data is too large during casting of constants or parameters to character string or bit string data types.
Following is ij example for constants which is too big for the datatype it is getting cast to
ij> values (cast ('hello' as char(3)));
1
hel
1 row selected
ij> values (cast (X'0102' as char(1) for bit data));
1
01
1 row selected
Following code snippet is when using parameters through a JDBC program
s.executeUpdate("create table ct (c CLOB(100K))");
//the following Formatters just loads cData with 32700 'c' characters
String cData = org.apache.derbyTesting.functionTests.util.Formatters.repeatChar("c",32700);
//notice that ? in the preared statement below is bound to length 32672
pSt = con.prepareStatement("insert into ct values (cast (? as varchar(32672)))");
pSt.setString(1, cData);
//Derby doesn't throw an exception at ps.execute time for 32700 characters into 32672 parameter. It silently
truncates it to 32672
pSt.execute();
Attachments
Attachments
Issue Links
- is duplicated by
-
DERBY-5537 Casting to a shorter string type does not warn about truncation
- Closed
- is related to
-
DERBY-6373 NPE in Statement.getWarnings()
- Closed