db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1466164 - in /db/derby/code/branches/10.8.3.1_testcompat: ./ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/functionTests/tests...
Date Tue, 09 Apr 2013 18:05:27 GMT
Author: kmarsden
Date: Tue Apr  9 18:05:27 2013
New Revision: 1466164

URL: http://svn.apache.org/r1466164
Log:
DERBY-5749 Implicit cast of variable length values, e.g. as arguments to stored methods and
generated columns values, silently truncate if too long 

merge tests from revision 1339281


Modified:
    db/derby/code/branches/10.8.3.1_testcompat/   (props changed)
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/iepnegativetests_ES.out
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/importExportIJ.out
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/iepnegativetests.sql
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/importExportIJ.sql

Propchange: db/derby/code/branches/10.8.3.1_testcompat/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1339281

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/iepnegativetests_ES.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/iepnegativetests_ES.out?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/iepnegativetests_ES.out
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/iepnegativetests_ES.out
Tue Apr  9 18:05:27 2013
@@ -109,11 +109,10 @@ ERROR XIE0J: Un delimitador no es v EnC:
 ij> call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('IEP', 'T1' , 'extinout/t2.dat' , 
                                  null, '', null) ;
 ERROR XIE0J: Un delimitador no es v EnC:>225< lido o se ha utilizado m EnC:>225<
s de una vez.
-ij> --more than one character passed to the delimiters get truncated to one
---following one should give error because eventually '\' delimiter 
+ij> --following one should give error because eventually '\' delimiter 
 --is used a both for char and col
 call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('IEP', 'T1' , 'extinout/t2.dat' , 
-                                 '\a', '\', null) ;
+                                 '\', '\', null) ;
 ERROR XIE0J: Un delimitador no es v EnC:>225< lido o se ha utilizado m EnC:>225<
s de una vez.
 ij> --DO A VALID EXPORT AND  IMPORT 
 set schema iep;

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/importExportIJ.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/importExportIJ.out?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/importExportIJ.out
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/importExportIJ.out
Tue Apr  9 18:05:27 2013
@@ -839,7 +839,7 @@ ij> --
 --
 
 CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
-('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\t' ,'|','UTF-16','extout/derby-2925_lobs.dat');
+('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\' ,'|','UTF-16','extout/derby-2925_lobs.dat');
 0 rows inserted/updated/deleted
 ij> --
 -- Errors should should happen in the second
@@ -847,7 +847,7 @@ ij> --
 -- since extout/derby-2925_data.dat already exists.
 --
 CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
-('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\t' ,'|','UTF-16','extout/derby-2925_lobs.dat');
+('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\' ,'|','UTF-16','extout/derby-2925_lobs.dat');
 ERROR XIE0S: The export operation was not performed, because the specified output file (extout/derby-2925_data.dat)
already exists. Export processing will not overwrite an existing file, even if the process
has permissions to write to that file, due to security concerns, and to avoid accidental file
damage. Please either change the output file name in the export procedure arguments to specify
a file which does not exist, or delete the existing file, then retry the export operation.
 ij> --
 -- Testing SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
@@ -859,7 +859,7 @@ ij> --
 --
 
 CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
-('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data1.dat', '\t' ,'|','UTF-16','extout/derby-2925_lobs.dat');
+('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data1.dat', '\' ,'|','UTF-16','extout/derby-2925_lobs.dat');
 ERROR XIE0T: The export operation was not performed, because the specified large object auxiliary
file (extout/derby-2925_lobs.dat) already exists. Export processing will not overwrite an
existing file, even if the process has permissions to write to that file, due to security
concerns, and to avoid accidental file damage. Please either change the large object auxiliary
file name in the export procedure arguments to specify a file which does not exist, or delete
the existing file, then retry the export operation.
 ij> --
 -- end test case for derby-2925:

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
Tue Apr  9 18:05:27 2013
@@ -1534,7 +1534,7 @@ public class CollationTest2 extends Base
         // bulk insert with replace to empty table/one index from an empty file 
         // import empty_file.dat into EMPTY_TABLE 
         doImportTable(
-                "APP", "EMPTY_TABLE", emptyFileName, "|", "``", null, 1);
+                "APP", "EMPTY_TABLE", emptyFileName, "|", "`", null, 1);
 
         commit();
 

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java
Tue Apr  9 18:05:27 2013
@@ -161,7 +161,7 @@ public class DatabaseClassLoadingTest ex
                   "language java parameter style java");
 
                 s.executeUpdate(
-                  "create function EMC.GETARTICLE(path VARCHAR(40)) " +
+                  "create function EMC.GETARTICLE(path VARCHAR(60)) " +
                   "RETURNS VARCHAR(256) " +
                   "NO SQL " +
                   "external name 'org.apache.derbyTesting.databaseclassloader.emc.getArticle'
" +

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
Tue Apr  9 18:05:27 2013
@@ -106,6 +106,7 @@ public class GeneratedColumnsHelper exte
     protected static  final   String  BAD_CAST = "42846";
     protected static  final   String  DUPLICATE_CLAUSE = "42XAJ";
     protected static  final   String  FORBIDDEN_DROP_TRIGGER = "X0Y24";
+    protected static  final   String  STRING_TRUNCATION = "22001";
 
     ///////////////////////////////////////////////////////////////////////////////////
     //

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Tue Apr  9 18:05:27 2013
@@ -2406,10 +2406,10 @@ public class GeneratedColumnsTest extend
              "create table t_cc_char\n" +
              "(\n" +
              "    a char( 10 ),\n" +
-             "    b char( 5 ) generated always as( upper( a ) ),\n" +
+             "    b char( 5 ) generated always as( cast(upper( a ) as char(5))),\n" +
              "    c char( 10 ) generated always as( upper( a ) ),\n" +
              "    d char( 15 ) generated always as( upper( a ) ),\n" +
-             "    e varchar( 5 ) generated always as( upper( a ) ),\n" +
+             "    e varchar( 5 ) generated always as( cast(upper( a ) as varchar(5))),\n"
+
              "    f varchar( 10 ) generated always as( upper( a ) ),\n" +
              "    g varchar( 15 ) generated always as( upper( a ) )\n" +
              ")\n"
@@ -2420,10 +2420,10 @@ public class GeneratedColumnsTest extend
              "create table t_cc_varchar\n" +
              "(\n" +
              "    a varchar( 10 ),\n" +
-             "    b char( 5 ) generated always as( upper( a ) ),\n" +
+             "    b char( 5 ) generated always as( cast(upper( a ) as char(5))),\n" +
              "    c char( 10 ) generated always as( upper( a ) ),\n" +
              "    d char( 15 ) generated always as( upper( a ) ),\n" +
-             "    e varchar( 5 ) generated always as( upper( a ) ),\n" +
+             "    e varchar( 5 ) generated always as( cast(upper( a ) as varchar(5))),\n"
+
              "    f varchar( 10 ) generated always as( upper( a ) ),\n" +
              "    g varchar( 15 ) generated always as( upper( a ) )\n" +
              ")\n"
@@ -2526,12 +2526,12 @@ public class GeneratedColumnsTest extend
         goodStatement
             (
              conn,
-             "create table t_atac_3( a varchar( 5 ), b varchar( 5 ) generated always as (
upper( a )  ) )"
+             "create table t_atac_3( a varchar( 5 ), b varchar( 5 ) generated always as (
cast(upper( a ) as varchar(5)) ) )"
              );
         goodStatement
             (
              conn,
-             "create table t_atac_4( a varchar( 5 ) for bit data,  b varchar( 5 ) for bit
data generated always as ( a )  )"
+             "create table t_atac_4( a varchar( 5 ) for bit data,  b varchar( 5 ) for bit
data generated always as ( cast(a as varchar( 5 ) for bit data))  )"
              );
 
         //
@@ -5536,6 +5536,44 @@ public class GeneratedColumnsTest extend
         );
     }
 
+
+    // Derby 5749
+    public void test_derby_5749()
+        throws Exception
+    {
+        Connection conn = getConnection();
+
+        goodStatement
+        (
+            conn,
+            "create table t_5749\n" +
+            "(c varchar(5) generated always as ('--' || b), b varchar(5))\n"
+        );
+
+        // fails on truncation
+        expectExecutionError
+        (
+            conn,
+            STRING_TRUNCATION,
+            "insert into t_5749 values (default, '12345')"
+        );
+
+        // Try an update case:
+        goodStatement
+        (
+            conn,
+            "insert into t_5749 values (default, '123')"
+        );
+
+        expectExecutionError
+        (
+            conn,
+            STRING_TRUNCATION,
+            "update t_5749 set b='12345'"
+        );
+
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // MINIONS

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RoutineTest.java
Tue Apr  9 18:05:27 2013
@@ -22,6 +22,7 @@
 package org.apache.derbyTesting.functionTests.tests.lang;
 
 import java.io.UnsupportedEncodingException;
+import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -640,7 +641,53 @@ public class RoutineTest extends BaseJDB
         assertStatementError( CANNOT_STUFF_NULL_INTO_PRIMITIVE, s, "values( negateInt( cast(
null as int) ) )" );
         assertStatementError( CANNOT_STUFF_NULL_INTO_PRIMITIVE, s, "values( negateInt( getNullInt()
) )" );
     }
-    
+
+    /**
+     * DERBY-5749: Too long (non-blank) argument for VARCHAR parameter does not
+     * throw as expected.
+     */
+    public void test_5749() throws SQLException
+    {
+        Statement s = createStatement();
+        s.executeUpdate("create table t5749(v varchar(5))");
+        s.executeUpdate(
+            "create procedure p5749 (a varchar(5)) modifies sql data " +
+            "external name '" + RoutineTest.class.getName() + ".p5749' " +
+            "language java parameter style java");
+        CallableStatement cs = prepareCall("call p5749(?)");
+        cs.setString(1, "123456");
+
+        // This silently truncates before fix of DERBY-5749
+        try {
+            cs.execute();
+            fail();
+        } catch (SQLException e) {
+            assertSQLState("22001", e);
+        }
+
+        // This silently truncates also
+        try {
+            s.executeUpdate("call p5749('123456')");
+            fail();
+        } catch (SQLException e) {
+            assertSQLState("22001", e);
+        }
+
+
+        PreparedStatement ps = prepareStatement("insert into t5749 values(?)");
+        ps.setString(1, "123456");
+        // This does not truncate
+        try {
+            ps.execute();
+            fail();
+        } catch (SQLException e) {
+            assertSQLState("22001", e);
+        }
+    }
+
+
+
+
     /*
     ** Routine implementations called from the tests but do
     *  not use DriverManager so that this test can be used on
@@ -688,6 +735,8 @@ public class RoutineTest extends BaseJDB
 
     public static int negateInt( int arg ) { return -arg; }
     public static Integer getNullInt() { return null; }
-    
+
+    public static void p5749 (String s) {
+    }
 }
 

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
Tue Apr  9 18:05:27 2013
@@ -2044,7 +2044,7 @@ public final class ImportExportProcedure
         
         cSt = prepareCall(
             "call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('IEP', 'T1' , "
-            + "'extinout/t1.dat' , '\\a', '\\', null) ");
+            + "'extinout/t1.dat' , '\\', '\\', null) ");
         assertStatementError("XIE0J", cSt);
                 
         //DO A VALID EXPORT AND  IMPORT

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/iepnegativetests.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/iepnegativetests.sql?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/iepnegativetests.sql
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/iepnegativetests.sql
Tue Apr  9 18:05:27 2013
@@ -70,11 +70,10 @@ call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('IEP
                                  null, '', null) ;
 
 
---more than one character passed to the delimiters get truncated to one
 --following one should give error because eventually '\' delimiter 
 --is used a both for char and col
 call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('IEP', 'T1' , 'extinout/t2.dat' , 
-                                 '\a', '\', null) ;
+                                 '\', '\', null) ;
 
 
 --DO A VALID EXPORT AND  IMPORT 

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/importExportIJ.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/importExportIJ.sql?rev=1466164&r1=1466163&r2=1466164&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/importExportIJ.sql
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/tools/importExportIJ.sql
Tue Apr  9 18:05:27 2013
@@ -535,14 +535,14 @@ create table derby_2925_lob
 --
 
 CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
-('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\t' ,'|','UTF-16','extout/derby-2925_lobs.dat');
+('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\' ,'|','UTF-16','extout/derby-2925_lobs.dat');
 --
 -- Errors should should happen in the second
 -- call to SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
 -- since extout/derby-2925_data.dat already exists.
 --
 CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
-('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\t' ,'|','UTF-16','extout/derby-2925_lobs.dat');
+('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data.dat', '\' ,'|','UTF-16','extout/derby-2925_lobs.dat');
 
 --
 -- Testing SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
@@ -554,7 +554,7 @@ CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_
 --
 
 CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE
-('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data1.dat', '\t' ,'|','UTF-16','extout/derby-2925_lobs.dat');
+('SELECT * FROM DERBY_2925_LOB','extout/derby-2925_data1.dat', '\' ,'|','UTF-16','extout/derby-2925_lobs.dat');
 
 --
 -- end test case for derby-2925:



Mime
View raw message