db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r526385 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/dictionary/SchemaDescriptor.java impl/sql/compile/AlterTableNode.java impl/sql/compile/CreateTableNode.java
Date Sat, 07 Apr 2007 07:04:25 GMT
Author: mamta
Date: Sat Apr  7 00:04:25 2007
New Revision: 526385

URL: http://svn.apache.org/viewvc?view=rev&rev=526385
Log:
Committing the patch DERBY2530_create_alter_table_collation_type_v1_diff.txt attached to DERBY-2530.
This patch changes alter table and 
create table code so that the persistent user defined character types will have collation
type of their schema.

svn stat -q
M      java\engine\org\apache\derby\impl\sql\compile\AlterTableNode.java
M      java\engine\org\apache\derby\impl\sql\compile\CreateTableNode.java
M      java\engine\org\apache\derby\iapi\sql\dictionary\SchemaDescriptor.java

This patch includes following changes
1)If a character type is getting added by alter table statement then AlterTable node needs
to set the collation type of that character 
column to same value as schema descriptor's collation type. Collation derivation of this column
will be set to implicit.
2)For all the character columns that get added by create table statement, CreateTable node
should set their collation type to same value 
as schema descriptor's collation type. Collation derivation of such columns will be set to
implicit.
3)Provide a method called getCollationType on SchemaDescriptor so that AlterTable node and
CreateTable node can call that method.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SchemaDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SchemaDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SchemaDescriptor.java?view=diff&rev=526385&r1=526384&r2=526385
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SchemaDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SchemaDescriptor.java
Sat Apr  7 00:04:25 2007
@@ -238,6 +238,17 @@
 		this.oid = oid;
 	}
 
+	/**
+	 * Returns the collation type associated with this schema 
+	 *
+	 * @return collation type
+	 *
+	 */
+	public int	getCollationType()
+	{
+		return collationType;
+	}
+
 	//
 	// Provider interface
 	//

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java?view=diff&rev=526385&r1=526384&r2=526385
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
Sat Apr  7 00:04:25 2007
@@ -35,6 +35,7 @@
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
 
 import org.apache.derby.iapi.sql.execute.ConstantAction;
+import org.apache.derby.iapi.types.StringDataValue;
 
 import org.apache.derby.impl.sql.execute.ColumnInfo;
 import org.apache.derby.impl.sql.execute.ConstraintConstantAction;
@@ -230,6 +231,28 @@
 		/* Statement is dependent on the TableDescriptor */
 		getCompilerContext().createDependency(baseTable);
 
+		//If we are dealing with add column character type, then set that 
+		//column's collation type to be the collation type of the schema.
+		//The collation derivation of such a column would be "implicit".
+		if (changeType == ADD_TYPE) {//the action is of type add.
+			if (tableElementList != null) {//check if is is add column
+				for (int i=0; i<tableElementList.size();i++) {
+					if (tableElementList.elementAt(i) instanceof ColumnDefinitionNode) {
+						ColumnDefinitionNode cdn = (ColumnDefinitionNode) tableElementList.elementAt(i);
+						//check if we are dealing with add character column
+						if (cdn.getDataTypeServices().getTypeId().isStringTypeId()) {
+							//we found what we are looking for. Set the 
+							//collation type of this column to be the same as
+							//schema descriptor's collation. Set the collation
+							//derivation as implicit
+							cdn.getDataTypeServices().setCollationType(schemaDescriptor.getCollationType());
+							cdn.getDataTypeServices().setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+			        	}						
+					}
+				}
+				
+			}
+		}
 		if (tableElementList != null)
 		{
 			tableElementList.validate(this, dd, baseTable);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java?view=diff&rev=526385&r1=526384&r2=526385
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
Sat Apr  7 00:04:25 2007
@@ -44,6 +44,7 @@
 import org.apache.derby.impl.sql.execute.ColumnInfo;
 import org.apache.derby.impl.sql.execute.CreateConstraintConstantAction;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.StringDataValue;
 import java.util.Properties;
 
 /**
@@ -424,6 +425,18 @@
 		CreateConstraintConstantAction[] conActions = null;
 
 		SchemaDescriptor sd = getSchemaDescriptor();
+		
+		//Set the collation type and collation derivation of all the character
+		//type columns. Their collation type will be same as the collation of
+		//the schema they belong to. Theie collation derivation will be 
+		//"implicit".
+        for (int i = 0; i < colInfos.length; i++) {
+        	DataTypeDescriptor dts = colInfos[i].dataType;
+        	if (dts.getTypeId().isStringTypeId()) {
+        		dts.setCollationType(sd.getCollationType());
+sqlc        		dts.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+        	}
+        }
 
 		if (numConstraints > 0)
 		{



Mime
View raw message