db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1200293 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/reference/ impl/db/ impl/jdbc/ impl/sql/catalog/ jdbc/
Date Thu, 10 Nov 2011 12:31:21 GMT
Author: kahatlen
Date: Thu Nov 10 12:31:20 2011
New Revision: 1200293

URL: http://svn.apache.org/viewvc?rev=1200293&view=rev
Log:
DERBY-4845: Improve the dependency tracking for our build targets

Don't call code that only works on Java SE platforms from code that's
supposed to work on CDC/Foundation Profile platforms.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java?rev=1200293&r1=1200292&r2=1200293&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java Thu Nov 10
12:31:20 2011
@@ -100,5 +100,31 @@ public interface Limits
     static final double DB2_SMALLEST_POSITIVE_DOUBLE = +2.225E-307d;
     static final double DB2_LARGEST_NEGATIVE_DOUBLE  = -2.225E-307d;
 
+    // Limits on the length of the return values for the procedures in
+    // LOBStoredProcedure.
+
+    /**
+     * The maximum length of the data returned from the BLOB stored procedures.
+     * <p>
+     * This value is currently dictated by the maximum length of
+     * VARCHAR/VARBINARY, because these are the return types of the stored
+     * procedures.
+     */
+    int MAX_BLOB_RETURN_LEN = Limits.DB2_VARCHAR_MAXWIDTH;
+
+    /**
+     * The maximum length of the data returned from the CLOB stored procedures.
+     * <p>
+     * This value is currently dictated by the maximum length of
+     * VARCHAR/VARBINARY, because these are the return types of the stored
+     * procedures, and the modified UTF8 encoding used for CLOB data. This
+     * threshold value could be higher (equal to {@code MAX_BLOB_RETURN_LEN}),
+     * but then the procedure fetching data from the CLOB must be rewritten to
+     * have more logic.
+     * <p>
+     * For now we use the defensive assumption that all characters are
+     * represented by three bytes.
+     */
+    int MAX_CLOB_RETURN_LEN = MAX_BLOB_RETURN_LEN / 3;
     
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java?rev=1200293&r1=1200292&r2=1200293&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/SlaveDatabase.java Thu Nov 10
12:31:20 2011
@@ -25,7 +25,6 @@ import org.apache.derby.iapi.error.Publi
 import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.error.ExceptionSeverity;
 import org.apache.derby.iapi.jdbc.AuthenticationService;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.context.ContextService;
@@ -34,8 +33,8 @@ import org.apache.derby.iapi.util.Interr
 import org.apache.derby.iapi.store.replication.slave.SlaveFactory;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 
-import java.sql.Driver;
-import java.sql.DriverManager;
+import org.apache.derby.jdbc.InternalDriver;
+
 import java.sql.SQLException;
 import java.util.Properties;
 
@@ -413,19 +412,15 @@ public class SlaveDatabase extends Basic
         } 
         try {
             shutdownInitiated = true;
-            String driverName = 
-                "org.apache.derby.jdbc.EmbeddedDriver";
-
-            Class.forName(driverName).newInstance();
-
-            Driver embedDriver = 
-                DriverManager.getDriver(Attribute.PROTOCOL);
 
             String conStr = "jdbc:derby:"+dbname+";"+
                 Attribute.REPLICATION_INTERNAL_SHUTDOWN_SLAVE+
                 "=true";
 
-            embedDriver.connect(conStr, (Properties) null);
+            InternalDriver driver = InternalDriver.activeDriver();
+            if (driver != null) {
+                driver.connect(conStr, (Properties) null);
+            }
         } catch (Exception e) {
             // Todo: report error to derby.log if exception is not
             // SQLState.SHUTDOWN_DATABASE

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java?rev=1200293&r1=1200292&r2=1200293&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java Thu
Nov 10 12:31:20 2011
@@ -23,8 +23,6 @@ package org.apache.derby.impl.jdbc;
 
 import java.sql.Blob;
 import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
 
 import org.apache.derby.iapi.jdbc.EngineLOB;
@@ -39,30 +37,6 @@ import org.apache.derby.jdbc.InternalDri
 public class LOBStoredProcedure {
 
     /**
-     * The maximum length of the data returned from the BLOB stored procedures.
-     * <p>
-     * This value is currently dictated by the maximum length of
-     * VARCHAR/VARBINARY, because these are the return types of the stored
-     * procedures.
-     */
-    public static final int MAX_BLOB_RETURN_LEN = Limits.DB2_VARCHAR_MAXWIDTH;
-
-    /**
-     * The maximum length of the data returned from the CLOB stored procedures.
-     * <p>
-     * This value is currently dictated by the maximum length of
-     * VARCHAR/VARBINARY, because these are the return types of the stored
-     * procedures, and the modified UTF8 encoding used for CLOB data. This
-     * threshold value could be higher (equal to {@code MAX_BLOB_RETURN_LEN}),
-     * but then the procedure fetching data from the CLOB must be rewritten to
-     * have more logic.
-     * <p>
-     * For now we use the defensive assumption that all characters are
-     * represented by three bytes.
-     */
-    public static final int MAX_CLOB_RETURN_LEN = MAX_BLOB_RETURN_LEN / 3;
-
-    /**
      * Creates a new empty Clob and registers it in the HashMap in the
      * Connection and returns the locator value corresponding to this Clob.
      * @return an integer that maps to the Clob value created.
@@ -174,7 +148,7 @@ public class LOBStoredProcedure {
         long pos, int len) throws SQLException {
         // Don't read more than what we can represent as a VARCHAR.
         // See DERBY-3769.
-        len = Math.min(len, MAX_CLOB_RETURN_LEN);
+        len = Math.min(len, Limits.MAX_CLOB_RETURN_LEN);
         return getClobObjectCorrespondingtoLOCATOR(LOCATOR).getSubString(pos, len);
     }
 
@@ -332,7 +306,7 @@ public class LOBStoredProcedure {
     throws SQLException {
         // Don't read more than what we can represent as a VARBINARY.
         // See DERBY-3769.
-        len = Math.min(len, MAX_BLOB_RETURN_LEN);
+        len = Math.min(len, Limits.MAX_BLOB_RETURN_LEN);
         return getBlobObjectCorrespondingtoLOCATOR(LOCATOR).getBytes(pos, len);
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1200293&r1=1200292&r2=1200293&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Thu Nov 10 12:31:20 2011
@@ -175,9 +175,6 @@ import java.security.NoSuchAlgorithmExce
 
 import java.sql.Types;
 
-// LOBStoredProcedure is imported only to get hold of a constant.
-import org.apache.derby.impl.jdbc.LOBStoredProcedure;
-
 /**
  * Standard database implementation of the data dictionary
  * that stores the information in the system catlogs.
@@ -2583,7 +2580,7 @@ public final class	DataDictionaryImpl
              TransactionController.ISOLATION_REPEATABLE_READ,
              tc);
         RoutineAliasInfo   oldRai = (RoutineAliasInfo) oldAD.getAliasInfo();
-        TypeDescriptor     newReturnType = DataTypeDescriptor.getCatalogType( Types.VARCHAR,
LOBStoredProcedure.MAX_CLOB_RETURN_LEN );
+        TypeDescriptor     newReturnType = DataTypeDescriptor.getCatalogType( Types.VARCHAR,
Limits.MAX_CLOB_RETURN_LEN );
         RoutineAliasInfo   newRai = new RoutineAliasInfo
             (
              oldRai.getMethodName(),
@@ -12308,7 +12305,7 @@ public final class	DataDictionaryImpl
                 false,
                 DataTypeDescriptor.getCatalogType(
                     Types.VARCHAR,
-                    LOBStoredProcedure.MAX_CLOB_RETURN_LEN),
+                    Limits.MAX_CLOB_RETURN_LEN),
                 newlyCreatedRoutines,
                 tc,
                 "org.apache.derby.impl.jdbc.LOBStoredProcedure");
@@ -12504,7 +12501,7 @@ public final class	DataDictionaryImpl
                 false,
                 DataTypeDescriptor.getCatalogType(
                     Types.VARBINARY,
-                    LOBStoredProcedure.MAX_BLOB_RETURN_LEN),
+                    Limits.MAX_BLOB_RETURN_LEN),
                 newlyCreatedRoutines,
                 tc,
                 "org.apache.derby.impl.jdbc.LOBStoredProcedure");

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java?rev=1200293&r1=1200292&r2=1200293&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java Thu Nov 10
12:31:20 2011
@@ -66,9 +66,6 @@ public class AutoloadedDriver implements
     // This is the driver that memorizes the autoloadeddriver (DERBY-2905)
     private static Driver _autoloadedDriver;
 
-    // This flag is true unless the deregister attribute has been set to
-    // false by the user (DERBY-2905)
-    private static boolean deregister = true;
 	//
 	// This is the driver that's specific to the JDBC level we're running at.
 	// It's the module which boots the whole Derby engine.
@@ -249,13 +246,13 @@ public class AutoloadedDriver implements
 		_engineForcedDown = true;
         try {
             // deregister is false if user set deregister=false attribute (DERBY-2905)
-            if (deregister && _autoloadedDriver != null) {
+            if (InternalDriver.getDeregister() && _autoloadedDriver != null) {
                 DriverManager.deregisterDriver(_autoloadedDriver);
                 _autoloadedDriver = null;
             } else {
                 DriverManager.deregisterDriver(_driverModule);
                 //DERBY 5085, need to restore the default value
-                deregister = true;
+                InternalDriver.setDeregister(true);
             }
             _driverModule = null;
         } catch (SQLException e) {
@@ -274,20 +271,6 @@ public class AutoloadedDriver implements
 	}
 	
     /**
-     * @param theValue set the deregister value
-     */
-    public static void setDeregister(boolean theValue) {
-        AutoloadedDriver.deregister = theValue;
-    }
-
-    /**
-     * @return the deregister value
-     */
-    public static boolean getDeregister() {
-        return deregister;
-    }
-
-    /**
      * load slightly more capable driver if possible.
      * But if the vm level doesn't support it, then we fall
      * back on the JDBC3 level driver.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java?rev=1200293&r1=1200292&r2=1200293&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java Thu Nov 10 12:31:20
2011
@@ -77,6 +77,13 @@ public abstract class InternalDriver imp
 	private ContextService contextServiceFactory;
 	private AuthenticationService	authenticationService;
 
+    /**
+     * Tells whether or not {@code AutoloadedDriver} should deregister itself
+     * on shutdown. This flag is true unless the deregister attribute has been
+     * set to false by the user (DERBY-2905).
+     */
+    private static boolean deregister = true;
+
 	public static final InternalDriver activeDriver()
 	{
 		return activeDriver;
@@ -230,7 +237,7 @@ public abstract class InternalDriver imp
                         boolean deregister = Boolean.valueOf(
                                 finfo.getProperty(Attribute.DEREGISTER_ATTR))
                                 .booleanValue();
-                        AutoloadedDriver.setDeregister(deregister);
+                        InternalDriver.setDeregister(deregister);
                     }
 
 					// check for shutdown privileges
@@ -634,7 +641,25 @@ public abstract class InternalDriver imp
                            (ResultColumnDescriptor[] columnInfo) {
             return new EmbedResultSetMetaData(columnInfo);
         }
-}
-
 
+    /**
+     * Indicate to {@code AutoloadedDriver} whether it should deregister
+     * itself on shutdown.
+     *
+     * @param deregister whether or not {@code AutoloadedDriver} should
+     * deregister itself
+     */
+    static void setDeregister(boolean deregister) {
+        InternalDriver.deregister = deregister;
+    }
 
+    /**
+     * Check whether {@code AutoloadedDriver} should deregister itself on
+     * shutdown.
+     *
+     * @return the deregister value
+     */
+    static boolean getDeregister() {
+        return InternalDriver.deregister;
+    }
+}



Mime
View raw message