db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r448961 [1/4] - in /db/derby/code/branches/10.2/java: demo/ drda/org/apache/derby/impl/drda/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/harness/ testing/org/apache/derbyTesting/functionTests/mast...
Date Fri, 22 Sep 2006 15:16:01 GMT
Author: rhillegas
Date: Fri Sep 22 08:15:58 2006
New Revision: 448961

URL: http://svn.apache.org/viewvc?view=rev&rev=448961
Log:
DERBY-1725: Merge the following patches from the trunk to the 10.2 branch: DERBY-1694 (447736),
DERBY-1589 (447644), DERBY-1588 (447502), DERBY-1784 (447469), DERBY-1326 (447462, 447375),
DERBY-1706 (447212), DERBY-1707 (447011), DERBY-1777 (446924), DERBY-1736 (446789).

Modified:
    db/derby/code/branches/10.2/java/demo/demo.html
    db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/optimizerOverrides.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/optimizerOverrides.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL2.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/grantRevokeDDL2.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/optimizerOverrides.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/predicatePushdown.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/synonym.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/declareGlobalTempTableJava.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL.sql
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL2.sql
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/grantRevokeDDL2_app.properties
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/optimizerOverrides.sql
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/predicatePushdown.sql
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/synonym.sql

Modified: db/derby/code/branches/10.2/java/demo/demo.html
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/demo/demo.html?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/demo/demo.html (original)
+++ db/derby/code/branches/10.2/java/demo/demo.html Fri Sep 22 08:15:58 2006
@@ -23,8 +23,10 @@
 <BODY>
 
 <H1>Example Apache Derby Programs</H1>
-<p>This directory contains example programs. For a complete description, see <A
href="http://db.apache.org/derby/manuals/index.html">Getting Started with Apache Derby</A>
the <A href="http://db.apache.org/derby/manuals/index.html">Apache Derby Server and
Administration Guide</A> and <A
-href="http://db.apache.org/derby/manuals/index.html">Working With Derby</A>
+<p>This directory contains example programs. For a complete description, 
+see <A href="../../docs/html/getstart/index.html">Getting Started with Apache Derby</A>,

+the <A href="../../docs/html/adminguide/index.html">Apache Derby Server and Administration
Guide</A> 
+and <A href="../../docs/html/workingwithderby/index.html">Working With Derby</A>
 .</p>
 <UL>
 	<LI><A href="simple/example.html">Simple</A>
@@ -32,13 +34,20 @@
                                 creates a database, and loads some data.</p></LI>
 </LI>
 <LI><A href="nserverdemo/readme.html">Network Server Sample Programs</A>
-	<p class="BodyRelative">Two examples are provided to demonstrate how to obtain an
<em class="Emphasis">embedded connection</em> and <em class="Emphasis">client
connections</em> using the Network Server to connect to the same database. An embedded
connection is a connection to a database that is booted in the same JVM as the application.
Client applications that require a database connection across the network use the network
server protocol (DRDA) to connect to the Network Server. This type of connection is referred
to as a client connection.</p></LI>
+	<p class="BodyRelative">Two examples are provided to demonstrate how to obtain an
<em class="Emphasis">embedded connection</em> 
+and <em class="Emphasis">client connections</em> using the Network Server to
connect to the same database. 
+An embedded connection is a connection to a database that is booted in the same JVM as the
application. 
+Client applications that require a database connection across the network use the network
server protocol (DRDA) 
+to connect to the Network Server. This type of connection is referred to as a client connection.</p></LI>
 <LI><A href="toursdb/toursdb_readme.html">ToursDB sample database schema</a>
-    <p class="BodyRelative">The toursdb is provided as an example and demo database
to illustrate some functionality of the Derby RDBMS. Many of the examples in the Derby documentation
use tables that exist in the toursdb database. The document describes the tables, the names
and types of columns in those tables, and the constraints, indexes, and triggers in the database.
+    <p class="BodyRelative">The toursdb is provided as an example and demo database
to illustrate some 
+functionality of the Derby RDBMS. Many of the examples in the Derby documentation use tables
that exist in the toursdb database. 
+The document describes the tables, the names and types of columns in those tables, and the
constraints, indexes, and triggers in the database.
     </p>
 </li>
 	<LI><A href="workingwithderby/readme.html">Working With Derby</A>
-        <p class="BodyRelative">Programs described and modified as part of the activities
documented in the <A href="../../docs/html/workingwithderby/index.html">Working With
Derby</A> manual.</p></LI>
+        <p class="BodyRelative">Programs described and modified as part of the activities
documented in 
+the <A href="../../docs/html/workingwithderby/index.html">Working With Derby</A>
manual.</p></LI>
 </LI>
 </UL>
 

Modified: db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Fri Sep 22 08:15:58 2006
@@ -752,11 +752,12 @@
 							runQueue.clear();
 						}
 
-						// Close and remove DRDAConnThreads on threadList.
-						for (int i = 0; i < threadList.size(); i++)
-							((DRDAConnThread)threadList.get(i)).close();
-						threadList.clear();
-						freeThreads = 0;
+						// DERBY-1326: There could be active threads that
+						// contain old/invalid sessions. These sessions won't
+						// be cleaned up until there is some activity on
+						// them. We could optimize this by going through
+						// sessionTable and closing the sessions' socket
+						// streams.
 
 						// Unload driver, then restart the server.
 						cloudscapeDriver = null;	// so it gets collected.

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
Fri Sep 22 08:15:58 2006
@@ -1069,10 +1069,20 @@
 		rcExpr = rc.getExpression();
 		colNum[0] = getColumnNumber();
 
-		while ((rcExpr != null) && (rcExpr instanceof ColumnReference))
+		/* We have to make sure we enter this loop if rc is redundant,
+		 * so that we can navigate down to the actual source result
+		 * set (DERBY-1777). If rc *is* redundant, then rcExpr is not
+		 * guaranteed to be a ColumnReference, so we have to check
+		 * for that case inside the loop.
+		 */
+		while ((rcExpr != null) &&
+			(rc.isRedundant() || (rcExpr instanceof ColumnReference)))
 		{
-			colNum[0] = ((ColumnReference)rcExpr).getColumnNumber();
-			rc = ((ColumnReference)rcExpr).getSource();
+			if (rcExpr instanceof ColumnReference)
+			{
+				colNum[0] = ((ColumnReference)rcExpr).getColumnNumber();
+				rc = ((ColumnReference)rcExpr).getSource();
+			}
 
 			/* If "rc" is redundant then that means it points to another
 			 * ResultColumn that in turn points to the source expression.

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
Fri Sep 22 08:15:58 2006
@@ -128,7 +128,8 @@
 	protected int[][] fkColArrays; 
 	protected Hashtable graphHashTable; 
                           // Hash Table which maitains the querytreenode graph 
-
+	protected TableName synonymTableName;
+	
 	/**
 	 * Initializer for a DMLModStatementNode -- delegate to DMLStatementNode
 	 *
@@ -229,6 +230,7 @@
 				TableName synonymTab = resolveTableToSynonym(targetTableName);
 				if (synonymTab == null)
 					throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, targetTableName);
+				synonymTableName = targetTableName;
 				targetTableName = synonymTab;
 				sdtc = getSchemaDescriptor(targetTableName.getSchemaName());
 
@@ -1567,6 +1569,50 @@
 								   dependentScan);
 	}
 
+	/**
+	 * Normalize synonym column references to have the name of the base table. 
+	 *
+	 * @param rcl	           The result column list of the target table
+	 * @param targetTableName  The target tablename
+	 *
+	 * @exception StandardException		Thrown on error
+	 */
+	public void normalizeSynonymColumns( 
+    ResultColumnList    rcl, 
+    TableName           targetTableName)
+		throws StandardException
+	{
+		if (synonymTableName == null) 
+            return;
+		
+		String synTableName = synonymTableName.getTableName();
+		
+		int	count = rcl.size();
+		for (int i = 0; i < count; i++)
+		{
+			ResultColumn    column    = (ResultColumn) rcl.elementAt(i);
+			ColumnReference	reference = column.getReference();
+
+			if ( reference != null )
+			{
+				String crTableName = reference.getTableName();
+				if ( crTableName != null )
+				{
+					if ( synTableName.equals( crTableName ) )
+					{
+						reference.setTableNameNode( targetTableName );
+					}
+					else
+					{
+						throw StandardException.newException(
+                                SQLState.LANG_TABLE_NAME_MISMATCH, 
+                                synTableName, 
+                                crTableName);
+					}
+				}
+			}
+		}
+	}
 }
 
 

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java
Fri Sep 22 08:15:58 2006
@@ -107,6 +107,10 @@
 		// Verify if REFERENCES_PRIV is granted to columns referenced
 		getCompilerContext().pushCurrentPrivType(getPrivType());
 
+		// Indicate that this statement has a dependency on the
+		// table which is referenced by this foreign key:
+		getCompilerContext().createDependency(td);
+
 		// If references clause doesn't have columnlist, get primary key info
 		if (refRcl.size()==0 && (td.getPrimaryKey() != null))
 		{

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
Fri Sep 22 08:15:58 2006
@@ -230,6 +230,7 @@
 			resultColumns = (ResultColumnList) arg3;
 		}
 
+		setOrigTableName(this.tableName);
 		templateColumns = resultColumns;
 	}
 
@@ -725,7 +726,6 @@
 				}
 				constraintSpecified = true;
 
-				/* Validate constraint name - NULL means table scan */
 				if (! StringUtil.SQLToUpperCase(value).equals("NULL"))
 				{
 					consDesc = 
@@ -816,9 +816,9 @@
 			}
 		}
 
-		/* If user specified a constraint name, then replace it in the 
-		 * properties list with the underlying index name to simplify
-		 * the code in the optimizer.
+		/* If user specified a non-null constraint name(DERBY-1707), then  
+		 * replace it in the properties list with the underlying index name to 
+		 * simplify the code in the optimizer.
 		 * NOTE: The code to get from the constraint name, for a constraint
 		 * with a backing index, to the index name is convoluted.  Given
 		 * the constraint name, we can get the conglomerate id from the
@@ -826,7 +826,7 @@
 		 * the ConglomerateDescriptor from the DataDictionary and, finally,
 		 * we get the index name (conglomerate name) from the ConglomerateDescriptor.
 		 */
-		if (constraintSpecified)
+		if (constraintSpecified && consDesc != null)
 		{
 			ConglomerateDescriptor cd = 
 				dDictionary.getConglomerateDescriptor(
@@ -2218,7 +2218,8 @@
 				fsq = (FromTable) getNodeFactory().getNode(
 					C_NodeTypes.FROM_SUBQUERY,
 					rsn, 
-					(correlationName != null) ? correlationName : tableName.getTableName(), 
+					(correlationName != null) ? 
+                        correlationName : getOrigTableName().getTableName(), 
 					resultColumns,
 					tableProperties,
 					getContextManager());
@@ -2231,6 +2232,7 @@
 				//privileges. This marking will make sure that we do not collect
 				//any privilege requirement for it.
 				fsq.disablePrivilegeCollection();
+				fsq.setOrigTableName(this.getOrigTableName());
 				return fsq.bindNonVTITables(dataDictionary, fromListParam);
 			}
 			finally
@@ -2390,6 +2392,7 @@
 			TableName synonymTab = resolveTableToSynonym(tableName);
 			if (synonymTab == null)
 				throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
+			
 			tableName = synonymTab;
 			sd = getSchemaDescriptor(tableName.getSchemaName());
 
@@ -2467,14 +2470,7 @@
 		** If there is a correlation name, use that instead of the
 		** table name.
 		*/
-		if (correlationName != null)
-		{
-			exposedTableName = makeTableName(null, correlationName);
-		}
-		else
-		{
-			exposedTableName = tableName;
-		}
+        exposedTableName = getExposedTableName();
 
         if(exposedTableName.getSchemaName() == null && correlationName == null)
             exposedTableName.bind(this.getDataDictionary());
@@ -3427,20 +3423,36 @@
 	}
 
 	/**
-	 * Return the exposed name for this table, which is the name that
-	 * can be used to refer to this table in the rest of the query.
+	 * Get the exposed name for this table, which is the name that can
+	 * be used to refer to it in the rest of the query.
+	 *
+	 * @return	The exposed name of this table.
 	 *
-	 * @return	The exposed name for this table.
 	 */
-
-	public String getExposedName()
+	public String getExposedName() 
 	{
 		if (correlationName != null)
 			return correlationName;
 		else
-			return tableName.getFullTableName();
+			return getOrigTableName().getFullTableName();
 	}
-
+	
+	/**
+	 * Get the exposed table name for this table, which is the name that can
+	 * be used to refer to it in the rest of the query.
+	 *
+	 * @return	TableName The exposed name of this table.
+	 *
+	 * @exception StandardException  Thrown on error
+	 */
+	private TableName getExposedTableName() throws StandardException  
+	{
+		if (correlationName != null)
+			return makeTableName(null, correlationName);
+		else
+			return getOrigTableName();
+	}
+	
 	/**
 	 * Return the table name for this table.
 	 *
@@ -3467,7 +3479,8 @@
 	public ResultColumnList getAllResultColumns(TableName allTableName)
 			throws StandardException
 	{
-		return getResultColumnsForList(allTableName, resultColumns, tableName);
+		return getResultColumnsForList(allTableName, resultColumns, 
+				getOrigTableName());
 	}
 
 	/**
@@ -3492,14 +3505,7 @@
 		 * The exposed name becomes the qualifier for each column
 		 * in the expanded list.
 		 */
-		if (correlationName == null)
-		{
-			exposedName = tableName;
-		}
-		else
-		{
-			exposedName = makeTableName(null, correlationName);
-		}
+		exposedName = getExposedTableName();
 
 		/* Add all of the columns in the table */
 		rcList = (ResultColumnList) getNodeFactory().getNode(
@@ -3568,14 +3574,7 @@
 		 * The exposed name becomes the qualifier for each column
 		 * in the expanded list.
 		 */
-		if (correlationName == null)
-		{
-			exposedName = tableName;
-		}
-		else
-		{
-			exposedName = makeTableName(null, correlationName);
-		}
+		exposedName = getExposedTableName();
 
 		/* Add all of the columns in the table */
 		ResultColumnList newRcl = (ResultColumnList) getNodeFactory().getNode(

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromTable.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
Fri Sep 22 08:15:58 2006
@@ -118,6 +118,9 @@
 	protected static final short ADD_PLAN = 1;
 	protected static final short LOAD_PLAN = 2;
 
+	/** the original unbound table name */
+	protected TableName origTableName;
+	
 	/**
 	 * Initializer for a table in a FROM list.
 	 *
@@ -1491,5 +1494,29 @@
 	public boolean needsSpecialRCLBinding()
 	{
 		return false;
+	}
+	
+	/**
+	 * Sets the original or unbound table name for this FromTable.  
+	 * 
+	 * @param tableName the unbound table name
+	 *
+	 */
+	public void setOrigTableName(TableName tableName) 
+	{
+		this.origTableName = tableName;
+	}
+	
+	/**
+	 * Gets the original or unbound table name for this FromTable.  
+	 * The tableName field can be changed due to synonym resolution.
+	 * Use this method to retrieve the actual unbound tablename.
+	 * 
+	 * @return TableName the original or unbound tablename
+	 *
+	 */
+	public TableName getOrigTableName() 
+	{
+		return this.origTableName;
 	}
 }

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
Fri Sep 22 08:15:58 2006
@@ -264,6 +264,14 @@
 		 */
 		if (targetColumnList != null)
 		{
+			/*
+			 * Normalize synonym qualifers for column references.
+			 */
+			if (synonymTableName != null)
+			{
+				normalizeSynonymColumns ( targetColumnList, targetTableName );
+			}
+			
 			/* Bind the target column list */
 			getCompilerContext().pushCurrentPrivType( getPrivType());
 			if (targetTableDescriptor != null)
@@ -861,4 +869,5 @@
 			cc.createDependency(cds[index]);
 		}
 	}
+	
 } // end of class InsertNode

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
Fri Sep 22 08:15:58 2006
@@ -454,18 +454,21 @@
 					firstLookOrder[i] = bestJoinOrder[i];
 				permuteState = JUMPING;
 
-				// If we were in the middle of a join order when this
-				// happened, then reset the join order before jumping.
-				// The call to rewindJoinOrder() here will put joinPosition
-				// back to 0.  But that said, we'll then end up incrementing 
-				// joinPosition before we start looking for the next join
-				// order (see below), which means we need to set it to -1
-				// here so that it gets incremented to "0" and then
-				// processing can continue as normal from there.  Note:
-				// we don't need to set reloadBestPlan to true here
-				// because we only get here if we have *not* found a
-				// best plan yet.
-				if (joinPosition > 0)
+				/* If we already assigned at least one position in the
+				 * join order when this happened (i.e. if joinPosition
+				 * is greater than *or equal* to zero; DERBY-1777), then 
+				 * reset the join order before jumping.  The call to
+				 * rewindJoinOrder() here will put joinPosition back
+				 * to 0.  But that said, we'll then end up incrementing
+				 * joinPosition before we start looking for the next
+				 * join order (see below), which means we need to set
+				 * it to -1 here so that it gets incremented to "0" and
+				 * then processing can continue as normal from there.  
+				 * Note: we don't need to set reloadBestPlan to true
+				 * here because we only get here if we have *not* found
+				 * a best plan yet.
+				 */
+				if (joinPosition >= 0)
 				{
 					rewindJoinOrder();
 					joinPosition = -1;
@@ -1672,6 +1675,18 @@
 				optimizableList.getOptimizable(
 					proposedJoinOrder[joinPosition - 1]).
 						getBestAccessPath().getCostEstimate();
+		}
+
+		/* At this point outerCost should be non-null (DERBY-1777).
+		 * Do the assertion here so that we catch it right away;
+		 * otherwise we'd end up with an NPE somewhere further
+		 * down the tree and it'd be harder to figure out where
+		 * it came from.
+		 */
+		if (SanityManager.DEBUG)
+		{
+			SanityManager.ASSERT(outerCost != null,
+				"outerCost is not expected to be null");
 		}
 
 		Optimizable optimizable = optimizableList.getOptimizable(proposedJoinOrder[joinPosition]);

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
Fri Sep 22 08:15:58 2006
@@ -1506,7 +1506,12 @@
 			getLanguageConnectionContext().getTransactionCompile(), raiseError);
 
 		if (isCurrent || isCompilation) {
-			if (sdCatalog != null)
+			//if we are dealing with a SESSION schema and it is not physically
+			//created yet, then it's uuid is going to be null. DERBY-1706
+			//Without the getUUID null check below, following will give NPE
+			//set schema session; -- session schema has not been created yet
+			//create table t1(c11 int);
+			if (sdCatalog != null && sdCatalog.getUUID() != null)
 			{
 				// different UUID for default (current) schema than in catalog,
 				// so reset default schema.

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
Fri Sep 22 08:15:58 2006
@@ -208,7 +208,10 @@
 		{
 			TableName synonymTab = resolveTableToSynonym(this.targetTableName);
 			if (synonymTab != null)
-				this.targetTableName = synonymTab;
+			{
+				this.synonymTableName = targetTableName;
+				this.targetTableName  = synonymTab;
+			}
 		}
 
 		bindTables(dataDictionary);
@@ -342,6 +345,10 @@
 		SanityManager.ASSERT(resultFromList.size() == 1,
 			"More than one table in result from list in an update.");
 
+		/* Normalize the SET clause's result column list for synonym */
+		if (synonymTableName != null)
+			normalizeSynonymColumns( resultSet.resultColumns, targetTable );
+		
 		/* Bind the original result columns by column name */
 		normalizeCorrelatedColumns( resultSet.resultColumns, targetTable );
 
@@ -1094,6 +1101,38 @@
 			 */
 			column.clearTableName();
 		}
+	}
+	
+	/**
+	 * Normalize synonym column references to have the name of the base table. 
+	 *
+	 * @param rcl	    The result column list of the target table
+	 * @param fromTable The table name to set the column refs to
+	 * 
+	 * @exception StandardException		Thrown on error
+	 */
+	private	void normalizeSynonymColumns(
+    ResultColumnList    rcl, 
+    FromTable           fromTable)
+		throws StandardException
+	{
+		if (fromTable.getCorrelationName() != null) 
+        { 
+            return; 
+        }
+		
+		TableName tableNameNode;
+		if (fromTable instanceof CurrentOfNode)
+		{ 
+			tableNameNode = 
+                ((CurrentOfNode) fromTable).getBaseCursorTargetTableName(); 
+		}
+		else 
+		{ 
+			tableNameNode = makeTableName(null, fromTable.getBaseTableName()); 
+		}
+		
+		super.normalizeSynonymColumns(rcl, tableNameNode);
 	}
 	
 } // end of UpdateNode

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/harness/ProcessStreamResult.java
Fri Sep 22 08:15:58 2006
@@ -32,11 +32,30 @@
 	protected OutputStreamWriter outStream;
 	// Encoding to be used to read output of test jvm process
 	protected String encoding;
+
+    /**
+     * Flag to find out if the work was finished 
+     * successfully without being interrupted 
+     * in between because of a timeout setting
+     */
 	protected boolean finished;
 	protected IOException ioe;
 	protected Thread myThread;
 	protected long startTime;
+    
+    /**
+     * Flag to keep state of whether the myThread has timed out.
+     * When interrupted is true, the myThread will exit 
+     * from its work. 
+     */
 	protected boolean interrupted;
+    
+    /**
+     * time in minutes for myThread to timeout in case it 
+     * has not finished its work before that.
+     * timeout handling only comes into effect only when Wait()
+     * is called.
+     */
 	protected int timeout;
 
 	public ProcessStreamResult(InputStream in, BufferedOutputStream bos,
@@ -92,7 +111,10 @@
         	else
         		inStream = new InputStreamReader(in);
 			
-			while ((valid = inStream.read(ca, 0, ca.length)) != -1)
+            // keep reading from the stream as long as we have not 
+            // timed out
+			while (((valid = inStream.read(ca, 0, ca.length)) != -1) &&
+                    !interrupted)
 			{
 			    //System.out.println("Still reading thread: " + tname);
 /*				if (timeout > 0) {
@@ -124,17 +146,51 @@
 			//ioe.printStackTrace();
 		}
 
+        // if we timed out, then just leave
+        if ( interrupted )
+            return;
+        
 		synchronized (this)
 		{
+            // successfully finished the work, notifyAll and leave.
 			finished = true;
 			notifyAll();
 		}
 	}
 
+    /**
+     * Wait till the myThread has finished its work or incase a timeout was set on this 
+     * object, then to set a flag to indicate the myThread to leave at the end of the 
+     * timeout period.
+     * 
+     * Behavior is as follows:
+     * 1) If timeout is set to a valid value (>0) - in this case, if myThread has not
+     * finished its work by the time this method was called, then it will wait
+     * till the timeout has elapsed or if the myThread has finished its work.
+     * 
+     * 2)If timeout is not set ( <= 0) - in this case, if myThread has not
+     * finished its work by the time this method was called, then it will wait
+     * till myThread has finished its work.
+     * 
+     * If timeout is set to a valid value, and the timeout amount of time has elapsed, 
+     * then the interrupted  flag is set to true to indicate that it is time for the 
+     * myThread to stop its work and leave.
+     *
+     * @return true if the timeout happened before myThread work was finished
+     *         else false
+     * @throws IOException
+     */
 	public boolean Wait() throws IOException
 	{
 	    synchronized(this)
 	    {
+            // It is possible that we have finished the work 
+            // by the time this method Wait() was called,
+            // so need to check if that is the case, before we
+            // go into a wait.
+            if ( finished )
+                return interrupted;
+            
 			if (timeout > 0) {
 				long millis = System.currentTimeMillis();
 
@@ -144,18 +200,32 @@
 
 				if (mins > timeout)
 				{
+                    interrupted = true;
 					return interrupted;
 				}
 			}
 			try
 			{
-				while (!finished && !interrupted)
-				{
-					wait();
-				}
-			}
+                // find timeout in milliseconds
+                long timeoutms = timeout * 60 *1000L;
+                
+                if ( timeout > 0 )
+                    // wait till notified or till timeoutms has elapsed
+                    wait(timeoutms);
+                else
+                    wait(); // wait till notified
+                
+                // if myThread didnt finish its work and we reached
+                // here, that means we just timedout. 
+                // In that case, indicate that we were interrupted and leave.
+                // myThread will read the value of interrupted and 
+                // stop its work and leave.
+    		    if ( !finished )
+                    interrupted = true;
+            }
 			catch (InterruptedException ie)
 			{
+                interrupted = true;
 				System.out.println("Interrupted: " + ie.toString());
 			}
 	    }

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/optimizerOverrides.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/optimizerOverrides.out?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/optimizerOverrides.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/optimizerOverrides.out
Fri Sep 22 08:15:58 2006
@@ -355,6 +355,58 @@
 	None
 		qualifiers:
 None
+ij> select * from t1 --derby-properties constraint = null
+;
+C1 |C2 |C3         
+-----
+1 |1 |1          
+2 |2 |2          
+3 |3 |3          
+4 |4 |4          
+ij> values SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();
+1                                                                                       
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         

                                    
+-----
+Statement Name: 
+	SQL_CURSH200C1
+Statement Text: 
+	select * from t1 --derby-properties constraint = null
+Parse Time: 0
+Bind Time: 0
+Optimize Time: 0
+Generate Time: 0
+Compile Time: 0
+Execute Time: 0
+Begin Compilation Timestamp : null
+End Compilation Timestamp : null
+Begin Execution Timestamp : null
+End Execution Timestamp : null
+Statement Execution Plan Text: 
+User supplied optimizer overrides on T1 are { constraint=NULL }
+Index Scan ResultSet for T1 using index T1_C1C2C3 at read committed isolation level using
instantaneous share row locking chosen by the optimizer
+Number of opens = 1
+Rows seen = 4
+Rows filtered = 0
+Fetch Size = 16
+	constructor time (milliseconds) = 0
+	open time (milliseconds) = 0
+	next time (milliseconds) = 0
+	close time (milliseconds) = 0
+	next time in milliseconds/row = 0
+scan information: 
+	Bit set of columns fetched={0, 1, 2}
+	Number of columns fetched=3
+	Number of deleted rows visited=0
+	Number of pages visited=1
+	Number of rows qualified=4
+	Number of rows visited=4
+	Scan type=btree
+	Tree height=1
+	start position: 
+	None
+	stop position: 
+	None
+	qualifiers:
+None
 ij> -- constraint which includes columns in for update of list
 select * from t1 --derby-properties constraint = cons1 
 for update;

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
Fri Sep 22 08:15:58 2006
@@ -85,6 +85,7 @@
 IDENTITY_VAL_LOCAL=2
 IDENTITY_VAL_LOCAL=3
 End testPoolReset XADataSource
+ERROR XJ015: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ015, SQLERRMC: Derby system shutdown.
 Running connection checks on DriverManager 
   isolation level 2
   auto commit     true

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
Fri Sep 22 08:15:58 2006
@@ -100,6 +100,7 @@
 IDENTITY_VAL_LOCAL=2
 IDENTITY_VAL_LOCAL=3
 End testPoolReset XADataSource
+ERROR XJ015: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ015, SQLERRMC: Derby system shutdown.
 Running JDBC 3.0 connection checks on DriverManager 
   holdability     true
 JDBC 3.0 savepoint SQL Exception: (XJ010) Cannot issue savepoint when autoCommit is on.

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/optimizerOverrides.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/optimizerOverrides.out?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/optimizerOverrides.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/optimizerOverrides.out
Fri Sep 22 08:15:58 2006
@@ -356,6 +356,58 @@
 	None
 		qualifiers:
 None
+ij> select * from t1 --derby-properties constraint = null
+;
+C1 |C2 |C3         
+-----
+1 |1 |1          
+2 |2 |2          
+3 |3 |3          
+4 |4 |4          
+ij> values SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();
+1                                                                                       
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         
                                                                                         

                                    
+-----
+Statement Name: 
+	SQL_CURLH000C1
+Statement Text: 
+	select * from t1 --derby-properties constraint = null
+Parse Time: 0
+Bind Time: 0
+Optimize Time: 0
+Generate Time: 0
+Compile Time: 0
+Execute Time: 0
+Begin Compilation Timestamp : null
+End Compilation Timestamp : null
+Begin Execution Timestamp : null
+End Execution Timestamp : null
+Statement Execution Plan Text: 
+User supplied optimizer overrides on T1 are { constraint=NULL }
+Index Scan ResultSet for T1 using index T1_C1C2C3 at read committed isolation level using
instantaneous share row locking chosen by the optimizer
+Number of opens = 1
+Rows seen = 4
+Rows filtered = 0
+Fetch Size = 16
+	constructor time (milliseconds) = 0
+	open time (milliseconds) = 0
+	next time (milliseconds) = 0
+	close time (milliseconds) = 0
+	next time in milliseconds/row = 0
+scan information: 
+	Bit set of columns fetched={0, 1, 2}
+	Number of columns fetched=3
+	Number of deleted rows visited=0
+	Number of pages visited=1
+	Number of rows qualified=4
+	Number of rows visited=4
+	Scan type=btree
+	Tree height=1
+	start position: 
+	None
+	stop position: 
+	None
+	qualifiers:
+None
 ij> -- constraint which includes columns in for update of list
 select * from t1 --derby-properties constraint = cons1 
 for update;

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/declareGlobalTempTableJava.out
Fri Sep 22 08:15:58 2006
@@ -1,4 +1,6 @@
 Test declaredGlobalTempTableJava starting
+TEST-DERBY1706 : Create a persistent object in SESSION schema w/o first creating the schema
+TEST-DERBY1706 PASSED
 TEST1 : global temporary tables can only be in SESSION schema
 Expected message: The qualifier for a declared global temporary table name must be SESSION.
 TEST1 PASSED

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out?view=diff&rev=448961&r1=448960&r2=448961
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/grantRevokeDDL.out
Fri Sep 22 08:15:58 2006
@@ -3045,4 +3045,36 @@
 2 rows inserted/updated/deleted
 ij(MAMTA1)> commit;
 ij(MAMTA1)> autocommit on;
-ij(MAMTA1)> 
+ij(MAMTA1)> -- Simple test case for DERBY-1589. The problem here involves dependency
+-- management between the FOREIGN KEY clause in the CREATE TABLE statement
+-- and the underlying table that the FK refers to. The statement must
+-- declare a dependency on the referenced table so that changes to the table
+-- cause invalidation of the statement's compiled plan. The test case below
+-- sets up such a situation by dropping the referenced table and recreating
+-- it and then re-issuing a statement with identical text to one which
+-- was issued earlier.
+set connection mamta1;
+ij(MAMTA1)> create table d1589t11ConstraintTest (c111 int not null, c112 int not null,
primary key (c111, c112));
+0 rows inserted/updated/deleted
+ij(MAMTA1)> grant references on d1589t11ConstraintTest to mamta3;
+0 rows inserted/updated/deleted
+ij(MAMTA1)> set connection mamta3;
+ij(MAMTA3)> drop table d1589t31ConstraintTest;
+ERROR: Failed with SQLSTATE 42Y55
+ij(MAMTA3)> create table d1589t31ConstraintTest (c311 int, c312 int, foreign key(c311,
c312) references mamta1.d1589t11ConstraintTest);
+0 rows inserted/updated/deleted
+ij(MAMTA3)> drop table d1589t31ConstraintTest;
+0 rows inserted/updated/deleted
+ij(MAMTA3)> set connection mamta1;
+ij(MAMTA1)> drop table d1589t11ConstraintTest;
+0 rows inserted/updated/deleted
+ij(MAMTA1)> create table d1589t11ConstraintTest (c111 int not null, c112 int not null,
primary key (c111, c112));
+0 rows inserted/updated/deleted
+ij(MAMTA1)> grant references(c111) on d1589t11ConstraintTest to mamta3;
+0 rows inserted/updated/deleted
+ij(MAMTA1)> grant references(c112) on d1589t11ConstraintTest to PUBLIC;
+0 rows inserted/updated/deleted
+ij(MAMTA1)> set connection mamta3;
+ij(MAMTA3)> create table d1589t31ConstraintTest (c311 int, c312 int, foreign key(c311,
c312) references mamta1.d1589t11ConstraintTest);
+0 rows inserted/updated/deleted
+ij(MAMTA3)> 



Mime
View raw message