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 2006/08/22 02:05:46 UTC

svn commit: r433434 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog: SYSALIASESRowFactory.java SystemColumnImpl.java

Author: djd
Date: Mon Aug 21 17:05:45 2006
New Revision: 433434

URL: http://svn.apache.org/viewvc?rev=433434&view=rev
Log:
DERBY-1734 (partial) Change SYSALIASESRowFactory to use the utility methods to obtain SystemColumn implementations
to avoid passing redundant parameters leading to bugs (see DERBY-1742). Fix the bug described by DERBY-1742
so that the column descriptor for SYSTEMALIAS BOOLEAN column is created correctly. Remove the calls to
convert the case for the SYSTEMALIASES columns as the system tables are an implementation detail of
Derby which is fixed at upper case.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSALIASESRowFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSALIASESRowFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSALIASESRowFactory.java?rev=433434&r1=433433&r2=433434&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSALIASESRowFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SYSALIASESRowFactory.java Mon Aug 21 17:05:45 2006
@@ -22,6 +22,7 @@
 package org.apache.derby.impl.sql.catalog;
 
 import org.apache.derby.iapi.types.TypeId;
+import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.sql.dictionary.SystemColumn;
 import org.apache.derby.catalog.TypeDescriptor;
 
@@ -423,115 +424,31 @@
 										aliasInfo, specificName);
 	}
 
-	/**
-	 * Builds a list of columns suitable for creating this Catalog.
-	 *
-	 *
-	 * @return array of SystemColumn suitable for making this catalog.
-	 */
-	public SystemColumn[]	buildColumnList()
-	{
-		SystemColumn[]			columnList = new SystemColumn[SYSALIASES_COLUMN_COUNT];
-
-		// describe columns
-
-		columnList[0] =
-					new SystemColumnImpl(
-							convertIdCase( "ALIASID"),			// column name
-							1,	// column number
-							0,					// precision
-							0,					// scale
-							false,				// nullability
-							"CHAR",				// dataType
-							true,				// built-in type
-							36					// maxLength
-			               );
-
-		columnList[1] =
-					new SystemColumnImpl(
-							convertIdCase( "ALIAS"),			// column name
-							2,	// column number
-							false				// nullability
-			               );
-
-		columnList[2] = new SystemColumnImpl(	
-								convertIdCase( "SCHEMAID"),			// column name
-								3,	// column number
-								0,					// precision
-								0,					// scale
-								true,				// nullability
-								"CHAR",				// dataType
-								true,				// built-in type
-								36					// maxLength
-			                   );
-
-		columnList[3] =
-					new SystemColumnImpl(
-							convertIdCase( "JAVACLASSNAME"),		// column name
-							4,
-							0,					// precision
-							0,					// scale
-							false,				// nullability
-							"LONG VARCHAR",			// dataType
-							true,				// built-in type
-							Integer.MAX_VALUE	// maxLength
-							);
-
-		columnList[4] =
-					new SystemColumnImpl(
-							convertIdCase( "ALIASTYPE"),		// column name
-							5,
-							0,					// precision
-							0,					// scale
-							false,				// nullability
-							"CHAR",			// dataType
-							true,				// built-in type
-							1					// maxLength
-							);
-
-		columnList[5] =
-					new SystemColumnImpl(
-							convertIdCase( "NAMESPACE"),		// column name
-							6,
-							0,					// precision
-							0,					// scale
-							false,				// nullability
-							"CHAR",			// dataType
-							true,				// built-in type
-							1					// maxLength
-							);
-
-		columnList[6] =
-					new SystemColumnImpl(
-							convertIdCase( "SYSTEMALIAS"),		// column name
-							7,
-							0,					// precision
-							0,					// scale
-							false,				// nullability
-							"BOOLEAN",			// dataType
-							true,				// built-in type
-							0					// maxLength
-							);
-
-		columnList[7] = 
-					new SystemColumnImpl(	
-							convertIdCase( "ALIASINFO"),			// column name
-							8,	// column number
-							0,					// precision
-							0,					// scale
-							true,				// nullability
-							"org.apache.derby.catalog.AliasInfo",	    // dataType
-							false,				// built-in type
-							TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN // maxLength
-			               );
-
-		columnList[8] =
-					new SystemColumnImpl(
-							convertIdCase( "SPECIFICNAME"),
-							9,	// column number
-							false				// nullability
-			               );
-
-		return	columnList;
-	}
+    /**
+     * Builds a list of columns suitable for creating this Catalog.
+     * DERBY-1734 fixed an issue where older code created the
+     * BOOLEAN column SYSTEMALIAS with maximum length 0 instead of 1.
+     * DERBY-1742 was opened to track if upgrade changes are needed.
+     *
+     *
+     * @return array of SystemColumn suitable for making this catalog.
+     */
+    public SystemColumn[]   buildColumnList()
+    {
+      return new SystemColumn[] {
+        
+        SystemColumnImpl.getUUIDColumn("ALIASID", false),
+        SystemColumnImpl.getIdentifierColumn("ALIAS", false),
+        SystemColumnImpl.getUUIDColumn("SCHEMAID", true),
+        SystemColumnImpl.getColumn("JAVACLASSNAME",
+                java.sql.Types.LONGVARCHAR, false, Integer.MAX_VALUE),
+        SystemColumnImpl.getIndicatorColumn("ALIASTYPE"),
+        SystemColumnImpl.getIndicatorColumn("NAMESPACE"),
+        SystemColumnImpl.getColumn("SYSTEMALIAS",
+                JDBC30Translation.SQL_TYPES_BOOLEAN, false),
+        SystemColumnImpl.getJavaColumn("ALIASINFO",
+                "org.apache.derby.catalog.AliasInfo", true),
+        SystemColumnImpl.getIdentifierColumn("SPECIFICNAME", false)
+        };
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java?rev=433434&r1=433433&r2=433434&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java Mon Aug 21 17:05:45 2006
@@ -62,7 +62,23 @@
         return new SystemColumnImpl(name, DataTypeDescriptor
                 .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability));
     }
-
+    
+    /**
+     * Create a system column for a builtin type.
+     * 
+     * @param name
+     *            name of column
+     * @param jdbcTypeId
+     *            JDBC type id from java.sql.Types
+     * @param nullability
+     *            Whether or not column accepts nulls.
+     */
+    static SystemColumn getColumn(String name, int jdbcTypeId,
+            boolean nullability,int maxLength) {
+        return new SystemColumnImpl(name, DataTypeDescriptor
+                .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability, maxLength));
+    }
+    
     /**
      * Create a system column for an identifer with consistent type of
      * VARCHAR(128)