db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shreyas Kaushik <Shreyas.Kaus...@Sun.COM>
Subject Re: [jira] Commented: (DERBY-18) Exposed name matching has bugs when the column name is qualified with a schema name.
Date Tue, 01 Feb 2005 13:46:06 GMT
Any updates on this??

thanks
Shreyas

Shreyas Kaushik wrote:

> I am attaching the latest diffs for Derby-18.
>
> This tries to address Dan's comments in his previous mails.
> Let me know the whether the extra checks that I have added, in 
> comparision to the diffs I sent out earlier
> are correct/sufficient.
>
> thanks
> Shreyas
>
> Shreyas Kaushik wrote:
>
>> My answers inline.
>>
>> Shreyas
>>
>> Daniel John Debrunner wrote:
>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Shreyas Kaushik wrote:
>>>
>>>  
>>>
>>>> Dan,
>>>>
>>>> I did the patch for this.
>>>>
>>>> From your comments I looked at the getSchemaDescriptor() in
>>>> QueryTreeNode. The schema name was getting
>>>> stored there but not stored in the TableName in the corresponding 
>>>> node.
>>>>
>>>> Since *null* schema implies current schema I just called bind() in
>>>> TableName.java whereever the schema was null.
>>>>   
>>>
>>>
>>>
>>> I'm not sure this is correct, because if you remember you patch to
>>> Derby-13, a TableName with a null schema can represent a correlation
>>> name (which don't have schemas). So the fact a TableName's schema name
>>> is null does not always mean that its schema name maps to the current
>>> schema. Thus only when a TableName represents a implicitly schema
>>> qualifed name (table, view, procedure, function, trigger, index,
>>> constraint name) should its lack of schema name be converted to the
>>> current schema. Possibly the only case that doesn't have an implicit
>>> schema name is the correlation name.
>>>  
>>>
>> Yes you are right, I agree .
>>
>>> Thus the patch needs to be careful of this overloaded use of TableName.
>>> Does your patch handle this correctly?
>>
>>
>> While binding the TableName object with schema name see whether 
>> correlation nae is null or not, along these lines.
>>
>>> Without looking at the code in
>>> detail I'm not sure how to handle this correctly, if you haven't made
>>> any progress I can try give and help out tomorrow.
>>>  
>>>
>> Your help and comments would be helpful for me to learn going 
>> forward. Thanks  :-)
>>
>>> Dan.
>>>
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.2.5 (MingW32)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>
>>> iD8DBQFB+c6jIv0S4qsbfuQRAvmcAJ9Nu4H0HzhGxg+S8nOJqBxi1gbbAQCgtWjO
>>> dLSVBATTSeJjkHrin45ygk4=
>>> =3KaU
>>> -----END PGP SIGNATURE-----
>>>
>>>  
>>>
>------------------------------------------------------------------------
>
>Index: java/engine/org/apache/derby/impl/sql/compile/FromList.java
>===================================================================
>--- java/engine/org/apache/derby/impl/sql/compile/FromList.java	(revision 148848)
>+++ java/engine/org/apache/derby/impl/sql/compile/FromList.java	(working copy)
>@@ -138,6 +138,7 @@
> 		 */
>         TableName leftTable = null;
>         TableName rightTable = null;
>+
> 		if (! (fromTable instanceof TableOperatorNode))
> 		{
> 			/* Check for duplicate table name in FROM list */
>@@ -146,12 +147,18 @@
> 			{
>                 leftTable = fromTable.getTableName();
> 
>+                if(leftTable.getSchemaName() == null && fromTable.correlationName
== null)
>+                     leftTable.bind(this.getDataDictionary());
>+
>                 if(((FromTable) elementAt(index)) instanceof TableOperatorNode) {
>                     continue;
>                 }
> 
>-                else {                    
>+                else {
>                     rightTable = ((FromTable) elementAt(index)).getTableName();
>+
>+                    if(rightTable.getSchemaName() == null && ((FromTable) elementAt(index)).correlationName
== null)
>+                        rightTable.bind(this.getDataDictionary());
>                 }
>                 if(leftTable.equals(rightTable))
> 				{
>@@ -291,6 +298,7 @@
> 		{
> 			fromTable = (FromTable) elementAt(index);
> 			setElementAt(fromTable.bindNonVTITables(dataDictionary, fromListParam), index);
>+
> 		}
> 		for (int index = 0; index < size; index++)
> 		{
>@@ -499,9 +507,9 @@
> 		int size = size();
> 		for (int index = 0; index < size; index++)
> 		{
>-			fromTable = (FromTable) elementAt(index);
>+			fromTable = (FromTable) elementAt(index);            
> 
>-			/* We can stop if we've found a matching column or table name 
>+			/* We can stop if we've found a matching column or table name
> 			 * at the previous nesting level.
> 			 */
> 			currentLevel = fromTable.getLevel();
>Index: java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
>===================================================================
>--- java/engine/org/apache/derby/impl/sql/compile/FromVTI.java	(revision 148848)
>+++ java/engine/org/apache/derby/impl/sql/compile/FromVTI.java	(working copy)
>@@ -988,6 +988,13 @@
> 
> 		columnsTableName = columnReference.getTableNameNode();
> 
>+        if(columnsTableName != null)
>+            if(columnsTableName.getSchemaName() == null && correlationName ==
null)
>+                columnsTableName.bind(this.getDataDictionary());
>+
>+        if(exposedName != null)
>+            if(exposedName.getSchemaName() == null && correlationName == null)
>+                exposedName.bind(this.getDataDictionary());
> 		/*
> 		** If the column did not specify a name, or the specified name
> 		** matches the table we're looking at, see whether the column
>Index: java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
>===================================================================
>--- java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java	(revision 148848)
>+++ java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java	(working copy)
>@@ -2125,6 +2125,7 @@
> 	{
> 		TableDescriptor tableDescriptor = bindTableDescriptor();
> 
>+
> /*		if (tableDescriptor.getTableType() == TableDescriptor.VTI_TYPE) {
> 			ResultSetNode vtiNode = getNodeFactory().mapTableAsVTI(getContextManager(), tableDescriptor);
> 			return vtiNode.bindNonVTITables(dataDictionary, fromListParam);
>@@ -2445,6 +2446,10 @@
> 
> 		columnsTableName = columnReference.getTableNameNode();
> 
>+        if(columnsTableName != null) {
>+            if(columnsTableName.getSchemaName() == null && correlationName ==
null)
>+                columnsTableName.bind(this.getDataDictionary());
>+        }
> 		/*
> 		** If there is a correlation name, use that instead of the
> 		** table name.
>@@ -2458,6 +2463,8 @@
> 			exposedTableName = tableName;
> 		}
> 
>+        if(exposedTableName.getSchemaName() == null && correlationName == null)
>+            exposedTableName.bind(this.getDataDictionary());
> 		/*
> 		** If the column did not specify a name, or the specified name
> 		** matches the table we're looking at, see whether the column
>@@ -2465,6 +2472,7 @@
> 		*/
> 		if (columnsTableName == null || columnsTableName.equals(exposedTableName))
> 		{
>+
> 			resultColumn = resultColumns.getResultColumn(columnReference.getColumnName());
> 			/* Did we find a match? */
> 			if (resultColumn != null)
>@@ -2480,8 +2488,7 @@
> 					tableDescriptor.setReferencedColumnMap(referencedColumnMap);
> 				}
> 			}
>-		}
>-
>+          }		
> 		return resultColumn;
> 	}
> 
>Index: java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java
>===================================================================
>--- java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java	(revision 148848)
>+++ java/engine/org/apache/derby/impl/sql/compile/CurrentOfNode.java	(working copy)
>@@ -305,6 +305,10 @@
> 
> 		columnsTableName = columnReference.getTableNameNode();
> 
>+        if(columnsTableName != null)
>+            if(columnsTableName.getSchemaName() == null && correlationName ==
null)
>+                columnsTableName.bind(this.getDataDictionary());
>+
> 		if (SanityManager.DEBUG)
> 		{
> 			SanityManager.ASSERT(preStmt!=null, "must have prepared statement");
>@@ -324,6 +328,11 @@
> 			SanityManager.ASSERT(baseTableName!=null,"no name on target table");
> 		}
> 
>+        if(baseTableName != null)
>+            if(baseTableName.getSchemaName() == null && correlationName == null)
>+                baseTableName.bind(this.getDataDictionary());
>+
>+
> 		/*
> 		 * If the column did not specify a name, or the specified name
> 		 * matches the table we're looking at, see whether the column
>  
>

Mime
View raw message