db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1565491 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apache/derbyTesting/f...
Date Fri, 07 Feb 2014 00:00:20 GMT
Author: mamta
Date: Fri Feb  7 00:00:20 2014
New Revision: 1565491

URL: http://svn.apache.org/r1565491
Log:
DERBY-4805(Increase the length of the RDBNAM field in the DRDA implementation)

This commit will allow RDBNAM to be 1024 bytes, thus lifting the limit from current 255bytes.
I have changed the existing boundary test case to test for the new limit but the tests now
use in-memory db jdbc url since on disk long urls were running into problem because of OS/file
system limitation on the length of file name length.

As for newer client(version 10.11 and higher) going against an older server(10.10 and lower
which will not have the fix for DERBY-4805 and hence will not accept the longer RDBNAM) with
new RDBNAM limit, it will result in protocol exception. This is because when the client makes
the first connect request to server, it has no way of knowing what server version it is talking
to and hence there is no way to catch the length violation on the client side at this point.


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConfiguration.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/NetConnectionReply.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/protocol.tests
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/InternationalConnectTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientDatabaseMetaData.java
Fri Feb  7 00:00:20 2014
@@ -102,6 +102,13 @@ public abstract class ClientDatabaseMeta
     private boolean supportsBooleanValues_;
 
     /**
+     * DERBY-4805(Increase the length of the RDBNAM field in the DRDA 
+     *   implementation)  
+     * True if the server supports RDBNAM longer than 255 character
+     */
+    private boolean supportsLongRDBNAM_;
+
+    /**
      * True if the server supports transport of boolean parameter values as
      * booleans. If false, boolean values used as parameters in prepared
      * statements will be transported as smallints to preserve backwards
@@ -2372,6 +2379,9 @@ public abstract class ClientDatabaseMeta
 
         supportsBooleanParameterTransport_ =
                 productLevel_.greaterThanOrEqualTo(10, 8, 0);
+
+        supportsLongRDBNAM_ =
+                productLevel_.greaterThanOrEqualTo(10, 11, 0);
     }
 
     /**
@@ -2436,6 +2446,10 @@ public abstract class ClientDatabaseMeta
         return supportsBooleanParameterTransport_;
     }
 
+    final public boolean serverSupportLongRDBNAM() {
+        return supportsLongRDBNAM_;
+    }
+
     //------------helper methods for meta data info call methods------------------
 
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConfiguration.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConfiguration.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConfiguration.java Fri
Feb  7 00:00:20 2014
@@ -86,6 +86,10 @@ public class NetConfiguration {
     // Identifier Length for fixed length rdb name
     static final int PKG_IDENTIFIER_FIXED_LEN = 18;
 
+    // Maximum RDBNAM Identifier Length
+    //  this used to be 255 prior to DERBY-4805 fix
+    static final int RDBNAM_MAX_LEN = 1024;  
+
     // Maximum RDB Identifier Length
     static final int PKG_IDENTIFIER_MAX_LEN = 255;
 

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=1565491&r1=1565490&r2=1565491&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 Fri Feb
 7 00:00:20 2014
@@ -1656,6 +1656,15 @@ public class NetConnection extends Clien
 
     }
     
+    public final boolean serverSupportLongRDBNAM() {
+        
+        NetDatabaseMetaData metadata =
+            (NetDatabaseMetaData) databaseMetaData_;
+        
+        return metadata.serverSupportLongRDBNAM();
+
+    }
+    
     
     /**
      * Check whether the server supports session data caching

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionReply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionReply.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionReply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionReply.java Fri
Feb  7 00:00:20 2014
@@ -2665,7 +2665,7 @@ class NetConnectionReply extends Reply
     //   SQLWARN8; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
     //   SQLWARN9; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
     //   SQLWARNA; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
-    //   SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+    //   SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
     //   SQLERRMSG_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 70
     //   SQLERRMSG_s; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 70
     private void parseSQLCAXGRP(NetSqlca netSqlca) throws DisconnectException {
@@ -2688,7 +2688,7 @@ class NetConnectionReply extends Reply
 
         if (netAgent_.targetSqlam_ >= NetConfiguration.MGRLVL_7) {
             // skip over the rdbnam for now
-            // SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+            // SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
             parseFastVCS();
         }
 
@@ -3067,7 +3067,7 @@ class NetConnectionReply extends Reply
     // SQLCNATYPE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
     // SQLCNETYPE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
     // SQLCNPRDID; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 8
-    // SQLCNRDB; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+    // SQLCNRDB; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
     // SQLCNCLASS; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
     // SQLCNAUTHID; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
     private void parseSQLCNGRP() throws DisconnectException {
@@ -3156,33 +3156,33 @@ class NetConnectionReply extends Reply
     // SQL Diagnostics Extended Names Group Description - Identity 0xD5
     // Nullable
     //
-    // SQLDCXRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
+    // SQLDCXRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 1024
     // SQLDCXSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
     // SQLDCXNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
     // SQLDCXTBLN_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
-    // SQLDCXRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
+    // SQLDCXRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 1024
     // SQLDCXSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     // SQLDCXNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     // SQLDCXTBLN_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     //
-    // SQLDCXCRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
+    // SQLDCXCRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 1024
     // SQLDCXCSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
     // SQLDCXCNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
-    // SQLDCXCRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
+    // SQLDCXCRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 1024
     // SQLDCXCSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     // SQLDCXCNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     //
-    // SQLDCXRRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
+    // SQLDCXRRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 1024
     // SQLDCXRSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
     // SQLDCXRNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
-    // SQLDCXRRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
+    // SQLDCXRRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 1024
     // SQLDCXRSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     // SQLDCXRNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     //
-    // SQLDCXTRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
+    // SQLDCXTRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 1024
     // SQLDCXTSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
     // SQLDCXTNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
-    // SQLDCXTRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
+    // SQLDCXTRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 1024
     // SQLDCXTSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     // SQLDCXTNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
     private void parseSQLDCXGRP() throws DisconnectException {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnectionRequest.java
Fri Feb  7 00:00:20 2014
@@ -493,9 +493,22 @@ class NetConnectionRequest extends Reque
             
         }
         
+        //DERBY-4805(Increase the length of the RDBNAM field in the 
+        // DRDA implementation)
+        //The new RDBNAM length in 10.11 is 1024bytes(it used to be 254 bytes).
+        //But if a 10.11 or higher client talks to a 10.10 or under server with
+        // a RDBNAM > 254 bytes, it will result in a protocol exception
+        // because those servers do not support RDBNAM greater than 254 bytes.
+        // This behavior will logged in the jira.
+        //One way to fix this would have been to check the server version
+        // before hand but we do not have that information when the client is
+        // first trying to establish connection to the server by sending the
+        // connect request along with the RDBNAM.
+        int maxRDBlength =
+                 NetConfiguration.RDBNAM_MAX_LEN;
         writeScalarString(CodePoint.RDBNAM, rdbnam,
                 NetConfiguration.PKG_IDENTIFIER_FIXED_LEN, //minimum RDBNAM length in bytes
-                NetConfiguration.PKG_IDENTIFIER_MAX_LEN,   //maximum RDBNAM length in bytes
+                maxRDBlength,  
                 SQLState.NET_DBNAME_TOO_LONG);
                 
     }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetCursor.java Fri Feb  7
00:00:20 2014
@@ -664,7 +664,7 @@ class NetCursor extends Cursor {
     //   SQLWARN8; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
     //   SQLWARN9; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
     //   SQLWARNA; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
-    //   SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+    //   SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
     //   SQLERRMSG_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 70
     //   SQLERRMSG_s; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 70
     private void parseSQLCAXGRP(Typdef typdef, NetSqlca netSqlca) throws DisconnectException,
SqlException {
@@ -684,7 +684,7 @@ class NetCursor extends Cursor {
         byte[] sqlwarn = readFdocaBytes(11);
 
         // skip over the rdbnam for now
-        // SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+        // SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
         parseVCS(typdef);
 
         //   SQLERRMSG_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 70
@@ -781,7 +781,7 @@ class NetCursor extends Cursor {
     // SQLDCMSGID; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 10
     // SQLDCMDE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 8
     // SQLDCPMOD; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 5
-    // SQLDCRDB; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+    // SQLDCRDB; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
     // SQLDCTOKS; PROTOCOL TYPE N-RLO; ENVLID 0xF7; Length Override 0
     // SQLDCMSG_m; PROTOCOL TYPE NVMC; ENVLID 0x3F; Length Override 32672
     // SQLDCMSG_S; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 32672

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java Fri
Feb  7 00:00:20 2014
@@ -59,10 +59,15 @@ class NetPackageRequest extends NetConne
         byte[] pkgNameBytes = ccsidMgr.convertFromJavaString(
                 section.getPackageName(), netAgent_);
 
+        //Maximum RDBNAM length would depend on the server level. 
+        // Server under 10.11 support only 255 bytes but server
+        // at 10.11 and higher support higher limit of 1024
         boolean scldtalenRequired =
                 checkPKGNAMlengths(netAgent_.netConnection_.databaseName_,
                 dbnameBytes.length,
-                maxIdentifierLength,
+                (netAgent_.netConnection_.databaseMetaData_.serverSupportLongRDBNAM())? 
+                        NetConfiguration.RDBNAM_MAX_LEN 
+                        : NetConfiguration.PKG_IDENTIFIER_MAX_LEN,  
                 NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
 
         if (!scldtalenRequired) {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java Fri
Feb  7 00:00:20 2014
@@ -1587,6 +1587,19 @@ class NetStatementReply extends NetPacka
 
         ensureBLayerDataInBuffer(ddmLength);
 
+        int maxDDMlength;
+        //For SQLAM level 7, this was harcoded to be 781 in 10.10 codeline. But
+        // after DERBY-4805 is fixed in Derby 10.11, we allow 1024 bytes for
+        // RDBNAM rather than just 255 characters. Because of this, the 
+        // DDM length in Derby 10.11 can be higher than 781. To be precise,
+        // it is 781-255+1024=1550. The following if statement is doing this
+        // calculation using constant identifiers rather than constant values
+        if (netAgent_.netConnection_.databaseMetaData_.serverSupportLongRDBNAM()) {
+        	maxDDMlength = 781-NetConfiguration.PKG_IDENTIFIER_MAX_LEN+
+        			NetConfiguration.RDBNAM_MAX_LEN;
+        } else
+        	maxDDMlength = 781;
+
         if (ddmLength == 64) {
             // read all the bytes except the section number into the byte[] for caching
             pkgnamcsnLength = ddmLength - 2;
@@ -1600,7 +1613,7 @@ class NetStatementReply extends NetPacka
             rdbcolid = readFastString(18); // RDB Collection ID
             pkgid = readFastString(18);    // RDB Package ID
             pkgcnstkn = readFastBytes(8);  // Package Consistency Token
-        } else if ((ddmLength >= 71) && (ddmLength <= 781)) {
+        } else if ((ddmLength >= 71) && (ddmLength <= maxDDMlength)) {
             // this is the new SCLDTA format.
 
             // new up a byte[] to cache all the bytes except the 2-byte section number
@@ -1608,7 +1621,12 @@ class NetStatementReply extends NetPacka
 
             // get rdbnam
             int scldtaLen = peekFastLength();
-            if (scldtaLen < 18 || scldtaLen > 255) {
+            int maxRDBlength =
+                    ((netAgent_.netConnection_.databaseMetaData_.serverSupportLongRDBNAM())?

+                            NetConfiguration.RDBNAM_MAX_LEN 
+                            : NetConfiguration.PKG_IDENTIFIER_MAX_LEN);
+            if (scldtaLen < NetConfiguration.PKG_IDENTIFIER_FIXED_LEN || 
+            		scldtaLen > maxRDBlength) {
                 agent_.accumulateChainBreakingReadExceptionAndThrow(
                     new DisconnectException(agent_,
                         new ClientMessageId(
@@ -2110,7 +2128,7 @@ class NetStatementReply extends NetPacka
     //   SQLXUPDATEABLE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
     //   SQLXGENERATED; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
     //   SQLXPARMMODE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
-    //   SQLXRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+    //   SQLXRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
     //   SQLXCORNAME_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 255
     //   SQLXCORNAME_s; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
     //   SQLXBASENAME_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 255
@@ -2138,7 +2156,7 @@ class NetStatementReply extends NetPacka
         //   SQLXPARMMODE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
         short sqlxparmmode = readFastShort();
 
-        //   SQLXRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+        //   SQLXRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
         String sqlxrdbnam = parseFastVCS();
 
         //   SQLXCORNAME_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 255
@@ -2206,7 +2224,7 @@ class NetStatementReply extends NetPacka
     //   SQLDSENSITIVE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
     //   SQLDFCODE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
     //   SQLDKEYTYPE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
-    //   SQLDRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+    //   SQLDRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
     //   SQLDSCHEMA_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 255
     //   SQLDSCHEMA_s; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
     private void parseSQLDHGRP(ColumnMetaData columnMetaData) throws DisconnectException
{
@@ -2233,7 +2251,7 @@ class NetStatementReply extends NetPacka
         //   SQLDKEYTYPE; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
         short sqldkeytype = readFastShort();
 
-        //   SQLDRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
+        //   SQLDRDBNAM; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 1024
         String sqldrdbnam = parseFastVCS();
 
         //   SQLDSCHEMA_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 255

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/CodePoint.java Fri Feb  7 00:00:20
2014
@@ -751,9 +751,13 @@ class CodePoint
     static final String TYPDEFNAM_QTDSQLX86 = "QTDSQLX86"; //  Intel X86 platform
 
     //----------------------Max sizes for strings in the protocol ---------
+    //dbname 
+    // fixed length for SQLAM level 6, 
+    // for level 7, limit is MAX_NAME(255) but Derby 10.11 allows 1024
     static final int MAX_NAME = 255;
-    static final int RDBNAM_LEN = 18; //dbname fixed length for SQLAM level 6, for level
7,
-                                      //limit is MAX_NAME (255)
+    static final int RDBNAM_MAX_NAME = 1024;
+    static final int RDBNAM_LEN = 18; 
+                                      
     static final int PRDID_MAX = 8;
     static final int RDBCOLID_LEN = 18;
     static final int PKGID_LEN = 18;

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=1565491&r1=1565490&r2=1565491&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 Fri Feb 
7 00:00:20 2014
@@ -3011,8 +3011,9 @@ class DRDAConnThread extends Thread {
             rdbNotFound(null);
         }
         //SQLAM level 7 allows db name up to 255, level 6 fixed len 18
+        // but Derby 10.11 allows 1024
         if (rdbName.length < CodePoint.RDBNAM_LEN ||
-                rdbName.length > CodePoint.MAX_NAME) {
+                rdbName.length > CodePoint.RDBNAM_MAX_NAME) {
             badObjectLength(CodePoint.RDBNAM);
         }
         name = reader.convertBytes(rdbName);
@@ -5732,7 +5733,7 @@ class DRDAConnThread extends Thread {
         else    // extended format
         {
             int length = reader.readNetworkShort();
-            if (length < CodePoint.RDBNAM_LEN || length > CodePoint.MAX_NAME) {
+            if (length < CodePoint.RDBNAM_LEN || length > CodePoint.RDBNAM_MAX_NAME)
{
                 badObjectLength(CodePoint.RDBNAM);
             }
             reader.readString(rdbnam, length, true);
@@ -6604,7 +6605,7 @@ class DRDAConnThread extends Thread {
      *   SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
      *   SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
      *   SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1
-     *   SQLRDBNAME; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+     *   SQLRDBNAME; DRDA TYPE VCS; ENVLID 0x32; Length Override 1024
      *   SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70
      *   SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70
      * @param nextException SQLException encountered
@@ -8225,7 +8226,7 @@ class DRDAConnThread extends Thread {
             writer.writeShort(0);
         }
     
-        //   SQLXRDBNAM; DRDA TYPE VCS; ENVLID 0x32; Length Override 255
+        //   SQLXRDBNAM; DRDA TYPE VCS; ENVLID 0x32; Length Override 1024
         // JCC uses this as the catalog name so we will send null.
         writer.writeShort(0);
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/protocol.tests
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/protocol.tests?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/protocol.tests
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/protocol.tests
Fri Feb  7 00:00:20 2014
@@ -320,7 +320,7 @@ endDss
 createDssRequest
 startDdm ACCSEC
 writeScalar2Bytes SECMEC 3 //  userid password
-writeScalarPaddedBytes RDBNAM "thisNeedsToBeNoMoreThan255CharactersLong" 256
+writeScalarPaddedBytes RDBNAM "thisNeedsToBeNoMoreThan1024CharactersLong" 1025
 writeScalarString USRID test
 writeScalarString PASSWORD test
 endDdm

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/InternationalConnectTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/InternationalConnectTest.java?rev=1565491&r1=1565490&r2=1565491&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/InternationalConnectTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/InternationalConnectTest.java
Fri Feb  7 00:00:20 2014
@@ -66,68 +66,97 @@ public class InternationalConnectTest ex
         databasesForCleanup = new ArrayList<String>();
     }
 
+    //DERBY-4805(Increase the length of the RDBNAM field in the DRDA 
+    // implementation)
+    //Fixing the jira above now prevents us from getting limited to 255 bytes
+    // in network server case for RDBNAM. The new limit now is 1024 bytes.
+    //Try 2 test cases for database name. 
+    // One right at the upper boundary of 1024 byte length
+    // and second with going little over 1024 byte length.
+    //Note that the test below is written for in-memory db rather than
+    // traditional on disk dbs. This is because depending on the file
+    // system and operating systems, there are different limits on
+    // how long a file name can be. In order to avoid having to 
+    // worry about various OSes, it is more portable to do the testing
+    // with in-memory db. 
     public void testBoundaries() throws SQLException, UnsupportedEncodingException {
         if (usingEmbedded()) return; /* This test is only for Client/Server */
 
-        // ensuring that we get a connection.
-        getConnection();
-        
+        //To get around the file name length limit on various operating 
+        // systems, using in memory db to try the long RDBNAM of 1024
+        // bytes
+        //Following url works fine because the length of string
+        // memory...;true is 1024 bytes long
+        String dbUrl1024bytes = "memory:dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir12
 34567890/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;create=true";
+        //Following url fails because the length of string
+        // memory...;true is 1025 bytes long, 1 byte longer than max length
+        String dbUrl1025bytes = "memory:dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir1234567890/dir12
 34567890/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;create=true";
+
         /*
-         * Sun's 1.4.2 JVM and IBM's JVM (any version) fail on Windows for this test
-         * Thus, we skip it.
-         * 
-         * Read JIRA's DERBY-4836 for more information.
-         */
-        if (getSystemProperty("os.name").startsWith("Windows")) {            
-            /* Skip with 1.4.2 jvms */
-            if (getSystemProperty("java.version").startsWith("1.4.2")) return;
-        }
-        
-        // Maximum length in bytes is 255. We subtract 14 to account for
-        // ;create=true and ;shutdown=true
-        int maxNameLength = 255 - 14;
-        
-        /**
-         * \u0041 is the letter 'A' (1 byte)
-         * \u00e7 is the letter 'c' with a cedilla (2 bytes)
-         * \u4310 is a Chinese character (3 bytes)
-         * \u1f030 is a domino tile (4 bytes)
+         *Prior to DERBY-4805 fix, maximum length in bytes was 255. With
+         * the fix, the new maximum length is 1024 bytes
+         *Try 2 test cases. One right at the upper boundary of 1024 byte length
+         * and second with 1025 byte length.
          */
-        String[] testCharacters = {"\u0041", "\u00e7", "\u4e10", "\u1f030"}; 
-        
-        for (int ch=0; ch<testCharacters.length; ch++) {
-            StringBuffer dbName = new StringBuffer();
-            
-            /* max length in bytes divided by length of 1 chinese char */ 
-            int maxChars = maxNameLength / testCharacters[ch].getBytes("UTF-8").length;
-            for(int i=0; i<maxChars; i++) {
-                dbName.append(testCharacters[ch]);
-            }
-            
-            /* This time it should work as we're right at the limit */
-            String url = TestConfiguration
-                    .getCurrent().getJDBCUrl(dbName.toString()+ ";create=true");
-            
-            Connection conn = DriverManager.getConnection(url);
-            conn.close();
-            
-            /* Add the database name for cleanup on tearDown() */
-            databasesForCleanup.add(dbName.toString());
-            
-            /* Append three more characters to make it fail */
-            for (int i = 0; i < 3; i++) {
-                dbName.append(testCharacters[ch]);
-            }
 
-            url = TestConfiguration
-                    .getCurrent().getJDBCUrl(dbName.toString()+ ";create=true");
+        /* This time it should work as we're right at the limit */
+        String url = TestConfiguration
+                .getCurrent().getJDBCUrl(dbUrl1024bytes);
+        loadDriver(url);
+        Connection conn = DriverManager.getConnection(url);
+        conn.close();
 
-            try {
+        //Add test case 2
+        //We will try going over 1024 byte length for database name and it 
+        // will fail as expected
+        url = TestConfiguration
+                .getCurrent().getJDBCUrl(dbUrl1025bytes);
+
+        try {
                 conn = DriverManager.getConnection(url);
                 assertTrue("Used more characters than possible in database name",
                         false);
-            } catch (SQLException e) {
-                assertSQLState("08001", e); /* Check if it failed */
+        } catch (SQLException e) {
+            	assertSQLState("08001", e); /* Check if it failed */
+        }
+    }
+    
+    /**
+     * Will check if the JDBC driver has been loaded and load it if that is not
+     * the case.
+     * Any other exception messages than "No suitable driver" on the first
+     * attempt to get the JDBC driver will result in an assertion failure.
+     * 
+     * @param url a valid connection URL for the desired JDBC driver
+     * @throws SQLException if an unexpected exception is thrown
+     */
+    private void loadDriver(String url) throws SQLException {
+        try {
+            DriverManager.getDriver(url);
+        } catch (SQLException e) {
+            // getDriver() failed, JDBC driver probably not loaded.
+            // Expecting SQLState 08001 and message "No suitable driver"...
+            assertSQLState("Unexpected SQLState from getDriver().", "08001", e);
+            assertEquals("Unexpected exception message from getDriver(), ",
+                    "No suitable driver", e.getMessage());
+            String driverClass = 
+                    getTestConfiguration().getJDBCClient().getJDBCDriverName();
+            println("Loading JDBC driver " + driverClass);
+            // load the driver
+            try {
+                Class.forName(driverClass).newInstance();
+            } catch (ClassNotFoundException cnfe) {
+                throw new SQLException("Failed to load JDBC driver '" 
+                        + driverClass + "', ClassNotFoundException: " 
+                        + cnfe.getMessage());
+            } catch (IllegalAccessException iae) {
+                throw new SQLException("Failed to load JDBC driver '" 
+                        + driverClass + "', IllegalAccessException: " 
+                        + iae.getMessage());
+            } catch (InstantiationException ie) {
+                throw new SQLException("Failed to load JDBC driver '" 
+                        + driverClass + "', InstantiationException: " 
+                        + ie.getMessage());
             }
         }
     }



Mime
View raw message