db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r546372 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: compile/ColumnDefinitionNode.java compile/ModifyColumnNode.java execute/AlterTableConstantAction.java
Date Tue, 12 Jun 2007 03:59:17 GMT
Author: djd
Date: Mon Jun 11 20:59:16 2007
New Revision: 546372

URL: http://svn.apache.org/viewvc?view=rev&rev=546372
Log:
DERBY-2775 (partial) Cleanup of type handling in ColumnDefinitionNode & its sub-class
and uses.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java?view=diff&rev=546372&r1=546371&r2=546372
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
Mon Jun 11 20:59:16 2007
@@ -66,7 +66,12 @@
 public class ColumnDefinitionNode extends TableElementNode
 {
 	boolean						isAutoincrement;
-	DataTypeDescriptor			dataTypeServices;
+	
+    /**
+     * The data type of this column.
+     */
+    DataTypeDescriptor			dataTypeServices;
+    
 	DataValueDescriptor			defaultValue;
 	DefaultInfoImpl				defaultInfo;
 	DefaultNode					defaultNode;
@@ -201,7 +206,7 @@
 	 *
 	 * @return	the data type services of the column
 	 */
-	public DataTypeDescriptor getDataTypeServices()
+	public final DataTypeDescriptor getDataTypeServices()
 	{
 		return this.dataTypeServices;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java?view=diff&rev=546372&r1=546371&r2=546372
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
Mon Jun 11 20:59:16 2007
@@ -92,36 +92,29 @@
 	public void checkUserType(TableDescriptor td)
 		throws StandardException
 	{
-		ColumnDescriptor cd;
-		TypeDescriptor oldType;
-		DataTypeDescriptor newType = dataTypeServices;
-		TypeId oldTypeId;
-		TypeId newTypeId;
-
 		if (getNodeType() != C_NodeTypes.MODIFY_COLUMN_TYPE_NODE)
 			return;				// nothing to do if user not changing length
 
-		cd = td.getColumnDescriptor(name);
+        ColumnDescriptor cd = td.getColumnDescriptor(name);
 		if (cd == null)
 		{
 			throw StandardException.newException(
 				SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE, name, td.getName());
 		}
 		
-		oldType = cd.getType();
-		oldTypeId = cd.getType().getTypeId();
-		newTypeId = dataTypeServices.getTypeId();
-		newType.setNullability(oldType.isNullable());
+		DataTypeDescriptor oldType = cd.getType();
+        dataTypeServices = 
+            getDataTypeServices().getNullabilityType(oldType.isNullable());
 
 		// can't change types yet.
-		if (!(oldTypeId.equals(newTypeId)))
+		if (!(oldType.getTypeId().equals(getDataTypeServices().getTypeId())))
 		{
 			throw StandardException.newException(
 					 SQLState.LANG_MODIFY_COLUMN_CHANGE_TYPE, name);
 		}			
 		
 		// can only alter the length of varchar, nvarchar, bitvarying columns
-		String typeName = dataTypeServices.getTypeName();
+		String typeName = getDataTypeServices().getTypeName();
 		if (!(typeName.equals(TypeId.NATIONAL_VARCHAR_NAME)) &&
 			!(typeName.equals(TypeId.VARCHAR_NAME)) &&
 			!(typeName.equals(TypeId.VARBIT_NAME)))
@@ -131,7 +124,7 @@
 		}
 		
 		// cannot decrease the length of a column
-		if (newType.getMaximumWidth() < oldType.getMaximumWidth())
+		if (getDataTypeServices().getMaximumWidth() < oldType.getMaximumWidth())
 		{
 			throw StandardException.newException(
 						 SQLState.LANG_MODIFY_COLUMN_INVALID_LENGTH, name);
@@ -362,7 +355,7 @@
 			return;
 		
 		super.validateAutoincrement(dd, td, tableType);
-		if (dataTypeServices.isNullable())
+		if (getDataTypeServices().isNullable())
 			throw StandardException.newException(SQLState.LANG_AI_CANNOT_ADD_AI_TO_NULLABLE,
 												getColumnName());
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?view=diff&rev=546372&r1=546371&r2=546372
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Mon Jun 11 20:59:16 2007
@@ -1029,10 +1029,11 @@
 		ColumnDescriptor columnDescriptor = 
 			td.getColumnDescriptor(colName),
 			newColumnDescriptor = null;
-		DataTypeDescriptor dataType = columnDescriptor.getType();
+        
+        // Get the type and change the nullability
+		DataTypeDescriptor dataType =
+            columnDescriptor.getType().getNullabilityType(nullability);
 
-		// set nullability
-		dataType.setNullability(nullability);
 
 		newColumnDescriptor = 
 			 new ColumnDescriptor(colName,



Mime
View raw message