db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r943465 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/reference/ testing/org/apache/derbyTesting/functionTests/master/ te...
Date Wed, 12 May 2010 12:15:53 GMT
Author: rhillegas
Date: Wed May 12 12:15:52 2010
New Revision: 943465

URL: http://svn.apache.org/viewvc?rev=943465&view=rev
Log:
DERBY-4613: Make the client driver treat boolean columns the same way that the embedded driver
does.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SignedBinary.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/Typdef.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/DRDAConstants.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/showindex_client.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/junitTests/compatibility/CompatibilitySuite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ColumnMetaData.java Wed May
12 12:15:52 2010
@@ -286,6 +286,8 @@ public class ColumnMetaData implements j
             checkForValidColumnIndex(column);
             int jdbcType = types_[column - 1];
             switch (jdbcType) {
+            case Types.BOOLEAN:
+                return 5;
             case Types.INTEGER:
                 return 11;
             case Types.SMALLINT:
@@ -419,6 +421,8 @@ public class ColumnMetaData implements j
             int jdbcType = types_[column - 1];
 
             switch (jdbcType) {
+            case Types.BOOLEAN:
+                return 1;
             case java.sql.Types.NUMERIC:
             case Types.DECIMAL:
                 return sqlPrecision_[column - 1];
@@ -550,6 +554,9 @@ public class ColumnMetaData implements j
             int sqlType = sqlType_[column - 1];
 
             switch (sqlType) {
+            case DRDAConstants.DB2_SQLTYPE_BOOLEAN:
+            case DRDAConstants.DB2_SQLTYPE_NBOOLEAN:
+                return "BOOLEAN";
             case DRDAConstants.DB2_SQLTYPE_DATE:
             case DRDAConstants.DB2_SQLTYPE_NDATE:
                 return "DATE";
@@ -684,6 +691,8 @@ public class ColumnMetaData implements j
 
             int jdbcType = types_[column - 1];
             switch (jdbcType) {
+            case java.sql.Types.BOOLEAN:
+                return "java.lang.Boolean";
             case java.sql.Types.BIT:
                 return "java.lang.Boolean";
             case java.sql.Types.TINYINT:
@@ -809,6 +818,8 @@ public class ColumnMetaData implements j
     // Only used when describe information is not available.
     private int getInternalTypeForGuessedOrRegisteredJdbcType(int guessedOrRegisteredJdbcType)
throws SqlException {
         switch (guessedOrRegisteredJdbcType) {
+        case java.sql.Types.BOOLEAN:
+            return Types.BOOLEAN;
         case java.sql.Types.BIT:
         case java.sql.Types.TINYINT:
         case java.sql.Types.SMALLINT:

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Cursor.java Wed May 12 12:15:52
2010
@@ -363,6 +363,14 @@ public abstract class Cursor {
     //------- the following getters are called on known column types -------------
     // Direct conversions only, cross conversions are handled by another set of getters.
 
+    // Build a Java boolean from a 1-byte signed binary representation.
+    private final boolean get_BOOLEAN(int column) {
+        if ( org.apache.derby.client.am.SignedBinary.getByte
+             ( dataBuffer_, columnDataPosition_[column - 1] ) == 0 )
+        { return false; }
+        else { return true; }
+    }
+
     // Build a Java short from a 2-byte signed binary representation.
     private final short get_SMALLINT(int column) {
         return org.apache.derby.client.am.SignedBinary.getShort(dataBuffer_,
@@ -763,6 +771,8 @@ public abstract class Cursor {
 
     final boolean getBoolean(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return get_BOOLEAN(column);
         case java.sql.Types.SMALLINT:
             return agent_.crossConverters_.getBooleanFromShort(get_SMALLINT(column));
         case java.sql.Types.INTEGER:
@@ -790,6 +800,8 @@ public abstract class Cursor {
     final byte getByte(int column) throws SqlException {
         // This needs to be changed to use jdbcTypes[]
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return agent_.crossConverters_.getByteFromBoolean(get_BOOLEAN(column));
         case java.sql.Types.SMALLINT:
             return agent_.crossConverters_.getByteFromShort(get_SMALLINT(column));
         case java.sql.Types.INTEGER:
@@ -816,6 +828,8 @@ public abstract class Cursor {
 
     final short getShort(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return agent_.crossConverters_.getShortFromBoolean(get_BOOLEAN(column));
         case java.sql.Types.SMALLINT:
             return get_SMALLINT(column);
         case java.sql.Types.INTEGER:
@@ -842,6 +856,8 @@ public abstract class Cursor {
 
     final int getInt(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return agent_.crossConverters_.getIntFromBoolean(get_BOOLEAN(column));
         case java.sql.Types.SMALLINT:
             return (int) get_SMALLINT(column);
         case java.sql.Types.INTEGER:
@@ -868,6 +884,8 @@ public abstract class Cursor {
 
     final long getLong(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return agent_.crossConverters_.getLongFromBoolean(get_BOOLEAN(column));
         case java.sql.Types.SMALLINT:
             return (long) get_SMALLINT(column);
         case java.sql.Types.INTEGER:
@@ -894,6 +912,8 @@ public abstract class Cursor {
 
     final float getFloat(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return agent_.crossConverters_.getFloatFromBoolean(get_BOOLEAN(column));
         case java.sql.Types.REAL:
             return get_FLOAT(column);
         case java.sql.Types.DOUBLE:
@@ -920,6 +940,8 @@ public abstract class Cursor {
 
     final double getDouble(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return agent_.crossConverters_.getDoubleFromBoolean(get_BOOLEAN(column));
         case java.sql.Types.REAL:
             double d = (double) get_FLOAT(column);
             return d;
@@ -948,6 +970,8 @@ public abstract class Cursor {
 
     final java.math.BigDecimal getBigDecimal(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return new java.math.BigDecimal( getInt( column ) );
         case java.sql.Types.DECIMAL:
             return get_DECIMAL(column);
         case java.sql.Types.REAL:
@@ -1039,6 +1063,9 @@ public abstract class Cursor {
         try {
             String tempString = null;
             switch (jdbcTypes_[column - 1]) {
+            case java.sql.Types.BOOLEAN:
+                if ( get_BOOLEAN( column ) ) { return Boolean.TRUE.toString(); }
+                else { return Boolean.FALSE.toString(); }
             case java.sql.Types.CHAR:
                 return getCHAR(column);
             case java.sql.Types.VARCHAR:
@@ -1319,6 +1346,8 @@ public abstract class Cursor {
 
     public final Object getObject(int column) throws SqlException {
         switch (jdbcTypes_[column - 1]) {
+        case java.sql.Types.BOOLEAN:
+            return new Boolean(get_BOOLEAN(column));
         case java.sql.Types.SMALLINT:
             return new Integer(get_SMALLINT(column)); // See Table 4 in JDBC 1 spec (pg.
932 in jdbc book)
         case java.sql.Types.INTEGER:

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java Wed May
12 12:15:52 2010
@@ -69,6 +69,33 @@ public abstract class DatabaseMetaData i
 
     public boolean useServerXAState_ = true;
 
+    /** True if the server supports QRYCLSIMP. */
+    private boolean supportsQryclsimp_;
+    
+    private boolean supportsLayerBStreaming_;
+
+    /**
+     * True if the server supports session data caching
+     */
+    private boolean supportsSessionDataCaching_;
+
+    /** True if the server supports UDTs */
+    private boolean supportsUDTs_;
+
+    /**
+     * True if the server supports aborting a statement whilst transferring
+     * EXTDTA objects. Note that there are two types of aborts, depending on
+     * whether an object is being transferred to the server using DDM layer B
+     * streaming or not.
+     */
+    private boolean supportsEXTDTAAbort_;
+    
+    /** True if the server supports nanoseconds in timestamps */
+    private boolean supportsTimestampNanoseconds_;
+    
+    /** True if the server supports boolean values */
+    private boolean supportsBooleanValues_;
+
     //---------------------constructors/finalizer---------------------------------
 
     protected DatabaseMetaData(Agent agent, Connection connection, ProductLevel productLevel)
{
@@ -2258,10 +2285,108 @@ public abstract class DatabaseMetaData i
         return false;
     }
 
-    //--------------------Abstract material layer call-down methods-----------------
+    //-----------------------------helper methods---------------------------------
 
-    // Compute feature set based on release
-    abstract protected void computeFeatureSet_();
+    // Set flags describing the level of support for this connection.
+    // Flags will be set based on manager level and/or specific product identifiers.
+    // Support for a specific server version can be set as follows. For example
+    // if (productLevel_.greaterThanOrEqualTo(11,1,0))
+    //  supportsTheBestThingEver = true
+    //
+    // WARNING WARNING WARNING !!!!
+    //
+    // If you define an instance variable of NetDatabaseMetaData that
+    // you want computeFeatureSet_() to compute, DO NOT assign an
+    // initial value to the variable in the
+    // declaration. NetDatabaseMetaData's constructor will invoke
+    // DatabaseMetaData's constructor, which then invokes
+    // computeFeatureSet_(). Initialization of instance variables in
+    // NetDatabaseMetaData will happen *after* the invocation of
+    // computeFeatureSet_() and will therefore overwrite the computed
+    // values. So, LEAVE INSTANCE VARIABLES UNINITIALIZED!
+    //
+    // END OF WARNING
+    protected void computeFeatureSet_() {
+
+        // Support for QRYCLSIMP was added in 10.2.0
+        if (productLevel_.greaterThanOrEqualTo(10, 2, 0)) {
+            supportsQryclsimp_ = true;
+        } else {
+            supportsQryclsimp_ = false;
+        }
+        
+        supportsLayerBStreaming_ = 
+            productLevel_.greaterThanOrEqualTo(10, 3, 0);
+
+        supportsSessionDataCaching_ =
+                productLevel_.greaterThanOrEqualTo(10, 4, 0);
+
+        supportsUDTs_ =
+                productLevel_.greaterThanOrEqualTo(10, 6, 0);
+
+        supportsTimestampNanoseconds_ =
+                productLevel_.greaterThanOrEqualTo(10, 6, 0);
+
+        supportsEXTDTAAbort_ =
+                productLevel_.greaterThanOrEqualTo(10, 6, 0);
+
+        supportsBooleanValues_ =
+                productLevel_.greaterThanOrEqualTo(10, 7, 0);
+    }
+
+    /**
+     * Check whether the server has full support for the QRYCLSIMP
+     * parameter in OPNQRY.
+     *
+     * @return true if QRYCLSIMP is fully supported
+     */
+    final public boolean serverSupportsQryclsimp() {
+        return supportsQryclsimp_;
+    }
+
+    final public boolean serverSupportsLayerBStreaming() {
+        return supportsLayerBStreaming_;
+    }
+
+    /**
+     * Check if server supports session data caching
+     * @return true if the server supports this
+     */
+    final public boolean serverSupportsSessionDataCaching() {
+        return supportsSessionDataCaching_;
+    }
+
+    /**
+     * Check if server supports UDTs
+     * @return true if the server supports this
+     */
+    final public boolean serverSupportsUDTs() {
+        return supportsUDTs_;
+    }
+
+    /**
+     * Check if server supports nanoseconds in timestamps
+     * @return true if the server supports this
+     */
+    final public boolean serverSupportsTimestampNanoseconds() {
+        return supportsTimestampNanoseconds_;
+    }
+
+    /**
+     * Check if server supports product specific EXTDTA abort protocol.
+     * @return {@code true} if the server supports this.
+     */
+    final public boolean serverSupportsEXTDTAAbort() {
+        return supportsEXTDTAAbort_;
+    }
+
+    /**
+     * Check if server supports boolean values
+     * @return true if the server supports this
+     */
+    final public boolean serverSupportsBooleanValues() {
+        return supportsUDTs_;
+    }
 
     //------------helper methods for meta data info call methods------------------
 
@@ -2269,11 +2394,16 @@ public abstract class DatabaseMetaData i
     private boolean getMetaDataInfoBoolean(int infoCallIndex) throws SQLException {
         try
         {
-			if (metaDataInfoIsCached_) {
-				return ((Integer) metaDataInfoCache_[infoCallIndex]).intValue() != 0;
-			}
-			metaDataInfoCall();
-			return ((Integer) metaDataInfoCache_[infoCallIndex]).intValue() != 0;
+			if ( !metaDataInfoIsCached_) { metaDataInfoCall(); }
+
+            if ( serverSupportsBooleanValues() )
+            {
+                return ((Boolean) metaDataInfoCache_[infoCallIndex]).booleanValue();
+            }
+            else
+            {
+                return ((Integer) metaDataInfoCache_[infoCallIndex]).intValue() != 0;
+            }
         }
         catch ( SqlException se )
         {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SignedBinary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SignedBinary.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SignedBinary.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SignedBinary.java Wed May 12
12:15:52 2010
@@ -36,6 +36,13 @@ public class SignedBinary {
     public final static int LITTLE_ENDIAN = 2;
 
     /**
+     * Get a byte from the buffer.
+     */
+    public static final byte getByte(byte[] buffer, int offset) {
+        return buffer[ offset ];
+    }
+
+    /**
      * Build a Java short from a 2-byte signed binary representation.
      *
      * @throws IllegalArgumentException if the specified byte order is not recognized.

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Types.java Wed May 12 12:15:52
2010
@@ -119,6 +119,8 @@ public class Types {
 
     static public int mapDERBYTypeToDriverType(boolean isDescribed, int sqlType, long length,
int ccsid) {
         switch (Utils.getNonNullableSqlType(sqlType)) { // mask the isNullable bit
+        case DRDAConstants.DB2_SQLTYPE_BOOLEAN:
+            return BOOLEAN;
         case DRDAConstants.DB2_SQLTYPE_SMALL:
             return SMALLINT;
         case DRDAConstants.DB2_SQLTYPE_INTEGER:

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java Wed May
12 12:15:52 2010
@@ -1781,6 +1781,18 @@ public class NetConnection extends org.a
     }
     
     /**
+     * Check whether the server supports boolean values
+     * @return true if boolean values are supported
+     */
+    protected final boolean serverSupportsBooleanValues() {
+
+        NetDatabaseMetaData metadata =
+            (NetDatabaseMetaData) databaseMetaData_;
+
+        return metadata.serverSupportsBooleanValues();
+    }
+
+    /**
      * Returns if a transaction is in process
      * @return open
      */

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData.java Wed
May 12 12:15:52 2010
@@ -26,30 +26,6 @@ import org.apache.derby.client.am.SqlExc
 
 public class NetDatabaseMetaData extends org.apache.derby.client.am.DatabaseMetaData {
 
-    /** True if the server supports QRYCLSIMP. */
-    private boolean supportsQryclsimp_;
-    
-    private boolean supportsLayerBStreaming_;
-
-    /**
-     * True if the server supports session data caching
-     */
-    private boolean supportsSessionDataCaching_;
-
-    /** True if the server supports UDTs */
-    private boolean supportsUDTs_;
-
-    /**
-     * True if the server supports aborting a statement whilst transferring
-     * EXTDTA objects. Note that there are two types of aborts, depending on
-     * whether an object is being transferred to the server using DDM layer B
-     * streaming or not.
-     */
-    private boolean supportsEXTDTAAbort_;
-    
-    /** True if the server supports nanoseconds in timestamps */
-    private boolean supportsTimestampNanoseconds_;
-    
     public NetDatabaseMetaData(NetAgent netAgent, NetConnection netConnection) {
         // Consider setting product level during parse
         super(netAgent, netConnection, new ProductLevel(netConnection.productID_,
@@ -73,95 +49,4 @@ public class NetDatabaseMetaData extends
                 connection_.databaseName_;
     }
 
-    //-----------------------------helper methods---------------------------------
-
-    // Set flags describing the level of support for this connection.
-    // Flags will be set based on manager level and/or specific product identifiers.
-    // Support for a specific server version can be set as follows. For example
-    // if (productLevel_.greaterThanOrEqualTo(11,1,0))
-    //  supportsTheBestThingEver = true
-    //
-    // WARNING WARNING WARNING !!!!
-    //
-    // If you define an instance variable of NetDatabaseMetaData that
-    // you want computeFeatureSet_() to compute, DO NOT assign an
-    // initial value to the variable in the
-    // declaration. NetDatabaseMetaData's constructor will invoke
-    // DatabaseMetaData's constructor, which then invokes
-    // computeFeatureSet_(). Initialization of instance variables in
-    // NetDatabaseMetaData will happen *after* the invocation of
-    // computeFeatureSet_() and will therefore overwrite the computed
-    // values. So, LEAVE INSTANCE VARIABLES UNINITIALIZED!
-    //
-    // END OF WARNING
-    protected void computeFeatureSet_() {
-
-        // Support for QRYCLSIMP was added in 10.2.0
-        if (productLevel_.greaterThanOrEqualTo(10, 2, 0)) {
-            supportsQryclsimp_ = true;
-        } else {
-            supportsQryclsimp_ = false;
-        }
-        
-        supportsLayerBStreaming_ = 
-            productLevel_.greaterThanOrEqualTo(10, 3, 0);
-
-        supportsSessionDataCaching_ =
-                productLevel_.greaterThanOrEqualTo(10, 4, 0);
-
-        supportsUDTs_ =
-                productLevel_.greaterThanOrEqualTo(10, 6, 0);
-
-        supportsTimestampNanoseconds_ =
-                productLevel_.greaterThanOrEqualTo(10, 6, 0);
-
-        supportsEXTDTAAbort_ =
-                productLevel_.greaterThanOrEqualTo(10, 6, 0);
-    }
-
-    /**
-     * Check whether the server has full support for the QRYCLSIMP
-     * parameter in OPNQRY.
-     *
-     * @return true if QRYCLSIMP is fully supported
-     */
-    final boolean serverSupportsQryclsimp() {
-        return supportsQryclsimp_;
-    }
-
-    final boolean serverSupportsLayerBStreaming() {
-        return supportsLayerBStreaming_;
-    }
-
-    /**
-     * Check if server supports session data caching
-     * @return true if the server supports this
-     */
-    final boolean serverSupportsSessionDataCaching() {
-        return supportsSessionDataCaching_;
-    }
-
-    /**
-     * Check if server supports UDTs
-     * @return true if the server supports this
-     */
-    final boolean serverSupportsUDTs() {
-        return supportsUDTs_;
-    }
-
-    /**
-     * Check if server supports nanoseconds in timestamps
-     * @return true if the server supports this
-     */
-    final boolean serverSupportsTimestampNanoseconds() {
-        return supportsTimestampNanoseconds_;
-    }
-
-    /**
-     * Check if server supports product specific EXTDTA abort protocol.
-     * @return {@code true} if the server supports this.
-     */
-    final boolean serverSupportsEXTDTAAbort() {
-        return supportsEXTDTAAbort_;
-    }
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java Wed
May 12 12:15:52 2010
@@ -1218,6 +1218,17 @@ public class NetStatementRequest extends
                     lidAndLengths[i][1] = 4;
                     break;
                 case java.sql.Types.BOOLEAN:
+                    if ( netAgent_.netConnection_.serverSupportsBooleanValues() )
+                    {
+                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NBOOLEAN;
+                        lidAndLengths[i][1] = 1;
+                    }
+                    else
+                    {
+                        lidAndLengths[i][0] = DRDAConstants.DRDA_TYPE_NSMALL;
+                        lidAndLengths[i][1] = 2;
+                    }
+                    break;
                 case java.sql.Types.SMALLINT:
                 case java.sql.Types.TINYINT:
                 case java.sql.Types.BIT:

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/Typdef.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/Typdef.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/Typdef.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/Typdef.java Wed May 12 12:15:52
2010
@@ -645,10 +645,10 @@ public class Typdef implements java.lang
         null,
         /* 0xBD Empties */
         null,
-        /* 0xBE Empties */
-        null,
-        /* 0xBF Empties */
-        null,
+        /* 0xBE Boolean */
+        new FdocaSimpleDataArray(0xBE, FdocaConstants.FDOCA_TYPE_FIXEDBYTES, Cursor.BYTES,
NOCCSID, 0, 0, 1, FIXEDLENGTH),
+        /* 0xBF null Boolean */
+        new FdocaSimpleDataArray(0xBF, FdocaConstants.FDOCA_TYPE_NFIXEDBYTES, Cursor.BYTES,
NOCCSID, 0, 0, 1, FIXEDLENGTH),
         /* 0xC0 Empties */
         null,
         /* 0xC1 Empties */
@@ -875,8 +875,8 @@ public class Typdef implements java.lang
         0x00, // 0xBB Empties
         0x00, // 0xBC Empties
         0x00, // 0xBD Empties
-        0x00, // 0xBE Empties
-        0x00, // 0xBF Empties
+        java.sql.Types.BOOLEAN, // 0xBE Boolean
+        java.sql.Types.BOOLEAN, // 0xBF null Boolean
         0x00, // 0xC0 Empties
         0x00, // 0xC1 Empties
         0x00, // 0xC2 Empties

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/AppRequester.java Wed May 12
12:15:52 2010
@@ -317,6 +317,10 @@ class AppRequester
 		return (clientType == DNC_CLIENT && greaterThanOrEqualTo(10, 6, 0));
 	}
 
+	protected boolean supportsBooleanValues() {
+		return (clientType == DNC_CLIENT && greaterThanOrEqualTo(10, 7, 0));
+	}
+
     /**
      * The timestamp length may be truncated for old versions of Derby.
      * See DERBY-2602.

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Wed May 12
12:15:52 2010
@@ -7834,6 +7834,9 @@ class DRDAConnThread extends Thread {
 			long valLength = 0;
 			switch (ndrdaType)
 			{
+			    case DRDAConstants.DRDA_TYPE_NBOOLEAN:
+                    writer.writeBoolean( ((Boolean) val).booleanValue() );
+					break;
 			    case DRDAConstants.DRDA_TYPE_NSMALL:
  					// DB2 does not have a BOOLEAN java.sql.bit type,
 					// so we need to send it as a small

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/FdocaConstants.java Wed May 12
12:15:52 2010
@@ -140,6 +140,17 @@ class FdocaConstants
 		int drdaType = 0;
 		switch (jdbcType) {
 			case Types.BOOLEAN:
+                if ( appRequester.supportsBooleanValues() )
+                {
+                    drdaType = DRDAConstants.DRDA_TYPE_NBOOLEAN;
+                    outlen[0] = 1;
+                }
+                else
+                {
+                    drdaType = DRDAConstants.DRDA_TYPE_NSMALL;
+                    outlen[0] = 2;
+                }
+				break;
 			case java.sql.Types.BIT:
 			case java.sql.Types.TINYINT:
 			case java.sql.Types.SMALLINT:

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/SQLTypes.java Wed May 12 12:15:52
2010
@@ -146,6 +146,14 @@ class SQLTypes {
 	  switch(jdbctype)
 	  {
 		  case Types.BOOLEAN:
+              if ( appRequester.supportsBooleanValues() )
+              {
+                  return DRDAConstants.DB2_SQLTYPE_BOOLEAN + nullAddVal;
+              }
+              else
+              {
+                  return DRDAConstants.DB2_SQLTYPE_SMALL + nullAddVal;
+              }
 		  case java.sql.Types.BIT:
 		  case java.sql.Types.TINYINT:
 		  case java.sql.Types.SMALLINT:

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/DRDAConstants.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/DRDAConstants.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/DRDAConstants.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/DRDAConstants.java Wed
May 12 12:15:52 2010
@@ -144,12 +144,8 @@ public	interface	DRDAConstants
 	public	static final int DRDA_TYPE_LOBCMIXED = 0xCE;
 	public	static final int DRDA_TYPE_NLOBCMIXED = 0xCF;
 
-	// Experimental types. These codes will change when the Open Group
-	// publishes an addendum to the DRDA spec covering these
-	// datatypes.
-	
-	// public	static final int DRDA_TYPE_BOOLEAN = 0xBE;
-	// public	static final int DRDA_TYPE_NBOOLEAN = 0xBF;
+	public	static final int DRDA_TYPE_BOOLEAN = 0xBE;
+	public	static final int DRDA_TYPE_NBOOLEAN = 0xBF;
 
     // This is the maximum size which a udt can serialize to in order to
     // be transported across DRDA
@@ -221,9 +217,8 @@ public	interface	DRDAConstants
 	public	static final  int DB2_SQLTYPE_DBCLOB_LOCATOR = 968;  // DBCLOB locator
 	public	static final  int DB2_SQLTYPE_NDBCLOB_LOCATOR = 969;
 
-	// extensions to the db2 datatypes
-    // public	static final  int DB2_SQLTYPE_BOOLEAN = 1000;     // BOOLEAN
-    // public	static final  int DB2_SQLTYPE_NBOOLEAN = 1001;
+    public	static final  int DB2_SQLTYPE_BOOLEAN = 2436;     // BOOLEAN
+    public	static final  int DB2_SQLTYPE_NBOOLEAN = 2437;
 
     // there is no DB2 type for UDTs. we invent one
     public   static final int DB2_SQLTYPE_FAKE_UDT = 2000;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/showindex_client.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/showindex_client.out?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/showindex_client.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/showindex_client.out
Wed May 12 12:15:52 2010
@@ -34,12 +34,12 @@ ij> -- show all the indexes in the schem
 SHOW INDEXES IN APP;
 TABLE_NAME          |COLUMN_NAME         |NON_U&|TYPE|ASC&|CARDINA&|PAGES   
 ----------------------------------------------------------------------------
-T1                  |TEST                |1     |3   |A   |NULL    |NULL    
-T2                  |PK                  |0     |3   |A   |NULL    |NULL    
-T2                  |V                   |1     |3   |A   |NULL    |NULL    
+T1                  |TEST                |true  |3   |A   |NULL    |NULL    
+T2                  |PK                  |false |3   |A   |NULL    |NULL    
+T2                  |V                   |true  |3   |A   |NULL    |NULL    
 ij> -- show only indexes in table t1
 SHOW INDEXES FROM APP.t1;
 TABLE_NAME          |COLUMN_NAME         |NON_U&|TYPE|ASC&|CARDINA&|PAGES   
 ----------------------------------------------------------------------------
-T1                  |TEST                |1     |3   |A   |NULL    |NULL    
-ij> 
\ No newline at end of file
+T1                  |TEST                |true  |3   |A   |NULL    |NULL    
+ij> 

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=943465&r1=943464&r2=943465&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 May 12 12:15:52 2010
@@ -1821,17 +1821,7 @@ public class DatabaseMetaDataTest extend
         // DMD returns BOOLEAN
         // RSMD returns SMALLINT
         int dmdColumnType = rs.getInt("DATA_TYPE");
-        if (dmdColumnType == Types.BOOLEAN && usingDerbyNetClient())
-        {
-            assertEquals("TYPE_NAME",
-                    "BOOLEAN", rs.getString("TYPE_NAME"));
-            assertEquals("TYPE_NAME",
-                    "SMALLINT", rsmdt.getColumnTypeName(col));
-
-            assertEquals("DATA_TYPE",
-                    Types.SMALLINT, rsmdt.getColumnType(col));
-        }
-        else if (dmdColumnType == Types.JAVA_OBJECT && usingDerbyNetClient()
+        if (dmdColumnType == Types.JAVA_OBJECT && usingDerbyNetClient()
                  &&  ( dataVersion.compareTo( new Version( 10, 6, 0, 0 ) ) < 0
) )
         {
             // DMD returns JAVA_OBJECT
@@ -2047,8 +2037,6 @@ public class DatabaseMetaDataTest extend
     {
         // Client returns BOOLEAN type from the engine as SMALLINT
         int BOOLEAN = Types.BOOLEAN;      
-        if (usingDerbyNetClient())
-            BOOLEAN = Types.SMALLINT;
         
         String[] JDBC_COLUMN_NAMES = new String[] {
                 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
@@ -3732,10 +3720,6 @@ public class DatabaseMetaDataTest extend
                 Types.SMALLINT,Types.VARCHAR,Types.CHAR,Types.INTEGER,
                 Types.INTEGER,Types.VARCHAR};
         
-        // types.boolean is not supported with networkserver
-        if (usingDerbyNetClient())
-        	columnTypes[4 - 1] = Types.SMALLINT;
-        
         boolean [] nullability = {false,false,false,
             false,false,true,true,true,false,false,true,true,true};
         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/CompatibilitySuite.java
Wed May 12 12:15:52 2010
@@ -57,6 +57,7 @@ public	class	CompatibilitySuite	extends	
 	public	static	final	Version	DRB_10_4 = new Version( 10, 4 );
 	public	static	final	Version	DRB_10_5 = new Version( 10, 5 );
 	public	static	final	Version	DRB_10_6 = new Version( 10, 6 );
+	public	static	final	Version	DRB_10_7 = new Version( 10, 7 );
 
 	// Supported VM versions.
 	public	static	final	Version	VM_1_3 = new Version( 1, 3 );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java?rev=943465&r1=943464&r2=943465&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/junitTests/compatibility/JDBCDriverTest.java
Wed May 12 12:15:52 2010
@@ -253,12 +253,87 @@ public	class	JDBCDriverTest	extends	Comp
 		datatypesTest( conn );
         udtTest( conn );
         derby_2602_test( conn );
+        derby_4613_test( conn );
 
 		close( conn );
 	}
 	
 	/////////////////////////////////////////////////////////////
 	//
+	//	DERBY-4613
+    //
+    // Make embedded and network clients treat BOOLEAN values identically.
+	//
+	/////////////////////////////////////////////////////////////
+
+    //
+    // Verify that embedded and network clients handle BOOLEAN values the
+    // same way from release 10.7 onward.
+    //
+	private	void	derby_4613_test( Connection conn )
+		throws Exception
+	{
+        boolean correctBehavior =
+            usingEmbeddedClient() ||
+            (
+             getServerVersion().atLeast( DRB_10_7 ) &&
+             getDriverVersion().atLeast( DRB_10_7 )
+             );
+
+        println( "derby_4613_test correctBehavior = " + correctBehavior );
+
+        vet_isindex_column( conn, correctBehavior, "SYSTABLES_HEAP", false );
+        vet_isindex_column( conn, correctBehavior, "SYSTABLES_INDEX1", true );
+    }
+    /**
+     * <p>
+     * Vet boolean results.
+     * </p>
+     */
+    private void vet_isindex_column( Connection conn, boolean correctBehavior, String conglomerateName,
boolean expectedValue ) throws Exception
+    {
+        PreparedStatement ps = prepare( conn, "select isindex from sys.sysconglomerates where
conglomeratename = ?" );
+        ps.setString( 1, conglomerateName );
+        ResultSet rs = ps.executeQuery();
+        ResultSetMetaData rsmd = rs.getMetaData();
+
+        int jdbcType = correctBehavior ? Types.BOOLEAN : Types.SMALLINT;
+        String typeName = correctBehavior ? "BOOLEAN" : "SMALLINT";
+        int precision = correctBehavior ? 1 : 5;
+        int scale = 0;
+        int columnDisplaySize = correctBehavior ? 5 : 6;
+        String columnClassName = correctBehavior ? "java.lang.Boolean" : "java.lang.Integer";
+
+        Object objectValue;
+        if ( correctBehavior )
+        {
+            objectValue = new Boolean( expectedValue );
+        }
+        else
+        {
+            objectValue = expectedValue ? new Integer( 1 ) : new Integer( 0 );
+        }        
+        String stringValue = objectValue.toString();
+
+        assertEquals( jdbcType, rsmd.getColumnType( 1 ) );
+        assertEquals( typeName, rsmd.getColumnTypeName( 1 ) );
+        assertEquals( precision, rsmd.getPrecision( 1 ) );
+        assertEquals( scale, rsmd.getScale( 1 ) );
+        assertEquals( columnDisplaySize, rsmd.getColumnDisplaySize( 1 ) );
+        assertEquals( columnClassName, rsmd.getColumnClassName( 1 ) );
+
+        assertEquals( true, rs.next() );
+        
+        assertEquals( expectedValue, rs.getBoolean( 1 ) );
+        assertEquals( objectValue, rs.getObject( 1 ) );
+        assertEquals( stringValue, rs.getString( 1 ) );
+
+        rs.close();
+        ps.close();
+    }
+    
+	/////////////////////////////////////////////////////////////
+	//
 	//	DERBY-2602
 	//
 	/////////////////////////////////////////////////////////////



Mime
View raw message