db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r909190 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Fri, 12 Feb 2010 00:40:09 GMT
Author: rhillegas
Date: Fri Feb 12 00:40:06 2010
New Revision: 909190

URL: http://svn.apache.org/viewvc?rev=909190&view=rev
Log:
DERBY-4469: Forbid implicit and explicit casts to and from UDTs.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
Fri Feb 12 00:40:06 2010
@@ -274,6 +274,7 @@
 	public boolean numberConvertible(TypeId otherType, 
 									 boolean forDataTypeFunction)
 	{
+        if ( otherType.getBaseTypeId().isAnsiUDT() ) { return false; }
 
 		// Can't convert numbers to long types
 		if (otherType.isLongConcatableTypeId())
@@ -312,6 +313,8 @@
 									TypeId otherType,
 									ClassFactory cf)
 	{
+        if ( otherType.getBaseTypeId().isAnsiUDT() ) { return false; }
+
 		/*
 		** Numbers can be stored into from other number types.
 		** Also, user types with compatible classes can be stored into numbers.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
Fri Feb 12 00:40:06 2010
@@ -57,6 +57,7 @@
         public boolean convertible(TypeId otherType, 
 								   boolean forDataTypeFunction)
         {
+            if ( otherType.getBaseTypeId().isAnsiUDT() ) { return false; }
 
 
 			return (otherType.isBitTypeId() ||

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
Fri Feb 12 00:40:06 2010
@@ -51,6 +51,8 @@
          */
         public boolean convertible(TypeId otherType, boolean forDataTypeFunction)
         {
+            if ( otherType.getBaseTypeId().isAnsiUDT() ) { return false; }
+            
 			// LONGVARCHAR can only be converted from  character types
 			// or CLOB or boolean.
 			if (getTypeId().isLongVarcharTypeId())

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
Fri Feb 12 00:40:06 2010
@@ -246,7 +246,7 @@
 		/* Bind the expression under us */
 		javaNode = javaNode.bindExpression(fromList, subqueryList, aggregateVector);
 
-		DataTypeDescriptor dts = DataTypeDescriptor.getSQLDataTypeDescriptor(javaNode.getJavaTypeName());
+		DataTypeDescriptor dts = javaNode.getDataType();
 		if (dts == null)
 		{
 			throw StandardException.newException(SQLState.LANG_NO_CORRESPONDING_S_Q_L_TYPE, 
@@ -255,7 +255,7 @@
 
         TypeDescriptor catalogType = dts.getCatalogType();
 
-        if ( catalogType.getTypeName().equals( "java.sql.ResultSet" ) )
+        if ( catalogType.isRowMultiSet() || (catalogType.getTypeName().equals( "java.sql.ResultSet"
)) )
         {
 			throw StandardException.newException(SQLState.LANG_TABLE_FUNCTION_NOT_ALLOWED);
         }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java Fri
Feb 12 00:40:06 2010
@@ -77,6 +77,14 @@
         // * Collation type of schema where method is defined. 
 	private int collationType;
 
+    /**
+     * Get the resolved data type of this node. May be overridden by descendants.
+     */
+    public DataTypeDescriptor getDataType() throws StandardException
+    {
+        return DataTypeDescriptor.getSQLDataTypeDescriptor( getJavaTypeName()) ;
+    }
+
 	public boolean isPrimitiveType() throws StandardException
 	{
 		JSQLType	myType = getJSQLType();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
Fri Feb 12 00:40:06 2010
@@ -1251,6 +1251,21 @@
 		return variance;
 	}
 
+    /**
+     * Override method in ancestor.
+     */
+    public DataTypeDescriptor getDataType() throws StandardException
+    {
+        if ( routineInfo != null )
+        {
+            TypeDescriptor td = routineInfo.getReturnType();
+
+            if ( td != null ) { return DataTypeDescriptor.getType( td ); }
+        }
+
+        return super.getDataType();
+    }
+
 
 	/////////////////////////////////////////////////////////////////////
 	//

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
Fri Feb 12 00:40:06 2010
@@ -30,6 +30,7 @@
 import org.apache.derby.iapi.types.TypeId;
 
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.catalog.types.UserDefinedTypeIdImpl;
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.compiler.LocalField;
@@ -42,11 +43,8 @@
 	/* TypeCompiler methods */
 
 	/**
-	 * User types are convertible to other user types only if
-	 * (for now) they are the same type and are being used to
-	 * implement some JDBC type.  This is sufficient for
-	 * date/time types; it may be generalized later for e.g.
-	 * comparison of any user type with one of its subtypes.
+	 * Right now, casting is not allowed from one user defined type
+     * to another.
 	 *
 	 * @param otherType 
 	 * @param forDataTypeFunction
@@ -56,8 +54,18 @@
 	 */
 	public boolean convertible(TypeId otherType, boolean forDataTypeFunction)
 	{
+        if ( getTypeId().getBaseTypeId().isAnsiUDT() )
+        {
+            if ( !otherType.getBaseTypeId().isAnsiUDT() ) { return false; }
+            
+            UserDefinedTypeIdImpl thisTypeID = (UserDefinedTypeIdImpl) getTypeId().getBaseTypeId();
+            UserDefinedTypeIdImpl thatTypeID = (UserDefinedTypeIdImpl) otherType.getBaseTypeId();
+            
+            return thisTypeID.getSQLTypeName().equals( thatTypeID.getSQLTypeName() );
+        }
+        
 		/*
-		** We are a user defined type, we are
+		** We are a non-ANSI user defined type, we are
 		** going to have to let the client find out
 		** the hard way.
 		*/
@@ -71,19 +79,32 @@
 	}
 
 	/**
-	 * User types are storable into other user types that they
+     * ANSI UDTs can only be stored into values of exactly their own
+     * type. This restriction can be lifted when we implement the
+     * ANSI subclassing clauses.
+     *
+	 * Old-style User types are storable into other user types that they
 	 * are assignable to. The other type must be a subclass of
 	 * this type, or implement this type as one of its interfaces.
 	 *
-	 * Built-in types are also storable into user types when the built-in
-	 * type's corresponding Java type is assignable to the user type.
-	 *
 	 * @param otherType the type of the instance to store into this type.
 	 * @param cf		A ClassFactory
 	 * @return true if otherType is storable into this type, else false.
 	 */
 	public boolean storable(TypeId otherType, ClassFactory cf)
 	{
+        if ( !otherType.isUserDefinedTypeId() ) { return false; }
+
+        UserDefinedTypeIdImpl thisTypeID = (UserDefinedTypeIdImpl) getTypeId().getBaseTypeId();
+        UserDefinedTypeIdImpl thatTypeID = (UserDefinedTypeIdImpl) otherType.getBaseTypeId();
+
+        if ( thisTypeID.isAnsiUDT() != thatTypeID.isAnsiUDT() ) { return false; }
+
+        if ( thisTypeID.isAnsiUDT() )
+        {
+            return thisTypeID.getSQLTypeName().equals( thatTypeID.getSQLTypeName() );
+        }
+        
 		return cf.getClassInspector().assignableTo(
 			   otherType.getCorrespondingJavaTypeName(),
 			   getTypeId().getCorrespondingJavaTypeName());

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsHelper.java
Fri Feb 12 00:40:06 2010
@@ -101,6 +101,8 @@
     protected static  final   String  FORBIDDEN_ORDERING_OPERATION = "X0X67";
     protected static  final   String  ILLEGAL_AGG = "42Y22";
     protected static  final   String  ILLEGAL_COMPARISON = "42818";
+    protected static  final   String  ILLEGAL_STORAGE = "42821";
+    protected static  final   String  BAD_CAST = "42846";
 
     ///////////////////////////////////////////////////////////////////////////////////
     //

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java?rev=909190&r1=909189&r2=909190&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UDTTest.java
Fri Feb 12 00:40:06 2010
@@ -1029,6 +1029,173 @@
         goodStatement( conn, "select all * from t_15\n" );
     }
 
+    /**
+     * <p>
+     * Verify implicit and explicit casts.
+     * </p>
+     */
+    public void test_16_casts() throws Exception
+    {
+        Connection conn = getConnection();
+
+        goodStatement( conn, "create type javaSerializable external name 'java.io.Serializable'
language java\n" );
+        goodStatement( conn, "create type javaNumber external name 'java.lang.Number' language
java\n" );
+        goodStatement( conn, "create type javaDate external name 'java.util.Date' language
java\n" );
+        goodStatement
+            ( conn,
+              "create function makeNumber( arg int ) returns javaNumber\n" +
+              "language java parameter style java no sql external name 'org.apache.derbyTesting.functionTests.tests.lang.UDTTest.makeNumber'\n"
);
+        goodStatement( conn, "create table t_16( a int generated always as identity, b javaNumber
)\n" );
+        goodStatement( conn, "create table t_16_1( a int generated always as identity, b
javaDate )\n" );
+        goodStatement( conn, "create table t_16_2( a int generated always as identity, b
javaSerializable )\n" );
+        goodStatement( conn, "insert into t_16( b ) values ( makeNumber( 1 ) )\n" );
+        goodStatement( conn, "insert into t_16( b ) select b from t_16\n" );
+        
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16( b ) values ( 1 )\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16( b ) values ( 1.0 )\n"
);
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16( b ) values ( '1' )\n"
);
+        
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_1( b ) values ( date('1994-02-23')
)\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_1( b ) values ( time('15:09:02')
)\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_1( b ) values ( timestamp('1960-01-01
23:03:20') )\n" );
+
+        // subtypes not recognized yet
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_2( b ) select b from t_16\n"
);
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_2( b ) values( cast (null
as javaNumber) )\n" );
+
+        // casts to other udts not allowed
+        expectCompilationError( BAD_CAST, "select cast (b as javaDate) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as javaSerializable) from t_16\n"
);
+
+        //
+        // If this fails, it means that we need to add another system type to the
+        // cast checks below.
+        //
+        assertEquals( 20, vetDatatypeCount( conn ) );
+        
+        // casts to system types not allowed
+        expectCompilationError( BAD_CAST, "select cast (b as bigint) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as blob) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as char( 1 ) ) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as char( 1 ) for bit data) from
t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as clob) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as date) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as decimal) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as double) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as float) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as int) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as long varchar) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as long varchar for bit data) from
t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as numeric) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as real) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as smallint) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as time) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as timestamp) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as varchar(10)) from t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as varchar(10) for bit data) from
t_16\n" );
+        expectCompilationError( BAD_CAST, "select cast (b as xml) from t_16\n" );
+
+
+        //
+        // If this fails, it means that we need to add another system type to the
+        // t_16_all_types table and add a corresponding cast check below.
+        //
+        assertEquals( 20, vetDatatypeCount( conn ) );
+        
+        goodStatement
+            (
+             conn,
+             "create table t_16_all_types\n" +
+             "(\n" +
+             "    a01 bigint,\n" +
+             "    a02 blob,\n" +
+             "    a03 char( 1 ),\n" +
+             "    a04 char( 1 ) for bit data ,\n" +
+             "    a05 clob,\n" +
+             "    a06 date,\n" +
+             "    a07 decimal,\n" +
+             "    a08 double,\n" +
+             "    a09 float,\n" +
+             "    a10 int,\n" +
+             "    a11 long varchar,\n" +
+             "    a12 long varchar for bit data,\n" +
+             "    a13 numeric,\n" +
+             "    a14 real,\n" +
+             "    a15 smallint,\n" +
+             "    a16 time,\n" +
+             "    a17 timestamp,\n" +
+             "    a18 varchar(10),\n" +
+             "    a19 varchar(10) for bit data,\n" +
+             "    a20 xml\n" +
+             ")"
+             );
+
+        expectCompilationError( BAD_CAST, "select cast( a01 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a02 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a03 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a04 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a05 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a06 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a07 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a08 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a09 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a10 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a11 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a12 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a13 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a14 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a15 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a16 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a17 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a18 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a19 as javaSerializable ) from t_16_all_types\n"
);
+        expectCompilationError( BAD_CAST, "select cast( a20 as javaSerializable ) from t_16_all_types\n"
);
+
+
+        //
+        // If this fails, it means that we need to add another system type to the
+        // implicit casts which follow.
+        //
+        assertEquals( 20, vetDatatypeCount( conn ) );
+        
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a01 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a02 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a03 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a04 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a05 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a06 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a07 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a08 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a09 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a10 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a11 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a12 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a13 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a14 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a15 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a16 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a17 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a18 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a19 ) select
b from t_16\n" );
+        expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a20 ) select
b from t_16\n" );
+        
+        // test cast from the half-supported boolean type
+        expectCompilationError( BAD_CAST, "select cast (isindex as javaNumber) from sys.sysconglomerates\n"
);
+
+        // good cast to self
+        assertResults
+            (
+             conn,
+             "select cast (b as javaNumber) from t_16",
+             new String[][]
+             {
+                 { "1" },
+                 { "1" },
+             },
+             false
+             );
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // PROCEDURES AND FUNCTIONS
@@ -1064,6 +1231,8 @@
         return ps.executeQuery();
     }
 
+    public static Number makeNumber( int arg ) { return new Integer( arg ); }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // MINIONS



Mime
View raw message