db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r125980 - in incubator/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile testing/org/apache/derbyTesting/functionTests/master testing/org/apache/derbyTesting/functionTests/tests/lang
Date Fri, 21 Jan 2005 23:28:25 GMT
Author: djd
Date: Fri Jan 21 15:28:22 2005
New Revision: 125980

URL: http://svn.apache.org/viewcvs?view=rev&rev=125980
Log:
Fix to Derby-13. Correctly compare exposed names using TableName objects
and not simple Strings.

Patch contributed by Shreyas Kaushik <Shreyas.Kaushik@Sun.COM>

Modified:
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.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/FromList.java
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
   incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.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/ResultSetNode.java
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out
   incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AllResultColumn.java
Fri Jan 21 15:28:22 2005
@@ -87,4 +87,9 @@
 									tableName,
 									getContextManager());
 	}
+
+
+    public TableName getTableNameObject() {
+        return tableName;
+    }
 }

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?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java&r2=125980
==============================================================================
--- 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
Fri Jan 21 15:28:22 2005
@@ -3412,7 +3412,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList getAllResultColumns(String allTableName)
+	public ResultColumnList getAllResultColumns(TableName allTableName)
 			throws StandardException
 	{
 		return getResultColumnsForList(allTableName, resultColumns, tableName);

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
Fri Jan 21 15:28:22 2005
@@ -136,14 +136,24 @@
 		 * user is executing a really dumb query and we won't throw
 		 * and exception - consider it an ANSI extension.
 		 */
+        TableName leftTable = null;
+        TableName rightTable = null;
 		if (! (fromTable instanceof TableOperatorNode))
 		{
 			/* Check for duplicate table name in FROM list */
 			int size = size();
 			for (int index = 0; index < size; index++)
 			{
-				if (fromTable.getExposedName().equals
-					(((FromTable) elementAt(index)).getExposedName()) )
+                leftTable = fromTable.getTableName();
+
+                if(((FromTable) elementAt(index)) instanceof TableOperatorNode) {
+                    continue;
+                }
+
+                else {                    
+                    rightTable = ((FromTable) elementAt(index)).getTableName();
+                }
+                if(leftTable.equals(rightTable))
 				{
 					throw StandardException.newException(SQLState.LANG_FROM_LIST_DUPLICATE_TABLE_NAME, fromTable.getExposedName());
 				}
@@ -380,7 +390,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList expandAll(String allTableName)
+	public ResultColumnList expandAll(TableName allTableName)
 			throws StandardException
 	{
 		ResultColumnList resultColumnList = null;

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
Fri Jan 21 15:28:22 2005
@@ -626,17 +626,24 @@
 	 * result columns from the subquery.
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList getAllResultColumns(String allTableName)
+	public ResultColumnList getAllResultColumns(TableName allTableName)
 			throws StandardException
 	{
 		ResultColumnList rcList = null;
 		TableName		 exposedName;
+        TableName        toCompare;
 
 
-		if (allTableName != null && ! allTableName.equals(getExposedName()))
-		{
-			return null;
-		}
+		if(allTableName != null)
+             toCompare = makeTableName(allTableName.getSchemaName(),correlationName);
+        else
+            toCompare = makeTableName(null,correlationName);
+        
+        if ( allTableName != null &&
+             ! allTableName.equals(toCompare))
+        {
+            return null;
+        }
 
 		/* Cache exposed name for this table.
 		 * The exposed name becomes the qualifier for each column

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
Fri Jan 21 15:28:22 2005
@@ -32,12 +32,7 @@
 import org.apache.derby.iapi.sql.compile.RowOrdering;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;
-import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
-import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
-import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
+import org.apache.derby.iapi.sql.dictionary.*;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
@@ -52,6 +47,7 @@
 import org.apache.derby.iapi.util.JBitSet;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import org.apache.derby.iapi.util.StringUtil;
+import org.apache.derby.catalog.UUID;
 
 import java.util.Enumeration;
 import java.util.Properties;
@@ -958,7 +954,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList getResultColumnsForList(String allTableName,
+	public ResultColumnList getResultColumnsForList(TableName allTableName,
 												ResultColumnList inputRcl,
 												TableName tableName)
 			throws StandardException
@@ -968,14 +964,26 @@
 		ValueNode		 valueNode;
 		String			 columnName;
 		TableName		 exposedName;
+        TableName        toCompare;
 
-		/* If allTableName is non-null, then we must check to see if it matches 
+		/* If allTableName is non-null, then we must check to see if it matches
 		 * our exposed name.
 		 */
-		if (allTableName != null && ! allTableName.equals(getExposedName()))
-		{
-			return null;
-		}
+
+        if(correlationName == null)
+           toCompare = tableName;
+        else {
+            if(allTableName != null)
+                toCompare = makeTableName(allTableName.getSchemaName(),correlationName);
+            else
+                toCompare = makeTableName(null,correlationName);
+        }
+
+        if ( allTableName != null &&
+             ! allTableName.equals(toCompare))
+        {
+            return null;
+        }
 
 		/* Cache exposed name for this table.
 		 * The exposed name becomes the qualifier for each column

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
Fri Jan 21 15:28:22 2005
@@ -901,18 +901,25 @@
 	 * result columns from the subquery.
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList getAllResultColumns(String allTableName)
+	public ResultColumnList getAllResultColumns(TableName allTableName)
 			throws StandardException
 	{
 		ResultColumnList rcList = null;
 		ResultColumn	 resultColumn;
 		ValueNode		 valueNode;
 		String			 columnName;
+        TableName        toCompare;
 
-		if (allTableName != null && ! allTableName.equals(getExposedName()))
-		{
-			return null;
-		}
+		if(allTableName != null)
+             toCompare = makeTableName(allTableName.getSchemaName(),correlationName);
+        else
+            toCompare = makeTableName(null,correlationName);
+
+        if ( allTableName != null &&
+             ! allTableName.equals(toCompare))
+        {
+            return null;
+        }
 
 		rcList = (ResultColumnList) getNodeFactory().getNode(
 										C_NodeTypes.RESULT_COLUMN_LIST,

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
Fri Jan 21 15:28:22 2005
@@ -359,7 +359,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList getAllResultColumns(String allTableName)
+	public ResultColumnList getAllResultColumns(TableName allTableName)
 			throws StandardException
 	{
 		/* We need special processing when there is a USING clause.
@@ -453,7 +453,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	private ResultColumnList getAllResultColumnsNoUsing(String allTableName)
+	private ResultColumnList getAllResultColumnsNoUsing(TableName allTableName)
 			throws StandardException
 	{
 		ResultColumnList leftRCL = leftResultSet.getAllResultColumns(allTableName); 

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?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java&r2=125980
==============================================================================
--- 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
Fri Jan 21 15:28:22 2005
@@ -1730,4 +1730,8 @@
         }
         return dtd;
     } // end of getTypeServices
+
+    public TableName getTableNameObject() {
+        return null;
+    }
 }

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?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java&r2=125980
==============================================================================
--- 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
Fri Jan 21 15:28:22 2005
@@ -1451,7 +1451,7 @@
 	{
 		boolean			expanded = false;
 		ResultColumnList allExpansion;
-		String			fullTableName;
+		TableName			fullTableName;
 
 		/* First walk result column list looking for *'s to expand */
 		for (int index = 0; index < size(); index++)
@@ -1461,7 +1461,15 @@
 			{
 				expanded = true;
 
-				fullTableName = ((AllResultColumn) rc).getFullTableName();
+				//fullTableName = ((AllResultColumn) rc).getFullTableName();
+                TableName temp = rc.getTableNameObject();
+                if(temp != null) {
+                   String sName = temp.getSchemaName();
+                   String tName = temp.getTableName();
+                   fullTableName = makeTableName(sName,tName);
+                }
+                else
+                   fullTableName = null;
 				allExpansion = fromList.expandAll(fullTableName);
 
 				/* Make sure that every column has a name */

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java&r1=125979&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
Fri Jan 21 15:28:22 2005
@@ -493,7 +493,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ResultColumnList getAllResultColumns(String allTableName)
+	public ResultColumnList getAllResultColumns(TableName allTableName)
 					throws StandardException
 	{
 		if (SanityManager.DEBUG)

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out&r1=125979&p2=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/select.out
Fri Jan 21 15:28:22 2005
@@ -160,4 +160,23 @@
 0 rows inserted/updated/deleted
 ij> drop schema content restrict;
 0 rows inserted/updated/deleted
+ij> -- This is to test quotes handling in tables.
+-- This tests patch for Derby 13
+create table "S1.T1" (id int not null primary key, d1 int);
+0 rows inserted/updated/deleted
+ij> create schema s1;
+0 rows inserted/updated/deleted
+ij> create table s1.t1 (id int not null primary key, d2 int);
+0 rows inserted/updated/deleted
+ij> select * from s1.t1, "S1.T1" where s1.t1.id = "S1.T1".id;
+ID         |D2         |ID         |D1         
+-----------------------------------------------
+ij> select s1.t1.* from "S1.T1";
+ERROR 42X10: 'S1.T1' is not an exposed table name in the scope in which it appears.
+ij> select "S1.T1".* from s1.t1;
+ERROR 42X10: 'S1.T1' is not an exposed table name in the scope in which it appears.
+ij> select * from "S1.T1" , APP."S1.T1";
+ERROR 42X09: The table or alias name 'APP.S1.T1' is used more than once in the FROM list.
+ij> select "S1.T1".d1 from "S1.T1", APP."S1.T1";
+ERROR 42X09: The table or alias name 'APP.S1.T1' is used more than once in the FROM list.
 ij> 

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql?view=diff&rev=125980&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql&r1=125979&p2=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql&r2=125980
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/select.sql
Fri Jan 21 15:28:22 2005
@@ -102,3 +102,22 @@
 drop table content.style;
 drop table content.keygen;
 drop schema content restrict;
+
+
+-- This is to test quotes handling in tables.
+-- This tests patch for Derby 13
+
+create table "S1.T1" (id int not null primary key, d1 int);
+
+create schema s1;
+create table s1.t1 (id int not null primary key, d2 int);
+
+select * from s1.t1, "S1.T1" where s1.t1.id = "S1.T1".id;
+
+select s1.t1.* from "S1.T1";
+
+select "S1.T1".* from s1.t1;
+
+select * from "S1.T1" , APP."S1.T1";
+
+select "S1.T1".d1 from "S1.T1", APP."S1.T1";

Mime
View raw message