Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 89898 invoked from network); 1 Feb 2008 21:47:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Feb 2008 21:47:31 -0000 Received: (qmail 64999 invoked by uid 500); 1 Feb 2008 21:47:22 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 64959 invoked by uid 500); 1 Feb 2008 21:47:22 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 64948 invoked by uid 99); 1 Feb 2008 21:47:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Feb 2008 13:47:22 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Feb 2008 21:47:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0D9A21A9832; Fri, 1 Feb 2008 13:47:05 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r617665 - in /db/derby/code/trunk/java/engine/org/apache/derby: catalog/types/ iapi/types/ impl/load/ impl/sql/compile/ Date: Fri, 01 Feb 2008 21:46:44 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080201214705.0D9A21A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Fri Feb 1 13:46:33 2008 New Revision: 617665 URL: http://svn.apache.org/viewvc?rev=617665&view=rev Log: DERBY-2775 DERBY-2917 (partial) Remove final set method (setCollationType) on TypeDescriptor to make TypeDescriptor and DataTypeDescriptor logically immutable. Required cleanup to ensure that a routine definition is only passed catalog types (TypeDescriptor) and also resulted in a cleanup of CreateAliasNode by encapsulating collation changes within the type system and RoutineAliasInfo. Also required that the tyep system use a valid JDBC Types constant for the XML type, using the Types.SQLXML from JDBC4. Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeUtilities.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/BaseTypeIdImpl.java Fri Feb 1 13:46:33 2008 @@ -35,6 +35,7 @@ import org.apache.derby.iapi.services.i18n.MessageService; import org.apache.derby.iapi.services.i18n.MessageService; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.reference.SQLState; import org.apache.derby.iapi.services.info.JVMInfo; @@ -391,11 +392,7 @@ case StoredFormatIds.XML_TYPE_ID_IMPL: SQLTypeName = TypeId.XML_NAME; - // RESOLVE: There isn't a JDBC type for XML, so we - // just use our internal type. Is it okay to do this, - // or should "JDBCTypeId" be renamed since it no longer - // just holds JDBC types? - JDBCTypeId = StoredFormatIds.XML_TYPE_ID; + JDBCTypeId = JDBC40Translation.SQLXML; wrapperTypeFormatId = StoredFormatIds.XML_TYPE_ID; break; Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java Fri Feb 1 13:46:33 2008 @@ -32,6 +32,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import org.apache.derby.iapi.services.sanity.SanityManager; +import org.apache.derby.iapi.types.DataTypeDescriptor; /** * Describe a routine (procedure or function) alias. @@ -57,6 +58,10 @@ private int parameterCount; + /** + * Types of the parameters. If there are no parameters + * then this may be null (or a zero length array). + */ private TypeDescriptor[] parameterTypes; /** * Name of each parameter. As of DERBY 10.3, parameter names @@ -156,6 +161,7 @@ } if (returnType != null) { + SanityManager.ASSERT(!(returnType instanceof DataTypeDescriptor)); if (!((sqlAllowed >= RoutineAliasInfo.READS_SQL_DATA) && (sqlAllowed <= RoutineAliasInfo.NO_SQL))) { SanityManager.THROWASSERT("Invalid sqlAllowed for FUNCTION " + methodName + " " + sqlAllowed); } @@ -172,6 +178,10 @@ return parameterCount; } + /** + * Types of the parameters. If there are no parameters + * then this may return null (or a zero length array). + */ public TypeDescriptor[] getParameterTypes() { return parameterTypes; } @@ -360,4 +370,22 @@ return "UNKNOWN"; } } + + /** + * Set the collation type of all string types declared for + * use in this routine to the given collation type. + * @param collationType + */ + public void setCollationTypeForAllStringTypes(int collationType) + { + if (parameterCount != 0) + { + for (int p = 0; p < parameterTypes.length; p++) + parameterTypes[p] = DataTypeDescriptor.getCatalogType( + parameterTypes[p], collationType); + } + + if (returnType != null) + returnType = DataTypeDescriptor.getCatalogType(returnType, collationType); + } } Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java Fri Feb 1 13:46:33 2008 @@ -407,7 +407,6 @@ return collationType; } - /** @see DataTypeDescriptor#setCollationType(int) */ public void setCollationType(int collationTypeValue) { collationType = collationTypeValue; Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Fri Feb 1 13:46:33 2008 @@ -151,6 +151,29 @@ { return getBuiltInDataTypeDescriptor(jdbcType).getCatalogType(); } + + /** + * Get a catlog type identical to the passed in type exception + * that the collationType is set to the passed in value. + * @param catalogType Type to be based upon. + * @param collationType Collation type of returned type. + * + * @return catalogType if it already has the correct collation, + * otherwise a new TypeDescriptor with the correct collation. + */ + public static TypeDescriptor getCatalogType(TypeDescriptor catalogType, + int collationType) + { + if (catalogType.isRowMultiSet()) + return getRowMultiSetCollation(catalogType, collationType); + + if (catalogType.getCollationType() == collationType) + return catalogType; + + // Create through a runtime type, derivation will be thrown away. + return getType(catalogType).getCollatedType(collationType, + StringDataValue.COLLATION_DERIVATION_IMPLICIT).getCatalogType(); + } /** * Get a descriptor that corresponds to a builtin JDBC type. @@ -330,16 +353,9 @@ * * @return A new DataTypeDescriptor describing the SQL Row Multiset */ - public static TypeDescriptor getRowMultiSet - ( - String[] columnNames, - DataTypeDescriptor[] types - ) - { - TypeDescriptor[] catalogTypes = - new TypeDescriptor[types.length]; - for (int i = 0; i < types.length; i++) - catalogTypes[i] = types[i].getCatalogType(); + public static TypeDescriptor getRowMultiSet(String[] columnNames, + TypeDescriptor[] catalogTypes) + { RowMultiSetImpl rms = new RowMultiSetImpl(columnNames, catalogTypes); TypeId typeID = new TypeId( StoredFormatIds.ROW_MULTISET_CATALOG_ID, rms ); @@ -1140,12 +1156,18 @@ /** * Return a type description identical to this type * with the exception that its collation information is - * taken from the passed in information. + * taken from the passed in information. If the type + * does not represent a string type then the collation + * will be unchanged and this is returned. + * * @return This if collation would be unchanged otherwise a new type. */ public DataTypeDescriptor getCollatedType(int collationType, int collationDerivation) - { + { + if (!typeDescriptor.isStringType()) + return this; + if ((getCollationType() == collationType) && (getCollationDerivation() == collationDerivation)) return this; @@ -1153,6 +1175,57 @@ return new DataTypeDescriptor(this, collationType, collationDerivation); + } + + /** + * For a row multi set type return an identical type + * with the collation type changed. Note that since + * row types are only ever catalog types the + * derivation is not used (since derivation is a property + * of runtime types). + *
+ * + * + * @param collationType + * @return this will be returned if no changes are required (e.g. + * no string types or collation is already correct), otherwise a + * new instance is returned (leaving this unchanged). + */ + private static TypeDescriptor getRowMultiSetCollation( + TypeDescriptor catalogType, int collationType) + { + TypeDescriptor[] rowTypes = catalogType.getRowTypes(); + + TypeDescriptor[] newTypes = null; + + for (int t = 0; t < rowTypes.length; t++) + { + TypeDescriptor newType = DataTypeDescriptor.getCatalogType( + rowTypes[t], collationType); + + // Is it the exact same as the old type. + if (newType == rowTypes[t]) + continue; + + if (newTypes == null) + { + // First different type, simply create a new + // array and copy all the old types across. + // Any new type will overwrite the old type. + newTypes = new TypeDescriptor[rowTypes.length]; + System.arraycopy(rowTypes, 0, newTypes, 0, rowTypes.length); + } + + newTypes[t] = newType; + } + + // If no change then we continue to use this instance. + if (newTypes == null) + return catalogType; + + return DataTypeDescriptor.getRowMultiSet( + catalogType.getRowColumnNames(), + newTypes); } /** Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeUtilities.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeUtilities.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeUtilities.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeUtilities.java Fri Feb 1 13:46:33 2008 @@ -24,6 +24,7 @@ import org.apache.derby.iapi.error.StandardException; import org.apache.derby.iapi.reference.JDBC30Translation; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.services.io.StoredFormatIds; import java.sql.Types; @@ -51,7 +52,7 @@ case Types.VARBINARY: case Types.LONGVARBINARY: case Types.BLOB: - case StoredFormatIds.XML_TYPE_ID: + case JDBC40Translation.SQLXML: return dtd.getMaximumWidth(); case Types.SMALLINT: return 5; @@ -105,7 +106,7 @@ typeId == Types.VARCHAR || typeId == Types.CLOB || typeId == Types.LONGVARCHAR || - typeId == StoredFormatIds.XML_TYPE_ID); + typeId == JDBC40Translation.SQLXML); } /** Is the data type nullable. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java Fri Feb 1 13:46:33 2008 @@ -44,6 +44,7 @@ import org.apache.derby.iapi.reference.JDBC20Translation; import org.apache.derby.iapi.reference.JDBC30Translation; +import org.apache.derby.iapi.reference.JDBC40Translation; import java.sql.Types; @@ -411,7 +412,7 @@ // XML is not a JDBC type, so we have to check for our // internal XML type. - case StoredFormatIds.XML_TYPE_ID: + case JDBC40Translation.SQLXML: ret = XML_ID; if (ret == null) ret = XML_ID = new TypeId(StoredFormatIds.XML_TYPE_ID, @@ -506,7 +507,7 @@ } else if (javaTypeName.equals("org.apache.derby.iapi.types.XML")) { - return getBuiltInTypeId(StoredFormatIds.XML_TYPE_ID); + return getBuiltInTypeId(JDBC40Translation.SQLXML); } else { Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java Fri Feb 1 13:46:33 2008 @@ -21,6 +21,7 @@ package org.apache.derby.impl.load; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.services.io.StoredFormatIds; import java.sql.ResultSet; @@ -211,7 +212,7 @@ return !(type == java.sql.Types.BIT || type == java.sql.Types.JAVA_OBJECT || type == java.sql.Types.OTHER || - type == StoredFormatIds.XML_TYPE_ID); + type == JDBC40Translation.SQLXML); } Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java Fri Feb 1 13:46:33 2008 @@ -42,6 +42,7 @@ import org.apache.derby.iapi.store.access.Qualifier; import org.apache.derby.iapi.reference.ClassName; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.reference.SQLState; import org.apache.derby.iapi.util.JBitSet; @@ -394,7 +395,7 @@ // XML data value, per SQL/XML spec 6.17: "...yielding a value // X1 of an XML type." setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( - StoredFormatIds.XML_TYPE_ID)); + JDBC40Translation.SQLXML)); } return genSQLJavaSQLTree(); Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java Fri Feb 1 13:46:33 2008 @@ -262,73 +262,6 @@ } return false; } - - /** - * Take the passed TypeDescriptor and check if it corresponds to a - * character string type. If yes, then create a new one based on it's - * typeid, length and nullability to create a new DataTypeDescriptor and - * then have it take the collation type of the schema in which the method - * is getting defined in. This is because all the character strings - * associated with the definition of the user defined function/procedure - * should take the collation of the schema in which this user defined - * function is getting created. - * - * @param changeTD TypeDescriptor with incorrect collation setting - * @return New TypeDescriptor with collation of the schema in which - * the function/procedure is getting created. - * @throws StandardException - */ - private TypeDescriptor typeDescriptorWithCorrectCollation(TypeDescriptor changeTD) - throws StandardException { - //We could have been called for the return type but for procedures - //there is no return type and hence we should be careful that we - //don't run into null ptr exception. So before doing anything, check if - //the passed parameter is null and if so, then simply return. - if (changeTD == null) - return changeTD; - - TypeId compTypeId = TypeId.getBuiltInTypeId(changeTD.getTypeName()); - //No work to do if type id does not correspond to a character string - if (compTypeId != null && compTypeId.isStringTypeId()) { - DataTypeDescriptor newTDWithCorrectCollation = - new DataTypeDescriptor(compTypeId, - changeTD.isNullable(), - changeTD.getMaximumWidth()); - //Use the collation type and info of the schema in which this - //function is defined for the return value of the function - newTDWithCorrectCollation = - newTDWithCorrectCollation.getCollatedType( - getSchemaDescriptor().getCollationType(), - StringDataValue.COLLATION_DERIVATION_IMPLICIT); - return newTDWithCorrectCollation.getCatalogType(); - } - return changeTD; - } - - /** - * Set the collation of the columns in a Table Function's returned row set. - */ - private void setTableFunctionCollations() - throws StandardException - { - if ( aliasInfo.isTableFunction() ) - { - RoutineAliasInfo info = (RoutineAliasInfo) aliasInfo; - TypeDescriptor[] types = info.getReturnType().getRowTypes(); - - SchemaDescriptor sd = getSchemaDescriptor(); - - for ( int i = 0; i < types.length; i++ ) - { - TypeDescriptorImpl tdi = (TypeDescriptorImpl) types[ i ]; - if ( tdi.isStringType() ) - { - tdi.setCollationType( sd.getCollationType() ); - } - } - } - - } // We inherit the generate() method from DDLStatementNode. @@ -347,41 +280,13 @@ //Are we dealing with user defined function or procedure? if (aliasType == AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR || aliasType == AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR) { - //Does the user defined function/procedure have any character - //string types in it's definition - if (anyStringTypeDescriptor()){ - RoutineAliasInfo oldAliasInfo = (RoutineAliasInfo)aliasInfo; - TypeDescriptor[] newParamTypes = null; - int paramCount = oldAliasInfo.getParameterCount(); - //Does the user defined functio has any parameters to it? - if (paramCount > 0) { - newParamTypes = new TypeDescriptor[paramCount]; - TypeDescriptor[] oldParamTypes = oldAliasInfo.getParameterTypes(); - //Go through the parameters and pick the character string - //type and set their collation to the collation of the - //schema in which the function/procedure is getting defined. - for (int i = 0; i < paramCount; i++) - newParamTypes[i] = typeDescriptorWithCorrectCollation(oldParamTypes[i]); - } - //Now create the RoutineAliasInfo again with it's character - //strings associated with correct collation type - aliasInfo = new RoutineAliasInfo( - oldAliasInfo.getMethodName(), - oldAliasInfo.getParameterCount(), - oldAliasInfo.getParameterNames(), - newParamTypes, - oldAliasInfo.getParameterModes(), - oldAliasInfo.getMaxDynamicResultSets(), - oldAliasInfo.getParameterStyle(), - oldAliasInfo.getSQLAllowed(), - oldAliasInfo.calledOnNullInput(), - typeDescriptorWithCorrectCollation(oldAliasInfo.getReturnType())); - - } - // if this is a table function, then force its string columns to - // have the correct collation. - setTableFunctionCollations(); + // Set the collation for all string types in parameters + // and return types including row multi-sets to be that of + // the schema the routine is being defined in. + ((RoutineAliasInfo)aliasInfo).setCollationTypeForAllStringTypes( + getSchemaDescriptor().getCollationType()); + } // Procedures and functions do not check class or method validity until // runtime execution. Synonyms do need some validity checks. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Fri Feb 1 13:46:33 2008 @@ -27,6 +27,7 @@ import org.apache.derby.catalog.types.SynonymAliasInfo; import org.apache.derby.iapi.error.StandardException; import org.apache.derby.iapi.reference.ClassName; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.reference.SQLState; import org.apache.derby.iapi.services.classfile.VMOpcode; import org.apache.derby.iapi.services.compiler.MethodBuilder; @@ -824,7 +825,7 @@ constantNodeType = C_NodeTypes.BLOB_CONSTANT_NODE; break; - case StoredFormatIds.XML_TYPE_ID: + case JDBC40Translation.SQLXML: constantNodeType = C_NodeTypes.XML_CONSTANT_NODE; break; Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java Fri Feb 1 13:46:33 2008 @@ -29,6 +29,7 @@ import org.apache.derby.iapi.reference.JDBC20Translation; import org.apache.derby.iapi.reference.JDBC30Translation; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.services.io.StoredFormatIds; import java.util.Properties; @@ -219,7 +220,7 @@ return btc; } - case StoredFormatIds.XML_TYPE_ID: + case JDBC40Translation.SQLXML: return xmlTypeCompiler = getAnInstance(PACKAGE_NAME + "XMLTypeCompiler", xmlTypeCompiler, Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java Fri Feb 1 13:46:33 2008 @@ -28,6 +28,7 @@ import org.apache.derby.iapi.sql.dictionary.DataDictionary; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.reference.SQLState; import org.apache.derby.iapi.reference.ClassName; import org.apache.derby.iapi.error.StandardException; @@ -390,7 +391,7 @@ // The result type of XMLParse() is always an XML type. setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( - StoredFormatIds.XML_TYPE_ID)); + JDBC40Translation.SQLXML)); } /** Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=617665&r1=617664&r2=617665&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri Feb 1 13:46:33 2008 @@ -131,6 +131,7 @@ import org.apache.derby.iapi.reference.Property; import org.apache.derby.iapi.reference.SQLState; import org.apache.derby.iapi.reference.JDBC30Translation; +import org.apache.derby.iapi.reference.JDBC40Translation; import org.apache.derby.iapi.reference.Limits; import org.apache.derby.iapi.sql.compile.CompilerContext; @@ -3733,6 +3734,22 @@ } } +/** + Returns a dataTypeDDL() as a catalog type, ie. + the Java interface TypeDescriptor. +*/ +TypeDescriptor +catalogType() throws StandardException : +{ + DataTypeDescriptor typeDescriptor; +} +{ + typeDescriptor = dataTypeDDL() + { + return typeDescriptor.getCatalogType(); + } +} + /* * dataTypeCast @@ -4217,7 +4234,7 @@ { checkVersion(DataDictionary.DD_VERSION_DERBY_10_1, "XML"); return DataTypeDescriptor.getBuiltInDataTypeDescriptor( - StoredFormatIds.XML_TYPE_ID); + JDBC40Translation.SQLXML); } } @@ -10093,10 +10110,10 @@ [ LOOKAHEAD( { commonDatatypeName(2, false) }) parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true) ] - typeDescriptor = dataTypeDDL() + typeDescriptor = dataTypeDDL() { list[0].addElement(parameterName); - list[1].addElement(typeDescriptor); + list[1].addElement(typeDescriptor.getCatalogType()); list[2].addElement(inout); } } @@ -10182,7 +10199,6 @@ { DataTypeDescriptor typeDescriptor; String parameterName = ""; - Integer inout; } { // Lookahead needed because token could satisfy identifier and dataTypeDDL @@ -10192,11 +10208,12 @@ typeDescriptor = dataTypeDDL() { list[0].addElement(parameterName); - list[1].addElement(typeDescriptor); + list[1].addElement(typeDescriptor.getCatalogType()); list[2].addElement(ReuseFactory.getInteger(JDBC30Translation.PARAMETER_MODE_IN)); } } + /* * functionReturnDataType */ @@ -10207,7 +10224,7 @@ } { ( - typeDescriptor = dataTypeCommon() + typeDescriptor = catalogType() | typeDescriptor = functionTableType() ) @@ -10225,7 +10242,7 @@ ArrayList names = new ArrayList(); ArrayList types = new ArrayList(); String[] nameArray; - DataTypeDescriptor[] typeArray; + TypeDescriptor[] typeArray; int columnCount; } { @@ -10240,7 +10257,7 @@ columnCount = names.size(); nameArray = new String[ columnCount ]; names.toArray( nameArray ); - typeArray = new DataTypeDescriptor[ columnCount ]; + typeArray = new TypeDescriptor[ columnCount ]; types.toArray( typeArray ); // @@ -10250,7 +10267,7 @@ // for ( int i = 0; i < columnCount; i++ ) { - if ( typeArray[ i ].getTypeId().isXMLTypeId() ) + if ( typeArray[ i ].getJDBCTypeId() == JDBC40Translation.SQLXML ) { throw StandardException.newException( SQLState.LANG_XML_NOT_ALLOWED_DJRS ); } } @@ -10277,7 +10294,7 @@ typeDescriptor = dataTypeDDL() { names.add( name ); - types.add( typeDescriptor ); + types.add( typeDescriptor.getCatalogType() ); } }