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 dj...@apache.org on 2005/05/12 17:53:22 UTC

svn commit: r169838 [1/3] - in /incubator/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/ engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/impl/sql/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/functionTests/master/jdk14/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ testing/org/apache/derbyTesting/functionTests/tests/lang/

Author: djd
Date: Thu May 12 08:53:20 2005
New Revision: 169838

URL: http://svn.apache.org/viewcvs?rev=169838&view=rev
Log:
Fix Derby-189


I have a new patch for this bug which also fixes the problem you
brought up with sql select * from a.t as X. The fix for this required
change in impl.sql.compile.FromBaseTable's method genResultColList().
I changed the code such that we set the TableDescriptor on the
ColumnDescriptor instance. This TableDescriptor is later used by
ResultColumn.getTableName to get the base table name of the column. In
addition to that, I changed ColumnReference.getSourceTableName and
ColumnReference.getSourceSchemaName so that they don't look at the
user supplied correlation name (if any) to fetch the base table/schema
name.

Patch contributed by Mamta Satoor msatoor@gmail.com

Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
    incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultset.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/updatableResultSet.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultset.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatableResultSet.java

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ResultColumnDescriptor.java Thu May 12 08:53:20 2005
@@ -47,22 +47,39 @@
 	String	getName();
 
 	/**
-	 * Get the name of the schema the Column is in, if any.
+	 * Get the name of the schema for the Column's base table, if any.
+	 * Following example queries will all return APP (assuming user is in schema APP)
+	 * select t.a from t
+	 * select b.a from t as b
+	 * select app.t.a from t
 	 *
-	 * @return	A String containing the name of the schema the Column
-	 *		is in.  If the column is not in a schema (i.e. is a
-	 * 		derived column), it returns NULL.
+	 * @return	The name of the schema of the Column's base table. If the column
+	 *		is not in a schema (i.e. is a derived column), it returns NULL.
 	 */
-	String	getSchemaName();
+	String	getSourceSchemaName();
 
 	/**
-	 * Get the name of the table the Column is in, if any.
+	 * Get the name of the underlying(base) table this column comes from, if any.
+	 * Following example queries will all return T
+	 * select a from t
+	 * select b.a from t as b
+	 * select t.a from t
 	 *
-	 * @return	A String containing the name of the table the Column
+	 * @return	A String containing the name of the base table of the Column
 	 *		is in. If the column is not in a table (i.e. is a
 	 * 		derived column), it returns NULL.
+	 * @return	The name of the Column's base table. If the column
+	 *		is not in a schema (i.e. is a derived column), it returns NULL.
 	 */
 	String	getSourceTableName();
+
+	/**
+	 * Return true if the column is wirtable by a positioned update.
+	 *
+	 * @return TRUE, if the column is a base column of a table and is 
+	 * writable by a positioned update.
+	 */
+	boolean updatableByCursor();
 
 	/**
 	 * Get the position of the Column.

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ColumnDescriptor.java Thu May 12 08:53:20 2005
@@ -104,7 +104,7 @@
 			this.table = table;
 			this.uuid = table.getUUID();
 		}
-		
+
 		if (SanityManager.DEBUG)
 		{
 			if (autoinc)
@@ -136,7 +136,7 @@
 	 *							(null if no default)
 	 * @param columnDefaultInfo		The default info for the column.
 	 * @param uuid			A uuid for the object that this column
-	 *						is in. 
+	 *						is in.
 	 * @param defaultUUID			The UUID for the default, if any.
 	 * @param autoincStart	Start value for an autoincrement column.
 	 * @param autoincInc	Increment for autoincrement column
@@ -145,8 +145,8 @@
 	public ColumnDescriptor(String columnName, int columnPosition,
 		DataTypeDescriptor columnType, DataValueDescriptor columnDefault,
 		DefaultInfo columnDefaultInfo,
-		UUID uuid, 
-		UUID defaultUUID, 
+		UUID uuid,
+		UUID defaultUUID,
         long autoincStart, long autoincInc, boolean autoinc)
 
 	{
@@ -220,7 +220,7 @@
 	}
 
 	/**
-	 * Sets the the column name in case of rename column.
+	 * Sets the column name in case of rename column.
 	 *
 	 * @param newColumnName	The new column name.
 	 */
@@ -230,6 +230,16 @@
 	}
 
 	/**
+	 * Sets the table descriptor for the column.
+	 *
+	 * @param tableDescriptor	The table descriptor for this column
+	 */
+	public void	setTableDescriptor(TableDescriptor tableDescriptor)
+	{
+		this.table = tableDescriptor;
+	}
+
+	/**
 	 * Get the ordinal position of the column (1 based)
 	 *
 	 * @return	The ordinal position of the column.
@@ -325,6 +335,10 @@
 	public boolean isAutoincrement()
 	{
 		return (autoincInc != 0);
+	}
+	public boolean updatableByCursor()
+	{
+		return false;
 	}
 
 	/**

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Thu May 12 08:53:20 2005
@@ -2043,11 +2043,19 @@
       //1)Make sure for updateXXX methods, the column position is not out of range
       ResultDescription rd = theResults.getResultDescription();
       if (columnIndex < 1 || columnIndex > rd.getColumnCount())
-        throw Util.generateCsSQLException(SQLState.LANG_INVALID_COLUMN_POSITION, new Integer(columnIndex), String.valueOf(rd.getColumnCount()));
+        throw Util.generateCsSQLException(SQLState.LANG_INVALID_COLUMN_POSITION,
+					new Integer(columnIndex), String.valueOf(rd.getColumnCount()));
 
       //2)Make sure the column corresponds to a column in the base table and it is not a derived column
       if (rd.getColumnDescriptor(columnIndex).getSourceTableName() == null)
-        throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TABLE, methodName);
+        throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TABLE,
+					methodName);
+
+      //3)If column not updatable then throw an exception
+      if (!getMetaData().isWritable(columnIndex))
+        throw Util.generateCsSQLException(SQLState.LANG_COLUMN_NOT_UPDATABLE_IN_CURSOR,
+					theResults.getResultDescription().getColumnDescriptor(columnIndex).getName(),
+					getCursorName());
 	}
 
 	//do following few checks before accepting updatable resultset api
@@ -3153,6 +3161,8 @@
             boolean foundOneColumnAlready = false;
             StringBuffer updateWhereCurrentOfSQL = new StringBuffer("UPDATE ");
             CursorActivation activation = getEmbedConnection().getLanguageConnection().lookupCursorActivation(getCursorName());
+
+
             ExecCursorTableReference targetTable = activation.getPreparedStatement().getTargetTable();
             updateWhereCurrentOfSQL.append(getFullBaseTableName(targetTable));//got the underlying (schema.)table name
             updateWhereCurrentOfSQL.append(" SET ");

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java Thu May 12 08:53:20 2005
@@ -204,7 +204,7 @@
 	public String getSchemaName(int column) throws SQLException	{
 		ResultColumnDescriptor cd = columnInfo[column - 1];
 
-		String s = cd.getSchemaName();
+		String s = cd.getSourceSchemaName();
 		// database returns null when no schema name to differentiate from empty name
 		return (s==null? "" : s);
 	}
@@ -308,9 +308,7 @@
      */
 	public boolean isWritable(int column) throws SQLException {
 		validColumnNumber(column);
-
-		// we just don't know if it is a base table column or not
-		return false;
+		return columnInfo[column - 1].updatableByCursor();
 	}
 
     /**

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericColumnDescriptor.java Thu May 12 08:53:20 2005
@@ -66,6 +66,7 @@
 	private int					columnPos;
 	private DataTypeDescriptor	type;
 	private boolean 			isAutoincrement;
+	private boolean 			updatableByCursor;
 
 	/**
 	 * Niladic constructor for Formatable
@@ -92,10 +93,11 @@
 	{
 		name = rcd.getName();
 		tableName = rcd.getSourceTableName();
-		schemaName = rcd.getSchemaName();
+ 		schemaName = rcd.getSourceSchemaName();
 		columnPos = rcd.getColumnPosition();
 		type = rcd.getType();
 		isAutoincrement = rcd.isAutoincrement();
+		updatableByCursor = rcd.updatableByCursor();
 	}
 
 	/**
@@ -121,23 +123,29 @@
 	}
 
 	/**
-	 * Get the name of the schema the Column is in, if any.
+	 * Get the name of the schema for the Column's base table, if any.
+	 * Following example queries will all return APP (assuming user is in schema APP)
+	 * select t.a from t
+	 * select b.a from t as b
+	 * select app.t.a from t
 	 *
-	 * @return	A String containing the name of the schema the Column
-	 *		is in.  If the column is not in a schema (i.e. is a
-	 * 		derived column), it returns NULL.
+	 * @return	A String containing the name of the schema of the Column's table.
+	 *		If the column is not in a schema (i.e. is a derived column), it returns NULL.
 	 */
-	public String	getSchemaName()
+	public String	getSourceSchemaName()
 	{
 		return schemaName;
 	}
 
 	/**
-	 * Get the name of the table the Column is in, if any.
+	 * Get the name of the underlying(base) table this column comes from, if any.
+	 * Following example queries will all return T
+	 * select a from t
+	 * select b.a from t as b
+	 * select t.a from t
 	 *
-	 * @return	A String containing the name of the table the Column
-	 *		is in. If the column is not in a table (i.e. is a
-	 * 		derived column), it returns NULL.
+	 * @return	A String containing the name of the Column's base table.
+	 *		If the column is not in a table (i.e. is a derived column), it returns NULL.
 	 */
 	public String	getSourceTableName()
 	{
@@ -161,6 +169,11 @@
 		return isAutoincrement;
 	}
 
+	public boolean updatableByCursor()
+	{
+		return updatableByCursor;
+	}
+
 	//////////////////////////////////////////////
 	//
 	// FORMATABLE
@@ -182,6 +195,7 @@
 		fh.putInt("columnPos", columnPos);
 		fh.put("type", type);
 		fh.putBoolean("isAutoincrement", isAutoincrement);
+		fh.putBoolean("updatableByCursor", updatableByCursor);
 		out.writeObject(fh);
 		return;
 	}	
@@ -205,6 +219,7 @@
 		columnPos = fh.getInt("columnPos");
 		type = (DataTypeDescriptor)fh.get("type");
 		isAutoincrement = fh.getBoolean("isAutoincrement");
+		updatableByCursor = fh.getBoolean("updatableByCursor");
 	}
 	
 	/**

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java Thu May 12 08:53:20 2005
@@ -111,6 +111,8 @@
 	/**
 	 * Get the user-supplied table name of this column.  This will be null
 	 * if the user did not supply a name (for example, select a from t).
+	 * The method will return B for this example, select b.a from t as b
+	 * The method will return T for this example, select t.a from t
 	 *
 	 * @return	The user-supplied name of this column.  Null if no user-
 	 * 		supplied name.
@@ -119,6 +121,19 @@
 	public String getTableName()
 	{
 		return ( ( tableName != null) ? tableName.getTableName() : null );
+	}
+
+	/**
+	 * Get the user-supplied schema name for this column's table. This will be null
+	 * if the user did not supply a name (for example, select t.a from t).
+	 * Another example for null return value (for example, select b.a from t as b).
+	 * But for following query select app.t.a from t, this will return APP
+	 *
+	 * @return	The schema name for this column's table
+	 */
+	public String getSchemaName() throws StandardException
+	{
+		return ( ( tableName != null) ? tableName.getSchemaName() : null );
 	}
 
 	/**

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java Thu May 12 08:53:20 2005
@@ -489,6 +489,8 @@
 	/**
 	 * Get the user-supplied table name of this column.  This will be null
 	 * if the user did not supply a name (for example, select a from t).
+	 * The method will return B for this example, select b.a from t as b
+	 * The method will return T for this example, select t.a from t
 	 *
 	 * @return	The user-supplied name of this column.  Null if no user-
 	 * 		supplied name.
@@ -500,16 +502,45 @@
 	}
 
 	/**
-	 * Get the name of the table this column comes from.
+	 * Get the name of the underlying(base) table this column comes from, if any.
+	 * Following example queries will all return T
+	 * select a from t
+	 * select b.a from t as b
+	 * select t.a from t
 	 *
-	 * @return	The name of the table that this column comes from.  
+	 * @return	The name of the base table that this column comes from.
 	 *			Null if not a ColumnReference.
 	 */
 
 	public String getSourceTableName()
 	{
-		return ( ( tableName != null) ? tableName.getTableName() : 
-					((source != null) ? source.getTableName() : null));
+		return ((source != null) ? source.getTableName() : null);
+	}
+
+	/**
+	 * Get the name of the schema for the Column's base table, if any.
+	 * Following example queries will all return APP (assuming user is in schema APP)
+	 * select t.a from t
+	 * select b.a from t as b
+	 * select app.t.a from t
+	 *
+	 * @return	The name of the schema for Column's base table. If the column
+	 *		is not in a schema (i.e. is a derived column), it returns NULL.
+	 */
+	public String getSourceSchemaName() throws StandardException
+	{
+		return ((source != null) ? source.getSchemaName() : null);
+	}
+
+	/**
+	 * Is the column wirtable by the cursor or not. (ie, is it in the list of FOR UPDATE columns list)
+	 *
+	 * @return TRUE, if the column is a base column of a table and is 
+	 * writable by cursor.
+	 */
+	public boolean updatableByCursor()
+	{
+		return ((source != null) ? source.updatableByCursor() : false);
 	}
 
 	/**
@@ -943,6 +974,9 @@
 	/**
 	 * Get the user-supplied schema name of this column.  This will be null
 	 * if the user did not supply a name (for example, select t.a from t).
+	 * Another example for null return value (for example, select b.a from t as b).
+	 * But for following query select app.t.a from t, this will return APP
+	 * Code generation of aggregate functions relies on this method
 	 *
 	 * @return	The user-supplied schema name of this column.  Null if no user-
 	 * 		supplied name.

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java Thu May 12 08:53:20 2005
@@ -295,7 +295,7 @@
 			if (updateMode == READ_ONLY)
 				updatableColumns = null; // don't need them any more
 		}
-	
+
 		// bind the update columns
 		if (updateMode == UPDATE)
 		{
@@ -308,6 +308,11 @@
 			if (updateTable instanceof FromTable)
 			{
 				((FromTable) updateTable).markUpdatableByCursor(updatableColumns);
+				//make sure that alongwith the FromTable, we keep other ResultSetLists
+				//in correct state too. ResultSetMetaData.isWritable looks at this to
+				//return the correct value.
+				resultSet.getResultColumns().markColumnsInSelectListUpdatableByCursor(
+					updatableColumns);
 			}
 		}
 

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Thu May 12 08:53:20 2005
@@ -3459,6 +3459,12 @@
 		{
 			/* Build a ResultColumn/BaseColumnNode pair for the column */
 			colDesc = (ColumnDescriptor) cdl.elementAt(index);
+			//A ColumnDescriptor instantiated through SYSCOLUMNSRowFactory only has 
+			//the uuid set on it and no table descriptor set on it. Since we know here
+			//that this columnDescriptor is tied to tableDescriptor, set it so using
+			//setTableDescriptor method. ColumnDescriptor's table descriptor is used
+			//to get ResultSetMetaData.getTableName & ResultSetMetaData.getSchemaName
+			colDesc.setTableDescriptor(tableDescriptor);
 
 			valueNode = (ValueNode) getNodeFactory().getNode(
 											C_NodeTypes.BASE_COLUMN_NODE,

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Thu May 12 08:53:20 2005
@@ -85,6 +85,8 @@
 	String			exposedName;
 	String			tableName;
 	String			sourceTableName;
+	//Used by metadata api ResultSetMetaData.getSchemaName to get a column's table's schema.
+	String			sourceSchemaName;
 	ValueNode		expression;
 	ColumnDescriptor	columnDescriptor;
 	boolean			isGenerated;
@@ -215,12 +217,12 @@
 		return exposedName;
 	}
 
-	public String getSchemaName()
+	public String getSchemaName() throws StandardException
 	{
-		if ((columnDescriptor!=null) && 
-			(columnDescriptor.getTableDescriptor() != null)) 
+		if ((columnDescriptor!=null) &&
+			(columnDescriptor.getTableDescriptor() != null))
 			return columnDescriptor.getTableDescriptor().getSchemaName();
-		else 
+		else
 		{
 			if (expression != null)
 			// REMIND: could look in reference, if set.
@@ -236,8 +238,8 @@
 		{
 			return tableName;
 		}
-		if ((columnDescriptor!=null) && 
-			(columnDescriptor.getTableDescriptor() != null)) 
+		if ((columnDescriptor!=null) &&
+			(columnDescriptor.getTableDescriptor() != null))
 		{
 			return columnDescriptor.getTableDescriptor().getName();
 		}
@@ -256,6 +258,14 @@
 	}
 
 	/**
+	 * @see ResultColumnDescriptor#getSourceSchemaName
+	 */
+	public String getSourceSchemaName()
+	{
+		return sourceSchemaName;
+	}
+
+	/**
 	 * Clear the table name for the underlying ColumnReference.
 	 * See UpdateNode for full explaination.
 	 */
@@ -274,14 +284,14 @@
 
 	public DataTypeDescriptor getExpressionType()
 	{
-		return (expression == null) ? 
+		return (expression == null) ?
 			dataTypeServices :
 			expression.getTypeServices();
 	}
 
 	public int getColumnPosition()
 	{
-		if (columnDescriptor!=null) 
+		if (columnDescriptor!=null)
 			return columnDescriptor.getPosition();
 		else
 			return virtualColumnId;
@@ -785,6 +795,7 @@
 			ColumnReference cr = (ColumnReference) expression;
 			tableName = cr.getTableName();
 			sourceTableName = cr.getSourceTableName();
+			sourceSchemaName = cr.getSourceSchemaName();
 		}
 	}
 
@@ -1335,11 +1346,11 @@
 	}
 
 	/**
-	 * Tell whether this column is updatable bay a positioned update.
+	 * Tell whether this column is updatable by a positioned update.
 	 *
 	 * @return	true means this column is updatable
 	 */
-	boolean updatableByCursor()
+	public boolean updatableByCursor()
 	{
 		return updatableByCursor;
 	}

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java Thu May 12 08:53:20 2005
@@ -2422,7 +2422,7 @@
 	}
 
 	/**
-	 * Mark all the columns in this list as updatable by a positioned update
+	 * Mark all the (base) columns in this list as updatable by a positioned update
 	 * statement.  This is necessary
 	 * for positioned update statements, because we expand the column list
 	 * to include all the columns in the base table, and we need to be able
@@ -2438,7 +2438,9 @@
 
 		for (int index = 0; index < size; index++)
 		{
-			((ResultColumn) elementAt(index)).markUpdatableByCursor();
+			//determine if the column is a base column and not a derived column
+			if (((ResultColumn) elementAt(index)).getSourceTableName() != null)
+				((ResultColumn) elementAt(index)).markUpdatableByCursor();
 		}
 	}
 
@@ -2615,17 +2617,33 @@
 	}
 
 	/**
-	 * Mark as updatable all the columns in this result column list
-	 * that match the columns in the given update column list
+	 * Mark all the columns in the select sql that this result column list represents
+	 * as updatable if they match the columns in the given update column list.
 	 *
 	 * @param updateColumns		A Vector representing the columns
 	 *							to be updated.
 	 */
-	void markUpdatableByCursor(Vector updateColumns)
+	void markColumnsInSelectListUpdatableByCursor(Vector updateColumns)
+	{
+		commonCodeForUpdatableByCursor(updateColumns, true);
+	}
+
+	/**
+	 * dealingWithSelectResultColumnList true means we are dealing with
+	 * ResultColumnList for a select sql. When dealing with ResultColumnList for
+	 * select sql, it is possible that not all the updatable columns are
+	 * projected in the select column list and hence it is possible that we may
+	 * not find the column to be updated in the ResultColumnList and that is why
+	 * special handling is required when dealingWithSelectResultColumnList is true.
+	 * eg select c11, c13 from t1 for update of c11, c12
+	 * In the eg above, we will find updatable column c11 in the select column
+	 * list but we will not find updatable column c12 in the select column list
+	 */
+	private void commonCodeForUpdatableByCursor(Vector updateColumns, boolean dealingWithSelectResultColumnList)
 	{
 		/*
-		** If there is no update column list, or the list is empty,
-		** it means all the columns are updatable.
+		** If there is no update column list, or the list is empty, then it means that
+		** all the columns which have a base table associated with them are updatable.
 		*/
 		if ( (updateColumns == null) || (updateColumns.size() == 0) )
 		{
@@ -2639,23 +2657,36 @@
 
 			for (int index = 0; index < ucSize; index++)
 			{
-				columnName = (String) updateColumns.elementAt(index); 
+				columnName = (String) updateColumns.elementAt(index);
 
 				resultColumn = getResultColumn(columnName);
-
 				if (SanityManager.DEBUG)
 				{
-					if (resultColumn == null)
+					if (resultColumn == null && !dealingWithSelectResultColumnList)
 					{
-						SanityManager.THROWASSERT(
-							"No result column found with name " +
+						SanityManager.THROWASSERT("No result column found with name " +
 							columnName);
 					}
 				}
-
+				//Following if means the column specified in FOR UPDATE clause is not
+				//part of the select list
+				if (resultColumn == null && dealingWithSelectResultColumnList)
+					continue;
 				resultColumn.markUpdatableByCursor();
 			}
 		}
+	}
+
+	/**
+	 * Mark as updatable all the columns in this result column list
+	 * that match the columns in the given update column list
+	 *
+	 * @param updateColumns		A Vector representing the columns
+	 *							to be updated.
+	 */
+	void markUpdatableByCursor(Vector updateColumns)
+	{
+		commonCodeForUpdatableByCursor(updateColumns, false);
 	}
 
 	/**

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Thu May 12 08:53:20 2005
@@ -661,6 +661,11 @@
 	}
 
 	/**
+	 * This returns the user-supplied schema name of the column.
+	 * At this class level, it simply returns null. But, the subclasses
+	 * of ValueNode will overwrite this method to return the
+	 * user-supplied schema name.
+	 * 
 	 * When the value node is in a result column of a select list,
 	 * the user can request metadata information. The result column
 	 * won't have a column descriptor, so we return some default
@@ -670,17 +675,37 @@
 	 *
 	 * @return the default schema name for an expression -- null
 	 */
-	public String getSchemaName()
+	public String getSchemaName() throws StandardException
 	{
 		return null;
 	}
 
 	/**
-	 * @return the default schema name for an expression -- null
+	 * This returns the user-supplied table name of the column.
+	 * At this class level, it simply returns null. But, the subclasses
+	 * of ValueNode will overwrite this method to return the
+	 * user-supplied table name.
+	 *
+	 * When the value node is in a result column of a select list,
+	 * the user can request metadata information. The result column
+	 * won't have a column descriptor, so we return some default
+	 * information through the expression. This lets expressions that
+	 * are simply columns return all of the info, and others use
+	 * this supertype's default values.
+	 *
+	 * @return the default table name for an expression -- null
 	 */
 	public String getTableName()
 	{
 		return null;
+	}
+
+	/**
+	 * @return the default updatability for an expression - false
+	 */
+	public boolean updatableByCursor()
+	{
+		return false;
 	}
 
 	/**

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java Thu May 12 08:53:20 2005
@@ -123,6 +123,47 @@
 	}
 
 	/**
+	 * Get the name of the table the ResultColumn is in, if any.  This will be null
+	 * if the user did not supply a name (for example, select a from t).
+	 * The method will return B for this example, select b.a from t as b
+	 * The method will return T for this example, select t.a from t
+	 *
+	 * @return	A String containing the name of the table the Column
+	 *		is in. If the column is not in a table (i.e. is a
+	 * 		derived column), it returns NULL.
+	 */
+	public String getTableName()
+	{
+		return ( ( sourceColumn != null) ? sourceColumn.getTableName() : null );
+	}
+
+	/**
+	 * Get the name of the schema the ResultColumn's table is in, if any.
+	 * The return value will be null if the user did not supply a schema name
+	 * (for example, select t.a from t).
+	 * Another example for null return value (for example, select b.a from t as b).
+	 * But for following query select app.t.a from t, this will return APP
+	 *
+	 * @return	A String containing the name of the schema for the Column's table.
+	 *		If the column is not in a schema (i.e. derived column), it returns NULL.
+	 */
+	public String getSchemaName() throws StandardException
+	{
+		return ( ( sourceColumn != null) ? sourceColumn.getSchemaName() : null );
+	}
+
+	/**
+	 * Return whether or not the ResultColumn is wirtable by a positioned update.
+	 *
+	 * @return TRUE, if the column is a base column of a table and is 
+	 * writable by a positioned update.
+	 */
+	public boolean updatableByCursor()
+	{
+		return ((sourceColumn != null) ? sourceColumn.updatableByCursor() : false);
+	}
+
+	/**
 	 * Return the ResultColumn that is the source of this VirtualColumnNode.
 	 *
 	 * @return ResultSetNode	

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/resultset.out Thu May 12 08:53:20 2005
@@ -10,7 +10,7 @@
 getColumnLabel(1): I
 getColumnName(1): I
 getTableName(1): T
-getSchemaName(1): 
+getSchemaName(1): APP
 getCatalogName(1): 
 getColumnType(1): 4
 getPrecision(1): 10
@@ -28,7 +28,7 @@
 getColumnLabel(2): S
 getColumnName(2): S
 getTableName(2): T
-getSchemaName(2): 
+getSchemaName(2): APP
 getCatalogName(2): 
 getColumnType(2): 5
 getPrecision(2): 5
@@ -46,7 +46,7 @@
 getColumnLabel(3): R
 getColumnName(3): R
 getTableName(3): T
-getSchemaName(3): 
+getSchemaName(3): APP
 getCatalogName(3): 
 getColumnType(3): 7
 getPrecision(3): 7
@@ -64,7 +64,7 @@
 getColumnLabel(4): D
 getColumnName(4): D
 getTableName(4): T
-getSchemaName(4): 
+getSchemaName(4): APP
 getCatalogName(4): 
 getColumnType(4): 8
 getPrecision(4): 15
@@ -82,7 +82,7 @@
 getColumnLabel(5): DT
 getColumnName(5): DT
 getTableName(5): T
-getSchemaName(5): 
+getSchemaName(5): APP
 getCatalogName(5): 
 getColumnType(5): 91
 getPrecision(5): 10
@@ -100,7 +100,7 @@
 getColumnLabel(6): T
 getColumnName(6): T
 getTableName(6): T
-getSchemaName(6): 
+getSchemaName(6): APP
 getCatalogName(6): 
 getColumnType(6): 92
 getPrecision(6): 8
@@ -118,7 +118,7 @@
 getColumnLabel(7): TS
 getColumnName(7): TS
 getTableName(7): T
-getSchemaName(7): 
+getSchemaName(7): APP
 getCatalogName(7): 
 getColumnType(7): 93
 getPrecision(7): 26
@@ -136,7 +136,7 @@
 getColumnLabel(8): C
 getColumnName(8): C
 getTableName(8): T
-getSchemaName(8): 
+getSchemaName(8): APP
 getCatalogName(8): 
 getColumnType(8): 1
 getPrecision(8): 10
@@ -154,7 +154,7 @@
 getColumnLabel(9): V
 getColumnName(9): V
 getTableName(9): T
-getSchemaName(9): 
+getSchemaName(9): APP
 getCatalogName(9): 
 getColumnType(9): 12
 getPrecision(9): 40
@@ -172,7 +172,7 @@
 getColumnLabel(10): DC
 getColumnName(10): DC
 getTableName(10): T
-getSchemaName(10): 
+getSchemaName(10): APP
 getCatalogName(10): 
 getColumnType(10): 3
 getPrecision(10): 10
@@ -190,7 +190,7 @@
 getColumnLabel(11): BI
 getColumnName(11): BI
 getTableName(11): T
-getSchemaName(11): 
+getSchemaName(11): APP
 getCatalogName(11): 
 getColumnType(11): -5
 getPrecision(11): 19
@@ -208,7 +208,7 @@
 getColumnLabel(12): CBD
 getColumnName(12): CBD
 getTableName(12): T
-getSchemaName(12): 
+getSchemaName(12): APP
 getCatalogName(12): 
 getColumnType(12): -2
 getPrecision(12): 10
@@ -226,7 +226,7 @@
 getColumnLabel(13): VBD
 getColumnName(13): VBD
 getTableName(13): T
-getSchemaName(13): 
+getSchemaName(13): APP
 getCatalogName(13): 
 getColumnType(13): -3
 getPrecision(13): 10
@@ -244,7 +244,7 @@
 getColumnLabel(14): LVBD
 getColumnName(14): LVBD
 getTableName(14): T
-getSchemaName(14): 
+getSchemaName(14): APP
 getCatalogName(14): 
 getColumnType(14): -4
 getPrecision(14): 32700
@@ -262,7 +262,7 @@
 getColumnLabel(15): CL
 getColumnName(15): CL
 getTableName(15): T
-getSchemaName(15): 
+getSchemaName(15): APP
 getCatalogName(15): 
 getColumnType(15): 2005
 getPrecision(15): 2147483647
@@ -280,7 +280,7 @@
 getColumnLabel(16): BL
 getColumnName(16): BL
 getTableName(16): T
-getSchemaName(16): 
+getSchemaName(16): APP
 getCatalogName(16): 
 getColumnType(16): 2004
 getPrecision(16): 1073741824
@@ -1011,4 +1011,28 @@
 OK EQUALITY OBJECT RETURNED column 5 existing 1
 OK EQUALITY OBJECT RETURNED column 6 existing 1
 COMPLETE testMutableValues
+Run select * from s ss (f, e, d, c, b, a) where f = 0 and then try getTableName and getSchemaName on columns
+getTableName(1): S
+getSchemaName(1): APP
+Run select * from (select * from s) a and then try getTableName and getSchemaName on columns
+getTableName(1): S
+getSchemaName(1): APP
+Run select * from s1.t1 as abc and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is S1
+Table name of second column is T1
+Schema name of second column is S1
+Run select abc.c11 from s1.t1 as abc and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is S1
+Run select bcd.a, abc.c11 from s1.t1 as abc, s as bcd and then try getTableName and getSchemaName on columns
+Table name of first column is S
+Schema name of first column is APP
+Table name of second column is T1
+Schema name of second column is S1
+Run select app1.t1.c11, app2.t1.c11 from app1.t1, app2.t1 and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is APP1
+Table name of second column is T1
+Schema name of second column is APP2
 Test resultset finished

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/updatableResultSet.out Thu May 12 08:53:20 2005
@@ -47,13 +47,88 @@
 Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Now attempting to send a updateRow on a sql with no FOR UPDATE clause.
 SQL State : null
-Got expected exception Invalid operation: result set closed
+Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
 Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the Client in Network Server Mode
+Will see the warnings in embedded mode only
 Now attempting to send a delete on a sql with FOR READ ONLY clause.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Now attempting to send a updateRow on a sql with FOR READ ONLY clause.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
+Negative Test7 - attempt to deleteRow & updateRow on updatable resultset when the resultset is not positioned on a row
+Make sure that we got CONCUR_UPDATABLE? true
+Now attempt a deleteRow without first doing next on the resultset.
+SQL State : XCL08
+Got expected exception Cursor 'SQL_CURSH200C7' is not on a row.
+Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then updateRow is a no-op and doesn't check if it is on a row or not
+PASS!!! In Network Server mode, this updateRow is a no-op because no updateXXX were issued before the updateRow
+ResultSet is positioned after the last row. attempt to deleteRow at this point should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+ResultSet is positioned after the last row. attempt to updateRow at this point should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test8 - attempt deleteRow & updateRow on updatable resultset after closing the resultset
+Make sure that we got CONCUR_UPDATABLE? true
+SQL State : null
+Got expected exception Invalid operation: result set closed
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test9 - try updatable resultset on system table
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test10 - try updatable resultset on a view
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test11 - attempt to open updatable resultset when there is join in the select query should fail
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test12 - With autocommit on, attempt to drop a table when there is an open updatable resultset on it
+Opened an updatable resultset. Now trying to drop that table through another Statement
+SQL State : X0X95
+Got expected exception Operation 'DROP TABLE' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
+Since autocommit is on, the drop table exception resulted in a runtime rollback causing updatable resultset object to close
+SQL State : 42X01
+Got expected exception Syntax error: Encountered "(" at line 1, column 19.
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Negative Test13 - foreign key constraint failure will cause deleteRow to fail
+SQL State : 23503
+Got expected exception DELETE on table 'TABLEWITHPRIMARYKEY' caused a violation of foreign key constraint 'FK' for key (1,1).  The statement has been rolled back.
+Since autocommit is on, the constraint exception resulted in a runtime rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure resulted in a runtime rollback
+Negative Test14 - foreign key constraint failure will cause updateRow to fail
+SQL State : 42X01
+Got expected exception Syntax error: Encountered "(" at line 1, column 36.
+Since autocommit is on, the constraint exception resulted in a runtime rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure resulted in a runtime rollback
+Negative Test15 - Can't call updateXXX methods on columns that do not correspond to a column in the table
+SQL State : null
+Got expected exception Column not updatable
+Negative Test16 - Call updateXXX method on out of the range column
+There are only 2 columns in the select list and we are trying to send updateXXX on column position 3
+SQL State : null
+Got expected exception Invalid argument: parameter index 3 is out of range.
+Positive Test1a - request updatable resultset for forward only type resultset
+requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE
+got TYPE_FORWARD_ONLY? true
+got CONCUR_UPDATABLE? true
+JDBC 2.0 updatable resultset apis on this ResultSet object will pass because this is an updatable resultset
+column 1 on this row before deleteRow is 1
+column 2 on this row before deleteRow is aa                  
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow and hence no error for getXXX
+column 1 on this deleted row is 0
+calling deleteRow again w/o first positioning the ResultSet on the next row will fail
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Position the ResultSet with next()
+Should be able to deletRow() on the current row now
 Finished testing updateable resultsets

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultset.out Thu May 12 08:53:20 2005
@@ -10,7 +10,7 @@
 getColumnLabel(1): I
 getColumnName(1): I
 getTableName(1): T
-getSchemaName(1): 
+getSchemaName(1): APP
 getCatalogName(1): 
 getColumnType(1): 4
 getPrecision(1): 10
@@ -28,7 +28,7 @@
 getColumnLabel(2): S
 getColumnName(2): S
 getTableName(2): T
-getSchemaName(2): 
+getSchemaName(2): APP
 getCatalogName(2): 
 getColumnType(2): 5
 getPrecision(2): 5
@@ -46,7 +46,7 @@
 getColumnLabel(3): R
 getColumnName(3): R
 getTableName(3): T
-getSchemaName(3): 
+getSchemaName(3): APP
 getCatalogName(3): 
 getColumnType(3): 7
 getPrecision(3): 7
@@ -64,7 +64,7 @@
 getColumnLabel(4): D
 getColumnName(4): D
 getTableName(4): T
-getSchemaName(4): 
+getSchemaName(4): APP
 getCatalogName(4): 
 getColumnType(4): 8
 getPrecision(4): 15
@@ -82,7 +82,7 @@
 getColumnLabel(5): DT
 getColumnName(5): DT
 getTableName(5): T
-getSchemaName(5): 
+getSchemaName(5): APP
 getCatalogName(5): 
 getColumnType(5): 91
 getPrecision(5): 10
@@ -100,7 +100,7 @@
 getColumnLabel(6): T
 getColumnName(6): T
 getTableName(6): T
-getSchemaName(6): 
+getSchemaName(6): APP
 getCatalogName(6): 
 getColumnType(6): 92
 getPrecision(6): 8
@@ -118,7 +118,7 @@
 getColumnLabel(7): TS
 getColumnName(7): TS
 getTableName(7): T
-getSchemaName(7): 
+getSchemaName(7): APP
 getCatalogName(7): 
 getColumnType(7): 93
 getPrecision(7): 26
@@ -136,7 +136,7 @@
 getColumnLabel(8): C
 getColumnName(8): C
 getTableName(8): T
-getSchemaName(8): 
+getSchemaName(8): APP
 getCatalogName(8): 
 getColumnType(8): 1
 getPrecision(8): 10
@@ -154,7 +154,7 @@
 getColumnLabel(9): V
 getColumnName(9): V
 getTableName(9): T
-getSchemaName(9): 
+getSchemaName(9): APP
 getCatalogName(9): 
 getColumnType(9): 12
 getPrecision(9): 40
@@ -172,7 +172,7 @@
 getColumnLabel(10): DC
 getColumnName(10): DC
 getTableName(10): T
-getSchemaName(10): 
+getSchemaName(10): APP
 getCatalogName(10): 
 getColumnType(10): 3
 getPrecision(10): 10
@@ -190,7 +190,7 @@
 getColumnLabel(11): BI
 getColumnName(11): BI
 getTableName(11): T
-getSchemaName(11): 
+getSchemaName(11): APP
 getCatalogName(11): 
 getColumnType(11): -5
 getPrecision(11): 19
@@ -208,7 +208,7 @@
 getColumnLabel(12): CBD
 getColumnName(12): CBD
 getTableName(12): T
-getSchemaName(12): 
+getSchemaName(12): APP
 getCatalogName(12): 
 getColumnType(12): -2
 getPrecision(12): 10
@@ -226,7 +226,7 @@
 getColumnLabel(13): VBD
 getColumnName(13): VBD
 getTableName(13): T
-getSchemaName(13): 
+getSchemaName(13): APP
 getCatalogName(13): 
 getColumnType(13): -3
 getPrecision(13): 10
@@ -244,7 +244,7 @@
 getColumnLabel(14): LVBD
 getColumnName(14): LVBD
 getTableName(14): T
-getSchemaName(14): 
+getSchemaName(14): APP
 getCatalogName(14): 
 getColumnType(14): -4
 getPrecision(14): 32700
@@ -262,7 +262,7 @@
 getColumnLabel(15): CL
 getColumnName(15): CL
 getTableName(15): T
-getSchemaName(15): 
+getSchemaName(15): APP
 getCatalogName(15): 
 getColumnType(15): 2005
 getPrecision(15): 2147483647
@@ -280,7 +280,7 @@
 getColumnLabel(16): BL
 getColumnName(16): BL
 getTableName(16): T
-getSchemaName(16): 
+getSchemaName(16): APP
 getCatalogName(16): 
 getColumnType(16): 2004
 getPrecision(16): 1073741824
@@ -1011,4 +1011,28 @@
 OK EQUALITY OBJECT RETURNED column 5 existing 1
 OK EQUALITY OBJECT RETURNED column 6 existing 1
 COMPLETE testMutableValues
+Run select * from s ss (f, e, d, c, b, a) where f = 0 and then try getTableName and getSchemaName on columns
+getTableName(1): S
+getSchemaName(1): APP
+Run select * from (select * from s) a and then try getTableName and getSchemaName on columns
+getTableName(1): S
+getSchemaName(1): APP
+Run select * from s1.t1 as abc and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is S1
+Table name of second column is T1
+Schema name of second column is S1
+Run select abc.c11 from s1.t1 as abc and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is S1
+Run select bcd.a, abc.c11 from s1.t1 as abc, s as bcd and then try getTableName and getSchemaName on columns
+Table name of first column is S
+Schema name of first column is APP
+Table name of second column is T1
+Schema name of second column is S1
+Run select app1.t1.c11, app2.t1.c11 from app1.t1, app2.t1 and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is APP1
+Table name of second column is T1
+Schema name of second column is APP2
 Test resultset finished

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out Thu May 12 08:53:20 2005
@@ -47,13 +47,88 @@
 Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Now attempting to send a updateRow on a sql with no FOR UPDATE clause.
 SQL State : null
-Got expected exception Invalid operation: result set closed
+Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
 Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the Client in Network Server Mode
+Will see the warnings in embedded mode only
 Now attempting to send a delete on a sql with FOR READ ONLY clause.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Now attempting to send a updateRow on a sql with FOR READ ONLY clause.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
+Negative Test7 - attempt to deleteRow & updateRow on updatable resultset when the resultset is not positioned on a row
+Make sure that we got CONCUR_UPDATABLE? true
+Now attempt a deleteRow without first doing next on the resultset.
+SQL State : XCL08
+Got expected exception Cursor 'SQL_CURLH000C8' is not on a row.
+Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then updateRow is a no-op and doesn't check if it is on a row or not
+PASS!!! In Network Server mode, this updateRow is a no-op because no updateXXX were issued before the updateRow
+ResultSet is positioned after the last row. attempt to deleteRow at this point should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+ResultSet is positioned after the last row. attempt to updateRow at this point should fail!
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test8 - attempt deleteRow & updateRow on updatable resultset after closing the resultset
+Make sure that we got CONCUR_UPDATABLE? true
+SQL State : null
+Got expected exception Invalid operation: result set closed
+SQL State : null
+Got expected exception Invalid operation: result set closed
+Negative Test9 - try updatable resultset on system table
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test10 - try updatable resultset on a view
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test11 - attempt to open updatable resultset when there is join in the select query should fail
+SQL State : 42Y90
+Got expected exception FOR UPDATE is not permitted on this type of statement.
+Negative Test12 - With autocommit on, attempt to drop a table when there is an open updatable resultset on it
+Opened an updatable resultset. Now trying to drop that table through another Statement
+SQL State : X0X95
+Got expected exception Operation 'DROP TABLE' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
+Since autocommit is on, the drop table exception resulted in a runtime rollback causing updatable resultset object to close
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Negative Test13 - foreign key constraint failure will cause deleteRow to fail
+SQL State : 23503
+Got expected exception DELETE on table 'TABLEWITHPRIMARYKEY' caused a violation of foreign key constraint 'FK' for key (1,1).  The statement has been rolled back.
+Since autocommit is on, the constraint exception resulted in a runtime rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure resulted in a runtime rollback
+Negative Test14 - foreign key constraint failure will cause updateRow to fail
+SQL State : 23503
+Got expected exception UPDATE on table 'TABLEWITHPRIMARYKEY' caused a violation of foreign key constraint 'FK' for key (1,1).  The statement has been rolled back.
+Since autocommit is on, the constraint exception resulted in a runtime rollback causing updatable resultset object to close
+Jira entry Derby-160 : for Network Server because next should have failed
+FAIL!!! next should have failed because foreign key constraint failure resulted in a runtime rollback
+Negative Test15 - Can't call updateXXX methods on columns that do not correspond to a column in the table
+SQL State : null
+Got expected exception Column not updatable
+Negative Test16 - Call updateXXX method on out of the range column
+There are only 2 columns in the select list and we are trying to send updateXXX on column position 3
+SQL State : null
+Got expected exception Invalid argument: parameter index 3 is out of range.
+Positive Test1a - request updatable resultset for forward only type resultset
+requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE
+got TYPE_FORWARD_ONLY? true
+got CONCUR_UPDATABLE? true
+JDBC 2.0 updatable resultset apis on this ResultSet object will pass because this is an updatable resultset
+column 1 on this row before deleteRow is 1
+column 2 on this row before deleteRow is aa                  
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow and hence no error for getXXX
+column 1 on this deleted row is 0
+calling deleteRow again w/o first positioning the ResultSet on the next row will fail
+SQL State : 24000
+Got expected exception Invalid cursor state - no current row.
+Position the ResultSet with next()
+Should be able to deletRow() on the current row now
 Finished testing updateable resultsets

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out Thu May 12 08:53:20 2005
@@ -51,6 +51,8 @@
 Got expected exception 'updateRow' not allowed because the ResultSet is not an updatable ResultSet. 
 Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
 Make sure that we got CONCUR_READ_ONLY? true
+Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the Client in Network Server Mode
+Will see the warnings in embedded mode only
 Expected warnings on resultset = java.sql.SQLWarning: ResultSet not updatable. Query does not qualify to generate an updatable ResultSet.
 Now attempting to send a delete on a sql with FOR READ ONLY clause.
 SQL State : XJ083
@@ -64,6 +66,8 @@
 SQL State : 24000
 Got expected exception Invalid cursor state - no current row.
 Now attempt a updateRow without first doing next on the resultset.
+In embedded mode, updateRow will check if it is on a row or not even though no changes have been made to the row using updateXXX
+In Network Server mode, if no updateXXX were issued before updateRow, then updateRow is a no-op and doesn't check if it is on a row or not
 SQL State : 24000
 Got expected exception Invalid cursor state - no current row.
 ResultSet is positioned after the last row. attempt to deleteRow at this point should fail!
@@ -122,7 +126,8 @@
 JDBC 2.0 updatable resultset apis on this ResultSet object will pass because this is an updatable resultset
 column 1 on this row before deleteRow is 1
 column 2 on this row before deleteRow is aa                  
-Since after deleteRow(), ResultSet is positioned before the next row, getXXX will fail
+Since after deleteRow(), in embedded mode, ResultSet is positioned before the next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the deleted row after deleteRow and hence no error for getXXX
 SQL State : 24000
 Got expected exception Invalid cursor state - no current row.
 calling deleteRow again w/o first positioning the ResultSet on the next row will fail
@@ -135,7 +140,8 @@
 column 1 on this row after updateInt is 234
 column 2 on this row before updateString is aa                  
 now updateRow on the row
-Since after updateRow(), ResultSet is positioned before the next row, getXXX will fail
+Since after updateRow(), in embedded mode, ResultSet is positioned before the next row, getXXX will fail
+In Network Server mode, the ResultSet stays on the updated row after updateRow and hence no error for getXXX
 SQL State : 24000
 Got expected exception Invalid cursor state - no current row.
 calling updateRow again w/o first positioning the ResultSet on the next row will fail
@@ -269,9 +275,29 @@
 Positive Test9c - try to updateXXX on a readonly column. Should get error
 SQL State : 42X31
 Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQLCUR15'.
+attempt to get an updatable resultset using correlation name for an readonly column. It should work
+The sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1
 Table t1 after updateRow has following rows
 	 C1,C2
 	 -- --
+	{11,aa                  }
+	{2,bb                  }
+	{3,cc                  }
+Positive Test9c - try to updateXXX on a readonly column. Should get error
+SQL State : 42X31
+Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQLCUR17'.
+Table t1 has following rows
+	 C1,C2
+	 -- --
+	{1,aa                  }
+	{2,bb                  }
+	{3,cc                  }
+Positive Test9d - try to updateXXX on a readonly column with correlation name. Should get error
+SQL State : 42X31
+Got expected exception Column 'COL2' is not in FOR UPDATE list of cursor 'SQLCUR18'.
+Table t1 has following rows
+	 C1,C2
+	 -- --
 	{1,aa                  }
 	{2,bb                  }
 	{3,cc                  }
@@ -279,7 +305,7 @@
 delete using first resultset
 attempt to send deleteRow on the same row through a different resultset should throw an exception
 SQL State : XCL08
-Got expected exception Cursor 'SQLCUR17' is not on a row.
+Got expected exception Cursor 'SQLCUR20' is not on a row.
 Move to next row in the 2nd resultset and then delete using the second resultset
 Positive Test11 - setting the fetch size to > 1 will be ignored by updatable resultset. Same as updatable cursors
 Notice the Fetch Size in run time statistics output.
@@ -3046,7 +3072,7 @@
 	{2,bb                  }
 	{3,cc                  }
 SQL State : 42X31
-Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQLCUR536'.
+Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQLCUR539'.
   Make sure the contents of table are unchanged
 	 C1,C2
 	 -- --

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultset.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultset.out?rev=169838&r1=169837&r2=169838&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultset.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultset.out Thu May 12 08:53:20 2005
@@ -10,7 +10,7 @@
 getColumnLabel(1): I
 getColumnName(1): I
 getTableName(1): T
-getSchemaName(1): 
+getSchemaName(1): APP
 getCatalogName(1): 
 getColumnType(1): 4
 getPrecision(1): 10
@@ -29,7 +29,7 @@
 getColumnLabel(2): S
 getColumnName(2): S
 getTableName(2): T
-getSchemaName(2): 
+getSchemaName(2): APP
 getCatalogName(2): 
 getColumnType(2): 5
 getPrecision(2): 5
@@ -48,7 +48,7 @@
 getColumnLabel(3): R
 getColumnName(3): R
 getTableName(3): T
-getSchemaName(3): 
+getSchemaName(3): APP
 getCatalogName(3): 
 getColumnType(3): 7
 getPrecision(3): 7
@@ -67,7 +67,7 @@
 getColumnLabel(4): D
 getColumnName(4): D
 getTableName(4): T
-getSchemaName(4): 
+getSchemaName(4): APP
 getCatalogName(4): 
 getColumnType(4): 8
 getPrecision(4): 15
@@ -86,7 +86,7 @@
 getColumnLabel(5): DT
 getColumnName(5): DT
 getTableName(5): T
-getSchemaName(5): 
+getSchemaName(5): APP
 getCatalogName(5): 
 getColumnType(5): 91
 getPrecision(5): 10
@@ -105,7 +105,7 @@
 getColumnLabel(6): T
 getColumnName(6): T
 getTableName(6): T
-getSchemaName(6): 
+getSchemaName(6): APP
 getCatalogName(6): 
 getColumnType(6): 92
 getPrecision(6): 0
@@ -124,7 +124,7 @@
 getColumnLabel(7): TS
 getColumnName(7): TS
 getTableName(7): T
-getSchemaName(7): 
+getSchemaName(7): APP
 getCatalogName(7): 
 getColumnType(7): 93
 getPrecision(7): 0
@@ -143,7 +143,7 @@
 getColumnLabel(8): C
 getColumnName(8): C
 getTableName(8): T
-getSchemaName(8): 
+getSchemaName(8): APP
 getCatalogName(8): 
 getColumnType(8): 1
 getPrecision(8): 10
@@ -162,7 +162,7 @@
 getColumnLabel(9): V
 getColumnName(9): V
 getTableName(9): T
-getSchemaName(9): 
+getSchemaName(9): APP
 getCatalogName(9): 
 getColumnType(9): 12
 getPrecision(9): 40
@@ -181,7 +181,7 @@
 getColumnLabel(10): DC
 getColumnName(10): DC
 getTableName(10): T
-getSchemaName(10): 
+getSchemaName(10): APP
 getCatalogName(10): 
 getColumnType(10): 3
 getPrecision(10): 10
@@ -200,7 +200,7 @@
 getColumnLabel(11): BI
 getColumnName(11): BI
 getTableName(11): T
-getSchemaName(11): 
+getSchemaName(11): APP
 getCatalogName(11): 
 getColumnType(11): -5
 getPrecision(11): 19
@@ -219,7 +219,7 @@
 getColumnLabel(12): CBD
 getColumnName(12): CBD
 getTableName(12): T
-getSchemaName(12): 
+getSchemaName(12): APP
 getCatalogName(12): 
 getColumnType(12): -2
 getPrecision(12): 10
@@ -238,7 +238,7 @@
 getColumnLabel(13): VBD
 getColumnName(13): VBD
 getTableName(13): T
-getSchemaName(13): 
+getSchemaName(13): APP
 getCatalogName(13): 
 getColumnType(13): -3
 getPrecision(13): 10
@@ -257,7 +257,7 @@
 getColumnLabel(14): LVBD
 getColumnName(14): LVBD
 getTableName(14): T
-getSchemaName(14): 
+getSchemaName(14): APP
 getCatalogName(14): 
 getColumnType(14): -4
 getPrecision(14): 32700
@@ -276,7 +276,7 @@
 getColumnLabel(15): CL
 getColumnName(15): CL
 getTableName(15): T
-getSchemaName(15): 
+getSchemaName(15): APP
 getCatalogName(15): 
 getColumnType(15): 2005
 getPrecision(15): 2147483647
@@ -295,7 +295,7 @@
 getColumnLabel(16): BL
 getColumnName(16): BL
 getTableName(16): T
-getSchemaName(16): 
+getSchemaName(16): APP
 getCatalogName(16): 
 getColumnType(16): 2004
 getPrecision(16): 1073741824
@@ -1011,4 +1011,28 @@
 OK EQUALITY OBJECT RETURNED column 5 existing 1
 OK EQUALITY OBJECT RETURNED column 6 existing 1
 COMPLETE testMutableValues
+Run select * from s ss (f, e, d, c, b, a) where f = 0 and then try getTableName and getSchemaName on columns
+getTableName(1): S
+getSchemaName(1): APP
+Run select * from (select * from s) a and then try getTableName and getSchemaName on columns
+getTableName(1): S
+getSchemaName(1): APP
+Run select * from s1.t1 as abc and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is S1
+Table name of second column is T1
+Schema name of second column is S1
+Run select abc.c11 from s1.t1 as abc and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is S1
+Run select bcd.a, abc.c11 from s1.t1 as abc, s as bcd and then try getTableName and getSchemaName on columns
+Table name of first column is S
+Schema name of first column is APP
+Table name of second column is T1
+Schema name of second column is S1
+Run select app1.t1.c11, app2.t1.c11 from app1.t1, app2.t1 and then try getTableName and getSchemaName on columns
+Table name of first column is T1
+Schema name of first column is APP1
+Table name of second column is T1
+Schema name of second column is APP2
 Test resultset finished