You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2010/05/15 19:11:42 UTC
[jira] Commented: (DERBY-129) Derby should throw a truncation error
or warning when CASTing a parameter/constant to char or char for bit
datatypes and the data is too large for the datatype.
[ https://issues.apache.org/jira/browse/DERBY-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867896#action_12867896 ]
Knut Anders Hatlen commented on DERBY-129:
------------------------------------------
I don't think Jeremy suggested that this issue was invalid, only that the appropriate response is a warning and not an exception. Derby doesn't currently give a warning.
> Derby should throw a truncation error or warning when CASTing a parameter/constant to char or char for bit datatypes and the data is too large for the datatype.
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-129
> URL: https://issues.apache.org/jira/browse/DERBY-129
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.0.2.1
> Reporter: Mamta A. Satoor
>
> 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();
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.