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 rh...@apache.org on 2010/07/07 22:29:38 UTC
svn commit: r961497 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/jdbc/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
testing/org/apache/derbyTesting/functionTests/test...
Author: rhillegas
Date: Wed Jul 7 20:29:37 2010
New Revision: 961497
URL: http://svn.apache.org/viewvc?rev=961497&view=rev
Log:
DERBY-4730: Add BOOLEAN to list of datatypes returned by DatabaseMetaData.getTypeInfo().
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.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/jdbc/metadata.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties?rev=961497&r1=961496&r2=961497&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties Wed Jul 7 20:29:37 2010
@@ -794,6 +794,8 @@ getTypeInfo=\
('VARCHAR',12,32672,'''','''','length', \
1,TRUE,3,TRUE,FALSE,FALSE,CAST (NULL AS INTEGER),CAST (NULL AS INTEGER), \
CAST (NULL AS INTEGER)), \
+ ('BOOLEAN',16,1,CAST (NULL AS CHAR),CAST (NULL AS CHAR),CAST (NULL AS CHAR), \
+ 1,FALSE,2,TRUE,FALSE,FALSE,CAST (NULL AS INTEGER),CAST (NULL AS INTEGER),CAST (NULL AS INTEGER)),\
('DATE',91,10,'DATE''','''',CAST (NULL AS CHAR), \
1,FALSE,2,TRUE,FALSE,FALSE,0,0,10),\
('TIME',92,8,'TIME''','''',CAST (NULL AS CHAR), \
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out?rev=961497&r1=961496&r2=961497&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out Wed Jul 7 20:29:37 2010
@@ -206,6 +206,7 @@ FLOAT
REAL
DOUBLE
VARCHAR
+BOOLEAN
DATE
TIME
TIMESTAMP
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java?rev=961497&r1=961496&r2=961497&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java Wed Jul 7 20:29:37 2010
@@ -1243,7 +1243,7 @@ public class DatabaseMetaDataTest extend
* @throws SQLException
* @throws IOException
*/
- public void testGetTablesModify() throws SQLException, IOException {
+ public void testGetTablesModify() throws Exception {
int totalTables = createTablesForTest(false);
@@ -1413,13 +1413,23 @@ public class DatabaseMetaDataTest extend
* be created.
* @throws SQLException
*/
- private int createTablesForTest(boolean skipXML) throws SQLException
+ private int createTablesForTest(boolean skipXML) throws Exception
{
getConnection().setAutoCommit(false);
List types = getSQLTypes(getConnection());
if (skipXML)
types.remove("XML");
+ //
+ // The BOOLEAN datatype is only allowed in databases
+ // at level 10.7 or higher.
+ //
+ Version dataVersion = getDataVersion( getConnection() );
+ if ( dataVersion.compareTo( new Version( 10, 7, 0, 0 ) ) < 0 )
+ {
+ types.remove("BOOLEAN");
+ }
+
int typeCount = types.size();
createSchemasForTests();
@@ -2087,7 +2097,7 @@ public class DatabaseMetaDataTest extend
and added XML data type which is supported by Derby
*/
int[] supportedTypes = new int[] {
- Types.BIGINT, Types.BINARY, Types.BLOB,
+ Types.BIGINT, Types.BINARY, Types.BLOB, Types.BOOLEAN,
Types.CHAR, Types.CLOB, Types.DATE,
Types.DECIMAL, Types.DOUBLE, Types.FLOAT,
Types.INTEGER, Types.LONGVARBINARY, Types.LONGVARCHAR,
@@ -2122,6 +2132,9 @@ public class DatabaseMetaDataTest extend
int precision = -1;
switch (type)
{
+ case Types.BOOLEAN:
+ precision = 1;
+ break;
case Types.BINARY:
case Types.CHAR:
precision = 254;
@@ -2823,6 +2836,9 @@ public class DatabaseMetaDataTest extend
if ("XML".equals(type))
return JDBC.SQLXML;
+ if (type.equals("BOOLEAN"))
+ return Types.BOOLEAN;
+
fail("Unexpected SQL type: " + type);
return Types.NULL;
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java?rev=961497&r1=961496&r2=961497&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java Wed Jul 7 20:29:37 2010
@@ -454,7 +454,7 @@ public class BooleanValuesTest extends
while ( rs.next() ) { actualTypeCount++; }
rs.close();
- assertEquals( 21, actualTypeCount );
+ assertEquals( 22, actualTypeCount );
}
/**
@@ -811,6 +811,17 @@ public class BooleanValuesTest extends
false
);
+ assertResults
+ (
+ conn,
+ "values ( cast( true as boolean) )\n",
+ new String[][]
+ {
+ { "true" },
+ },
+ false
+ );
+
vetBadStringCast( conn, "char_col" );
vetBadStringCast( conn, "clob_col" );
vetBadStringCast( conn, "long_varchar_col" );
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java?rev=961497&r1=961496&r2=961497&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CastingTest.java Wed Jul 7 20:29:37 2010
@@ -294,6 +294,7 @@ public static String[][]SQLData =
new TypedColumn( "varcharCol", "varchar( 5 )", true ),
new TypedColumn( "longVarcharCol", "long varchar", false ),
new TypedColumn( "clobCol", "clob", false ),
+ new TypedColumn( "booleanCol", "boolean", true ),
};
private static final TypedColumn[] ILLEGAL_BOOLEAN_CASTS = new TypedColumn[]
@@ -633,13 +634,6 @@ public static String[][]SQLData =
false,
1
);
-
- //
- // The following assertion will fail after the BOOLEAN data type is
- // re-enabled. At that time, the assertion should be removed and
- // replaced with tests to verify the explicit casting of legal types to BOOLEAN.
- //
- assertNoBoolean();
}
private void makeTableForCasts( String tableName, TypedColumn[] columns )
throws Exception
@@ -739,22 +733,6 @@ public static String[][]SQLData =
rs.close();
ps.close();
}
- // assert that the BOOLEAN type has not been re-enabled
- private void assertNoBoolean() throws Exception
- {
- println( "Testing whether the BOOLEAN data type has been re-enabled." );
-
- Connection conn = getConnection();
- DatabaseMetaData dbmd = conn.getMetaData();
- ResultSet rs = dbmd.getTypeInfo();
-
- while ( rs.next() )
- {
- assertFalse( rs.getString( 1 ), java.sql.Types.BOOLEAN == rs.getInt( 2 ) );
- }
-
- rs.close();
- }
// assert that we are testing the casting behavior of BOOLEANs to and from
// all Derby data types
private void assertAllTypesCovered() throws Exception
@@ -846,13 +824,6 @@ public static String[][]SQLData =
"select " + makeCastedColumnList( "c.isIndex", castedColumnList ) + " from sys.sysconglomerates c\n"
);
}
-
- //
- // The following assertion will fail after the BOOLEAN data type is
- // re-enabled. At that time, the assertion should be removed and
- // replaced with tests to verify the explicit casting of illegal types to BOOLEAN.
- //
- assertNoBoolean();
}
protected void tearDown() throws SQLException, Exception {
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=961497&r1=961496&r2=961497&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 Wed Jul 7 20:29:37 2010
@@ -946,7 +946,7 @@ public class UDTTest extends GeneratedC
// If a new system type is added, then we need to add it to the following block
// of compilation errors.
//
- assertEquals( 20, vetDatatypeCount( conn ) );
+ assertEquals( 21, vetDatatypeCount( conn ) );
expectCompilationError( ILLEGAL_UDT_CLASS, "create type java_string external name 'byte[]' language java\n" );
expectCompilationError( ILLEGAL_UDT_CLASS, "create type java_string external name 'java.lang.Boolean' language java\n" );
@@ -975,7 +975,6 @@ public class UDTTest extends GeneratedC
expectedTypeCount--; // eliminate JAVA_OBJECT
int actualTypeCount = org.apache.derby.iapi.types.TypeId.getAllBuiltinTypeIds().length;
- actualTypeCount--; // eliminate BOOLEAN
actualTypeCount--; // eliminate TINYINT
actualTypeCount--; // eliminate REF
actualTypeCount++; // add FLOAT (synonym of REAL)
@@ -1072,9 +1071,10 @@ public class UDTTest extends GeneratedC
// If this fails, it means that we need to add another system type to the
// cast checks below.
//
- assertEquals( 20, vetDatatypeCount( conn ) );
+ assertEquals( 21, vetDatatypeCount( conn ) );
// casts to system types not allowed
+ expectCompilationError( BAD_CAST, "select cast (b as boolean) from t_16\n" );
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" );
@@ -1101,7 +1101,7 @@ public class UDTTest extends GeneratedC
// 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 ) );
+ assertEquals( 21, vetDatatypeCount( conn ) );
goodStatement
(
@@ -1127,7 +1127,8 @@ public class UDTTest extends GeneratedC
" a17 timestamp,\n" +
" a18 varchar(10),\n" +
" a19 varchar(10) for bit data,\n" +
- " a20 xml\n" +
+ " a20 xml,\n" +
+ " a21 boolean\n" +
")"
);
@@ -1151,13 +1152,14 @@ public class UDTTest extends GeneratedC
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" );
+ expectCompilationError( BAD_CAST, "select cast( a21 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 ) );
+ assertEquals( 21, 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" );
@@ -1179,6 +1181,7 @@ public class UDTTest extends GeneratedC
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" );
+ expectCompilationError( ILLEGAL_STORAGE, "insert into t_16_all_types( a21 ) 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" );