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 rh...@apache.org on 2013/04/05 14:15:39 UTC
svn commit: r1464940 - in /db/derby/code/branches/10.10: ./
java/engine/org/apache/derby/impl/sql/execute/
java/engine/org/apache/derby/vti/
java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Author: rhillegas
Date: Fri Apr 5 12:15:39 2013
New Revision: 1464940
URL: http://svn.apache.org/r1464940
Log:
DERBY-6151: Port 1464934 from trunk to 10.10 branch.
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
db/derby/code/branches/10.10/java/engine/org/apache/derby/vti/VTITemplateBase.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1464934
Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java?rev=1464940&r1=1464939&r2=1464940&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java Fri Apr 5 12:15:39 2013
@@ -60,6 +60,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;
@@ -426,7 +427,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.10/java/engine/org/apache/derby/vti/VTITemplateBase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/vti/VTITemplateBase.java?rev=1464940&r1=1464939&r2=1464940&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/vti/VTITemplateBase.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/vti/VTITemplateBase.java Fri Apr 5 12:15:39 2013
@@ -86,7 +86,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.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java?rev=1464940&r1=1464939&r2=1464940&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java Fri Apr 5 12:15:39 2013
@@ -132,6 +132,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 =
{
{
@@ -1934,6 +1940,7 @@ public class TableFunctionTest extends B
derby_4092();
derby_5779();
derby_6040();
+ derby_6151();
}
/**
@@ -2406,6 +2413,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>
*/
@@ -3076,4 +3111,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 );
+ }
+ }
+
}