db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1464945 - in /db/derby/code/branches/10.8: ./ java/engine/org/apache/derby/impl/sql/execute/ java/engine/org/apache/derby/vti/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 05 Apr 2013 12:23:46 GMT
Author: rhillegas
Date: Fri Apr  5 12:23:46 2013
New Revision: 1464945

URL: http://svn.apache.org/r1464945
Log:
DERBY-6151: Port 1464934 from trunk to 10.8 branch.

Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
    db/derby/code/branches/10.8/java/engine/org/apache/derby/vti/VTITemplateBase.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1464934

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java?rev=1464945&r1=1464944&r2=1464945&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
(original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
Fri Apr  5 12:23:46 2013
@@ -66,6 +66,7 @@ import org.apache.derby.vti.Restriction;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.SQLWarning;
 import java.sql.ResultSetMetaData;
 
 
@@ -431,7 +432,10 @@ class VTIResultSet extends NoPutResultSe
                         result = getAllocatedRow();
                         populateFromResultSet(result);
                         if (fastPath != null)
-                            fastPath.currentRow(userVTI, result.getRowArray());
+                        { fastPath.currentRow(userVTI, result.getRowArray()); }
+
+                        SQLWarning  warnings = userVTI.getWarnings();
+                        if ( warnings != null ) { addWarning( warnings ); }
                     }
 				}
 			}

Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/vti/VTITemplateBase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/vti/VTITemplateBase.java?rev=1464945&r1=1464944&r2=1464945&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/vti/VTITemplateBase.java (original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/vti/VTITemplateBase.java Fri
Apr  5 12:23:46 2013
@@ -87,7 +87,7 @@ class VTITemplateBase implements ResultS
     public java.io.InputStream getAsciiStream(String columnName) throws SQLException { throw
notImplemented( "io.InputStream getAsciiStream" ); }
     public java.io.InputStream getUnicodeStream(String columnName) throws SQLException {
throw notImplemented( "io.InputStream getUnicodeStream" ); }
     public java.io.InputStream getBinaryStream(String columnName) throws SQLException { throw
notImplemented( "io.InputStream getBinaryStream" ); }
-    public SQLWarning getWarnings() throws SQLException { throw notImplemented( "getWarnings"
); }
+    public SQLWarning getWarnings() throws SQLException { return null; }
     public void clearWarnings() throws SQLException { throw notImplemented( "clearWarnings"
); }
     public String getCursorName() throws SQLException { throw notImplemented( "getCursorName"
); }
     public Object getObject(int columnIndex) throws SQLException { throw notImplemented(
"getObject" ); }

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java?rev=1464945&r1=1464944&r2=1464945&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
Fri Apr  5 12:23:46 2013
@@ -130,6 +130,12 @@ public class TableFunctionTest extends B
         { "2", "blue" },
     };
     
+    private static  final   String[][]  WARNING_VTI_ROWS =
+    {
+        { "1", "red" },
+        { "2", "blue" },
+    };
+    
     private static  final   String[][]  ALL_TYPES_ROWS =
     {
         {
@@ -1928,6 +1934,7 @@ public class TableFunctionTest extends B
         throws Exception
     {
         derby_4092();
+        derby_6151();
     }
     
     /**
@@ -1966,6 +1973,34 @@ public class TableFunctionTest extends B
     
     /**
      * <p>
+     * Verify that warnings percolate back from table functions.
+     * </p>
+     */
+    private void  derby_6151()
+        throws Exception
+    {
+        goodStatement
+            (
+             "create function warningVTI() returns table( a int, b varchar( 5 ) )\n" +
+             "language java parameter style derby_jdbc_result_set no sql\n" +
+             "external name '" + getClass().getName() + ".warningVTI'\n"
+             );
+
+        ResultSet   rs = getConnection().prepareStatement( "select * from table( warningVTI()
) t" ).executeQuery();
+
+        rs.next();
+        assertEquals( "Warning for row 1", rs.getWarnings().getMessage() );
+        rs.clearWarnings();
+        rs.next();
+        assertEquals( "Warning for row 2", rs.getWarnings().getMessage() );
+
+        rs.close();
+        
+        goodStatement( "drop function warningVTI" );
+    }
+    
+    /**
+     * <p>
      * Make the input rows for the coercion function.
      * </p>
      */
@@ -2632,4 +2667,35 @@ public class TableFunctionTest extends B
         return retval;
     }
 
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // NESTED CLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public  static  WarningVTI  warningVTI()    { return new WarningVTI(); }
+    
+    public  static  final   class   WarningVTI  extends StringArrayVTI
+    {
+        private int _count;
+        
+        public  WarningVTI()
+        {
+            super( makeColumnNames( 2, "mycol" ), WARNING_VTI_ROWS );
+        }
+
+        // override
+        public  boolean next()  throws SQLException
+        {
+            boolean retval = super.next();
+            if ( retval ) { _count++; }
+
+            return retval;
+        }
+        public  SQLWarning  getWarnings()
+        {
+            return new SQLWarning( "Warning for row " + _count );
+        }
+    }
+    
 }



Mime
View raw message