You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "ackelcn (Jira)" <ji...@apache.org> on 2020/07/01 07:39:00 UTC

[jira] [Created] (DERBY-7081) A rotten comment in DataDictionaryImpl.java

ackelcn created DERBY-7081:
------------------------------

             Summary: A rotten comment in DataDictionaryImpl.java
                 Key: DERBY-7081
                 URL: https://issues.apache.org/jira/browse/DERBY-7081
             Project: Derby
          Issue Type: Bug
            Reporter: ackelcn


When I read the code of DataDictionaryImpl.java, I found a comment:

 
{code:java}
private String genColumnReferenceSQL(private String genColumnReferenceSQL( 
TableDescriptor td, String colName, String tabName, boolean isOldTable, int colPositionInRuntimeResultSet ) throws StandardException 
{ 
  ColumnDescriptor colDesc = null; 
  if ((colDesc = td.getColumnDescriptor(colName)) ==              null) 
  { 
       throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND, tabName+"."+colName); 
  }
    /* ** Generate something like this: ** 
    **  CAST (org.apache.derby.iapi.db.Factory:: 
    ** getTriggerExecutionContext().getNewRow(). 
    ** getObject(<colPosition>) AS DECIMAL(6,2))     
    **     
    ** Column position is used to avoid the wrong column being     
    ** selected problem (DERBY-1258) caused by the case insensitive     
    ** JDBC rules for fetching a column by name. 
    ...
}{code}
The comment mentions DERBY-1258. I found that DERBY-1258 modified CreateTriggerNode.java, and the patch is as follows:

 

 

 
{code:java}
@@ -587,7 +587,11 @@@@ -587,7 +587,11 @@  
**  
**  cast (org.apache.derby.iapi.db.Factory::  
** getTriggerExecutionContext().getNewRow().
- ** getObject('<colName>') AS DECIMAL(6,2))
+ ** getObject(<colPosition>) AS DECIMAL(6,2))
+        **
+        ** Column position is used to avoid the wrong column being
+        ** selected problem (DERBY-1258) caused by the case insensitive
+        ** JDBC rules for fetching a column by name.  
**  
** The cast back to the SQL Domain may seem redundant  
** but we need it to make the column reference appear

@@ -599,9 +603,11 @@  
** CREATE TRIGGER ... INSERT INTO T length(Column), ...  
*/  StringBuffer methodCall = new StringBuffer();
- methodCall.append("cast (org.apache.derby.iapi.db.Factory::getTriggerExecutionContext().");
+ methodCall.append("CAST (org.apache.derby.iapi.db.Factory::getTriggerExecutionContext().");  methodCall.append(isOldTable ? "getOldRow()" : "getNewRow()");
- methodCall.append(".getObject('"+colName+"') AS ");
+ methodCall.append(".getObject(");
+        methodCall.append(colDesc.getPosition());
+        methodCall.append(") AS ");  DataTypeDescriptor dts = colDesc.getType();  TypeId typeId = dts.getTypeId(); 

@@ -611,8 +617,9 @@  
** case.  
*/  methodCall.append(
-   (typeId.userType() ? typeId.getSQLTypeName() : dts.getSQLstring())
-  + ") ");
+   (typeId.userType() ? typeId.getSQLTypeName() : dts.getSQLstring()));
+        
+        methodCall.append(") ");   return methodCall.toString();  }
{code}
The patch modified the genColumnReferenceSQL method. However, the method does not appear in the latest version of  CreateTriggerNode.java.  I found that DERBY-4874 deleted the whole method. 

 

 

I am wondering whether DataDictionaryImpl.java mentions a rotten issue report (DERBY-1258), in that all the modifications of this issue do not appear in the latest version.

 

Would you please check the problem? If it is, the reference of DERBY-1258 shall be removed from the comment of  DataDictionaryImpl.java.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)