You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2007/03/12 19:53:35 UTC
svn commit: r517332 - in /db/derby/code/branches/10.2/java:
engine/org/apache/derby/impl/sql/compile/
testing/org/apache/derbyTesting/functionTests/master/
Author: kahatlen
Date: Mon Mar 12 11:53:34 2007
New Revision: 517332
URL: http://svn.apache.org/viewvc?view=rev&rev=517332
Log:
DERBY-1132: Truncation Error with Concat
Merged from trunk (revision 477168).
Modified:
db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/cast.out
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/ejbql.out
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/implicitConversions.out
Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?view=diff&rev=517332&r1=517331&r2=517332
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Mon Mar 12 11:53:34 2007
@@ -41,6 +41,7 @@
import org.apache.derby.iapi.types.DataTypeUtilities;
import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.reference.Limits;
import org.apache.derby.iapi.reference.SQLState;
@@ -235,6 +236,23 @@
if (opndType.getScale() > 0)
length += 1; // 1 for the decimal .
+ }
+ /*
+ * Derby-1132 : The length for the target type was calculated
+ * incorrectly while Char & Varchar functions were used. Thus
+ * adding the check for Char & Varchar and calculating the
+ * length based on the operand type.
+ */
+ else if(srcTypeId.isStringTypeId())
+ {
+ length = opndType.getMaximumWidth();
+
+ // Truncate the target type width to the max width of the
+ // data type
+ if (this.targetCharType == Types.CHAR)
+ length = Math.min(length, Limits.DB2_CHAR_MAXWIDTH);
+ else if (this.targetCharType == Types.VARCHAR)
+ length = Math.min(length, Limits.DB2_VARCHAR_MAXWIDTH);
}
else
{
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/cast.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/cast.out?view=diff&rev=517332&r1=517331&r2=517332
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/cast.out (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/cast.out Mon Mar 12 11:53:34 2007
@@ -1515,30 +1515,30 @@
ij> insert into t1 values ('2005-09-10', '18.44.02', '2004-09-08-12.20.30.123456', 'cba', 'c');
1 row inserted/updated/deleted
ij> select char(c5), char(c6), char(c7), char(c8), char(c9) from t1;
-1 |2 |3 |4 |5
-------------------------------------------------------------------------------
-2003-09-10|16:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|abc |abcde
-2005-09-10|18:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|cba |c
+1 |2 |3 |4 |5
+----------------------------------------------------------
+2003-09-10|16:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|abc |abcde
+2005-09-10|18:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|cba |c
ij> select varchar(c5), varchar(c6), varchar(c7), varchar(c8), varchar(c9) from t1;
-1 |2 |3 |4 |5
-------------------------------------------------------------------------------
-2003-09-10|16:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|abc |abcde
-2005-09-10|18:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|cba |c
+1 |2 |3 |4 |5
+----------------------------------------------------------
+2003-09-10|16:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|abc |abcde
+2005-09-10|18:44:02|xxxxxxFILTERED-TIMESTAMPxxxxx|cba |c
ij> select char(c8, 10), varchar(c9, 9) from t1;
1 |2
--------------------
abc |abcde
cba |c
ij> select { fn concat(c8, char(c8)) } from t1;
-1
---------------------
-abc abc
-cba cba
+1
+----------
+abc abc
+cba cba
ij> select { fn concat(c8, varchar(c9)) } from t1;
-1
---------------------
-abc abcde
-cba c
+1
+----------
+abc abcde
+cba c
ij> select { fn concat(varchar(c9, 20), char(c8, 8)) } from t1;
1
----------------------------
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/ejbql.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/ejbql.out?view=diff&rev=517332&r1=517331&r2=517332
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/ejbql.out (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/ejbql.out Mon Mar 12 11:53:34 2007
@@ -1742,8 +1742,8 @@
1
---------------
ij> values{ fn concat( CHAR(''), CHAR('') ) };
-1
-------------------------------
+1
+---------------
ij> values{ fn concat( 45, 67 )};
ERROR 42846: Cannot convert types 'INTEGER' to 'VARCHAR'.
ij> values{ fn concat( '45', 67 )};
@@ -1751,9 +1751,9 @@
ij> values{ fn concat( 45, '67' )};
ERROR 42846: Cannot convert types 'INTEGER' to 'VARCHAR'.
ij> values{ fn concat( CHAR('C'), CHAR('#') ) };
-1
-------------------------------
-C #
+1
+----
+C#
ij> values{ fn concat( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=\ [];,./ \'' |',
'abcdefghijklmnopqrstuvwxyz~!@#$%^&*()_+|<>?:"{} '''''' ' ) };
1
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/implicitConversions.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/implicitConversions.out?view=diff&rev=517332&r1=517331&r2=517332
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/implicitConversions.out (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/implicitConversions.out Mon Mar 12 11:53:34 2007
@@ -2541,11 +2541,11 @@
ij> insert into t values (CHAR('2000-01-07'),
CHAR('20:06:58'),
CHAR('xxxxxxFILTERED-TIMESTAMPxxxxx'));
-ERROR 22007: The syntax of the string representation of a datetime value is incorrect.
+1 row inserted/updated/deleted
ij> insert into t values (CHAR('2000-1-06'),
CHAR('20:06:57'),
CHAR('2000-01-7 20:06:58.8000'));
-ERROR 22007: The syntax of the string representation of a datetime value is incorrect.
+1 row inserted/updated/deleted
ij> VALUES SYSCS_UTIL.SYSCS_CHECK_TABLE('APP', 'T');
1
-----------