db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r904472 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/execute/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 29 Jan 2010 11:49:21 GMT
Author: kahatlen
Date: Fri Jan 29 11:49:09 2010
New Revision: 904472

URL: http://svn.apache.org/viewvc?rev=904472&view=rev
Log:
DERBY-4488: Nullpointer when performing INSERT INTO

Merged fix from trunk (revision 903108).

Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteVTIResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertVTIResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/SetTransactionResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateVTIResultSet.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 29 11:49:09 2010
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,882732,884163,887246,892912,897161,901165,901648,901760
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,882732,884163,887246,892912,897161,901165,901648,901760,903108

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java
Fri Jan 29 11:49:09 2010
@@ -59,7 +59,6 @@
     CallStatementResultSet(
 				GeneratedMethod methodCall,
 				Activation a) 
-			throws StandardException
     {
 		super(a);
 		this.methodCall = methodCall;

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteResultSet.java
Fri Jan 29 11:49:09 2010
@@ -200,9 +200,6 @@
 		activation.checkStatementValidity();
 
 		/* Get or re-use the row changer.
-		 * NOTE: We need to set ourself as the top result set
-		 * if this is not the 1st execution.  (Done in constructor
-		 * for 1st execution.)
 		 */
 		if (firstExecute)
 		{
@@ -223,10 +220,7 @@
 								constants.getStreamStorableHeapColIds(),
 								activation);
 		}
-		else
-		{
-			lcc.getStatementContext().setTopResultSet(this, subqueryTrackingArray);
-		}
+
 		/* decode the lock mode for the execution isolation level */
 		lockMode = decodeLockMode(constants.lockMode);
 

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteVTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteVTIResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteVTIResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/DeleteVTIResultSet.java
Fri Jan 29 11:49:09 2010
@@ -75,8 +75,6 @@
 	*/
 	protected void openCore() throws StandardException
 	{
-		lcc.getStatementContext().setTopResultSet(this, subqueryTrackingArray);
-
 		ExecRow row = getNextRowCore(sourceResultSet);
 
 		if (row != null)

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
Fri Jan 29 11:49:09 2010
@@ -885,9 +885,6 @@
                 long user_autoinc=0;
                         
 		/* Get or re-use the row changer.
-		 * NOTE: We need to set ourself as the top result set
-		 * if this is not the 1st execution.  (Done in constructor
-		 * for 1st execution.)
 		 */
 		if (firstExecute)
 		{
@@ -908,10 +905,6 @@
 							       );
 			rowChanger.setIndexNames(constants.indexNames);
 		}
-		else
-		{
-			lcc.getStatementContext().setTopResultSet(this, subqueryTrackingArray);
-		}
 
 		/* decode lock mode for the execution isolation level */
 		int lockMode = decodeLockMode(constants.lockMode);

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertVTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertVTIResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertVTIResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/InsertVTIResultSet.java
Fri Jan 29 11:49:09 2010
@@ -107,16 +107,6 @@
 			throw StandardException.unexpectedUserException(t);
 		}
 
-		/* Get or re-use the row changer.
-		 * NOTE: We need to set ourself as the top result set
-		 * if this is not the 1st execution.  (Done in constructor
-		 * for 1st execution.)
-		 */
-		if (! firstExecute)
-		{
-			lcc.getStatementContext().setTopResultSet(this, subqueryTrackingArray);
-		}
-
 		/* The source does not know whether or not we are doing a
 		 * deferred mode insert.  If we are, then we must clear the
 		 * index scan info from the activation so that the row changer

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/MiscResultSet.java
Fri Jan 29 11:49:09 2010
@@ -43,11 +43,8 @@
      * Construct a MiscResultSet
 	 *
 	 *  @param activation		Describes run-time environment.
-	 *
-	 *  @exception StandardException Standard Derby error policy.
      */
     MiscResultSet(Activation activation)
-		 throws StandardException
     {
 		super(activation);
 	}

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
Fri Jan 29 11:49:09 2010
@@ -60,7 +60,7 @@
 abstract class NoRowsResultSetImpl implements ResultSet
 {
 	final Activation    activation;
-	NoPutResultSet[]	subqueryTrackingArray;
+    private NoPutResultSet[] subqueryTrackingArray;
 
 	private final boolean statisticsTimingOn;
 	/** True if the result set has been opened, and not yet closed. */
@@ -82,7 +82,6 @@
     private DataValueDescriptor[]  normalizedGeneratedValues;
 
 	NoRowsResultSetImpl(Activation activation)
-		throws StandardException
 	{
 		this.activation = activation;
 
@@ -100,12 +99,6 @@
 		 */
 		beginTime = getCurrentTimeMillis();
 		beginExecutionTime = beginTime;
-
-		StatementContext sc = lcc.getStatementContext();
-		sc.setTopResultSet(this, (NoPutResultSet[]) null);
-
-		// Pick up any materialized subqueries
-		subqueryTrackingArray = sc.getSubqueryTrackingArray();
 	}
 
 	/**
@@ -116,6 +109,14 @@
 	 */
 	void setup() throws StandardException {
 		isOpen = true;
+
+        StatementContext sc = lcc.getStatementContext();
+        sc.setTopResultSet(this, subqueryTrackingArray);
+
+        // Pick up any materialized subqueries
+        if (subqueryTrackingArray == null) {
+            subqueryTrackingArray = sc.getSubqueryTrackingArray();
+        }
 	}
 
     /**

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/SetTransactionResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/SetTransactionResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/SetTransactionResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/SetTransactionResultSet.java
Fri Jan 29 11:49:09 2010
@@ -40,11 +40,8 @@
      * Construct a SetTransactionResultSet
 	 *
 	 *  @param activation		Describes run-time environment.
-	 *
-	 *  @exception StandardException Standard Derby error policy.
      */
     SetTransactionResultSet(Activation activation)
-		 throws StandardException
     {
 		super(activation);
 	}

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateResultSet.java
Fri Jan 29 11:49:09 2010
@@ -301,9 +301,6 @@
 		}
 
 		/* Get or re-use the row changer.
-		 * NOTE: We need to set ourself as the top result set
-		 * if this is not the 1st execution.  (Done in constructor
-		 * for 1st execution.)
 		 */
 		if (firstOpen)
 		{
@@ -324,10 +321,6 @@
 										 activation);
 			rowChanger.setIndexNames(constants.indexNames);
 		}
-		else
-		{
-			lcc.getStatementContext().setTopResultSet(this, subqueryTrackingArray);
-		}
 
 
 		/* Open the RowChanger before the source ResultSet so that

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateVTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateVTIResultSet.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateVTIResultSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/UpdateVTIResultSet.java
Fri Jan 29 11:49:09 2010
@@ -76,8 +76,6 @@
 
         if( null != row)
             rowLocationColumn = row.nColumns();
-		if (!firstExecute)
-			lcc.getStatementContext().setTopResultSet(this, subqueryTrackingArray);
 
 		/* The source does not know whether or not we are doing a
 		 * deferred mode insert.  If we are, then we must clear the

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java?rev=904472&r1=904471&r2=904472&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ResultSetsFromPreparedStatementTest.java
Fri Jan 29 11:49:09 2010
@@ -174,6 +174,8 @@
 
     private static final long DERBY_DEFAULT_TIMEOUT = 60;
 
+    private static final String SQLSTATE_NULL_INTO_NON_NULL = "23502";
+
     /**
      * Creates a String containing an insert statement for the
      * specified table containing the specified number of '?'
@@ -2611,4 +2613,30 @@
         stm.execute("SET SCHEMA " + schema);
         stm.close();
     }
+
+    /**
+     * Test case for DERBY-4488, where the third execution of a statement
+     * that attempted to insert a NULL into a non-nullable column failed with
+     * a NullPointerException.
+     */
+    public void testInsertNullIntoNonNullableColumn() throws SQLException {
+        setAutoCommit(false);
+
+        Statement s = createStatement();
+        s.execute("create table d4488_t1 (pk int primary key)");
+        s.execute("insert into d4488_t1 values 1");
+        s.execute("create table d4488_t2 (c1 int, c2 int not null)");
+        commit();
+
+        PreparedStatement ps = prepareStatement(
+                "insert into d4488_t2(c1) select 1 from d4488_t1");
+        for (int i = 0; i < 5; i++) {
+            // Expect this to fail, but not with NullPointerException.
+            assertStatementError(SQLSTATE_NULL_INTO_NON_NULL, ps);
+            // Need a rollback here in order to close the index scan on
+            // D4488_T1, otherwise the NPE won't reproduce. Alternatively,
+            // run with auto-commit enabled.
+            rollback();
+        }
+    }
 }



Mime
View raw message