db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Wilder (JIRA)" <derby-...@db.apache.org>
Subject [jira] Created: (DERBY-469) Unnecessary if block in the FromBaseTable.bindTableDescriptor() method
Date Mon, 25 Jul 2005 12:40:03 GMT
Unnecessary if block in the FromBaseTable.bindTableDescriptor() method
----------------------------------------------------------------------

         Key: DERBY-469
         URL: http://issues.apache.org/jira/browse/DERBY-469
     Project: Derby
        Type: Bug
  Components: SQL  
    Versions: 10.2.0.0    
    Reporter: Philip Wilder
    Priority: Trivial


In attempting to get a better feel for the bind process of the SQLLayer I stumbled across
a rather suspicious (if innocuous) piece of code in the FromBaseTable class.

    /**
      *    Bind the table descriptor for this table.
      *
      *
      * @exception StandardException        Thrown on error
      */
    private    TableDescriptor    bindTableDescriptor()
        throws StandardException
    {
        String schemaName = tableName.getSchemaName();
        SchemaDescriptor sd = getSchemaDescriptor(schemaName);

        tableDescriptor = getTableDescriptor(tableName.getTableName(), sd);
        //There is no local tableDescriptor variable ergo we are just setting tableDescriptor
to itself here.
        if (tableDescriptor != null)
        {
            this.tableDescriptor = tableDescriptor;
        }
        else
        {
            // Check if the reference is for a synonym.
            TableName synonymTab = resolveTableToSynonym(tableName);
            if (synonymTab == null)
                throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
            tableName = synonymTab;
            sd = getSchemaDescriptor(tableName.getSchemaName());

            tableDescriptor = getTableDescriptor(synonymTab.getTableName(), sd);
            if (tableDescriptor == null)
                throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
        }

        return    tableDescriptor;
    }

This should probably look something like this:

    /**
      *    Bind the table descriptor for this table.
      *
      *
      * @exception StandardException        Thrown on error
      */
    private    TableDescriptor    bindTableDescriptor()
        throws StandardException
    {
        String schemaName = tableName.getSchemaName();
        SchemaDescriptor sd = getSchemaDescriptor(schemaName);

        tableDescriptor = getTableDescriptor(tableName.getTableName(), sd);
        if (tableDescriptor == null)
        {
            // Check if the reference is for a synonym.
            TableName synonymTab = resolveTableToSynonym(tableName);
            if (synonymTab == null)
                throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
            tableName = synonymTab;
            sd = getSchemaDescriptor(tableName.getSchemaName());

            tableDescriptor = getTableDescriptor(synonymTab.getTableName(), sd);
            if (tableDescriptor == null)
                throw StandardException.newException(SQLState.LANG_TABLE_NOT_FOUND, tableName);
        }

        return    tableDescriptor;
    }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message