db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r779319 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: CreateViewNode.java ResultColumnList.java
Date Wed, 27 May 2009 21:37:56 GMT
Author: kmarsden
Date: Wed May 27 21:37:56 2009
New Revision: 779319

URL: http://svn.apache.org/viewvc?rev=779319&view=rev
Log:
DERBY-4230 DatabaseMetaData.getColumns() returns extra column from view with group by and
expression in SELECT list

Changed CreateViewNode to only add visible columns to SYS.SYSCOLUMNS.

Also added assertions that generated columns are at the end of the ResultColumnList.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java?rev=779319&r1=779318&r2=779319&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
Wed May 27 21:37:56 2009
@@ -345,14 +345,19 @@
 	private void genColumnInfos(ColumnInfo[] colInfos)
 	{
 		ResultColumnList rcl = 	queryExpression.getResultColumns();
-		int			 	 rclSize = rcl.size();
 
-		for (int index = 0; index < rclSize; index++)
+		for (int index = 0; index < colInfos.length; index++)
 		{
 			ResultColumn rc = (ResultColumn) rcl.elementAt(index);
-			// Don't incorporate generated columns DERBY-4230
-			if (rc.isGenerated)
-				continue;
+			// The colInfo array has been initialized to be of length 
+			// visibleSize() (DERBY-4230).  This code assumes that all the visible
+			// columns are at the beginning of the rcl. Throw an assertion 
+			// if we hit a generated column in what we think is the visible
+			// range.
+			if (SanityManager.DEBUG) {
+				if (rc.isGenerated)
+					SanityManager.THROWASSERT("Encountered generated column in expected visible range at
rcl[" + index +"]");
+			}
 			//RESOLVEAUTOINCREMENT
 			colInfos[index] = new ColumnInfo(rc.getName(),
 											 rc.getType(),

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=779319&r1=779318&r2=779319&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Wed May 27 21:37:56 2009
@@ -4151,12 +4151,21 @@
 	{
 		int numGenerated = 0;
 		int sz = size();
+		boolean inVisibleRange = false;
 		for (int i = sz - 1; i >= 0; i--) 
 		{
 			ResultColumn rc = (ResultColumn) elementAt(i);
 			if (rc.isGenerated()) 
 			{
+				if (SanityManager.DEBUG) {
+					// We expect the generated columns to always be at the end of the list.
+					if (inVisibleRange)
+						SanityManager.THROWASSERT("Encountered generated column in expected visible range at
rcl[" + i +"]");
+				}	
 				numGenerated++;
+			} else {
+				// We are counting down, so as soon as we see one visible column, the rest should be
th same
+				inVisibleRange = true;
 			}
 		}
 		return numGenerated;



Mime
View raw message