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 2007/06/08 00:39:40 UTC
svn commit: r545338 - in
/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile:
ColumnReference.java OrderByColumn.java ValueNode.java VirtualColumnNode.java
Author: djd
Date: Thu Jun 7 15:39:38 2007
New Revision: 545338
URL: http://svn.apache.org/viewvc?view=rev&rev=545338
Log:
Cleanup some code related to ValueNode.getSourceResultColumn().
Method can be simply called through ValueNode rather than casting
nodes to an explicit sub-type.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?view=diff&rev=545338&r1=545337&r2=545338
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java Thu Jun 7 15:39:38 2007
@@ -216,7 +216,7 @@
*
* @return The nesting level for this CR.
*/
- int getNestingLevel()
+ private int getNestingLevel()
{
return nestingLevel;
}
@@ -751,26 +751,17 @@
*/
public ResultColumn getSourceResultColumn()
{
- ValueNode expression = source.getExpression();
-
- /* Find the matching ResultColumn */
- if (expression instanceof VirtualColumnNode)
- {
- return ((VirtualColumnNode) expression).getSourceResultColumn();
- }
- else
- {
- /* RESOLVE - If expression is a ColumnReference, then we are hitting
- * the top of a query block (derived table or view.)
- * In order to be able to push the expression down into the next
- * query block, it looks like we should reset the contents of the
- * current ColumnReference to be the same as expression. (This probably
- * only means names and tableNumber.) We would then "rebind" the top
- * level predicate somewhere up the call stack and see if we could push
- * the predicate through.
- */
- return ((ColumnReference) expression).getSourceResultColumn();
- }
+ /* RESOLVE - If expression is a ColumnReference, then we are hitting
+ * the top of a query block (derived table or view.)
+ * In order to be able to push the expression down into the next
+ * query block, it looks like we should reset the contents of the
+ * current ColumnReference to be the same as expression. (This probably
+ * only means names and tableNumber.) We would then "rebind" the top
+ * level predicate somewhere up the call stack and see if we could push
+ * the predicate through.
+ */
+
+ return source.getExpression().getSourceResultColumn();
}
/**
@@ -798,22 +789,8 @@
*/
for (rc = source; rc != null && rc.isRedundant(); )
{
- ResultColumn nextRC = null;
- ValueNode expression = rc.getExpression();
-
/* Find the matching ResultColumn */
- if (expression instanceof VirtualColumnNode)
- {
- nextRC = ((VirtualColumnNode) expression).getSourceResultColumn();
- }
- else if (expression instanceof ColumnReference)
- {
- nextRC = ((ColumnReference) expression).getSourceResultColumn();
- }
- else
- {
- nextRC = null;
- }
+ ResultColumn nextRC = rc.getExpression().getSourceResultColumn();
if (nextRC != null && nextRC.isRedundant())
{
@@ -887,8 +864,7 @@
SanityManager.THROWASSERT("rsn expected to be a FromTable, but is a " + rsn.getClass().getName());
}
}
- source = ((VirtualColumnNode) sourceRC.getExpression()).
- getSourceResultColumn();
+ source = sourceRC.getExpression().getSourceResultColumn();
return this;
}
else
@@ -1116,7 +1092,7 @@
{
rcExpr = rc.getExpression();
if (rcExpr instanceof VirtualColumnNode)
- rc = ((VirtualColumnNode)rcExpr).getSourceResultColumn();
+ rc = rcExpr.getSourceResultColumn();
else if (rcExpr instanceof ColumnReference)
{
colNum[0] = ((ColumnReference)rcExpr).getColumnNumber();
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java?view=diff&rev=545338&r1=545337&r2=545338
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java Thu Jun 7 15:39:38 2007
@@ -257,8 +257,7 @@
}
}
- VirtualColumnNode vcn = (VirtualColumnNode) resultCol.getExpression();
- resultCol = vcn.getSourceResultColumn();
+ resultCol = resultCol.getExpression().getSourceResultColumn();
}
/**
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?view=diff&rev=545338&r1=545337&r2=545338
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Thu Jun 7 15:39:38 2007
@@ -265,15 +265,12 @@
/**
* Get the source for this ValueNode.
*
- * @return The source of this ValueNode.
+ * @return The source of this ValueNode, null if this node
+ * is not sourced by a column.
*/
public ResultColumn getSourceResultColumn()
{
- if (SanityManager.DEBUG)
- SanityManager.ASSERT(false,
- "getSourceResultColumn() not expected to be called for this node - " +
- getClass().toString());
return null;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java?view=diff&rev=545338&r1=545337&r2=545338
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java Thu Jun 7 15:39:38 2007
@@ -46,8 +46,8 @@
* that is materializing the virtual column and the ResultColumn
* that represents that materialization.
*/
- ResultSetNode sourceResultSet;
- ResultColumn sourceColumn;
+ private ResultSetNode sourceResultSet;
+ private ResultColumn sourceColumn;
/* columnId is redundant since a ResultColumn also has one, but
* we need it here for generate()
@@ -92,11 +92,8 @@
{
super.printSubNodes(depth);
- if (sourceColumn != null)
- {
- printLabel(depth, "sourceColumn: ");
- sourceColumn.treePrint(depth + 1);
- }
+ printLabel(depth, "sourceColumn: ");
+ sourceColumn.treePrint(depth + 1);
}
}
@@ -132,7 +129,7 @@
*/
public String getTableName()
{
- return ( ( sourceColumn != null) ? sourceColumn.getTableName() : null );
+ return sourceColumn.getTableName();
}
/**
@@ -147,7 +144,7 @@
*/
public String getSchemaName() throws StandardException
{
- return ( ( sourceColumn != null) ? sourceColumn.getSchemaName() : null );
+ return sourceColumn.getSchemaName();
}
/**
@@ -158,7 +155,7 @@
*/
public boolean updatableByCursor()
{
- return ((sourceColumn != null) ? sourceColumn.updatableByCursor() : false);
+ return sourceColumn.updatableByCursor();
}
/**