db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1071320 - in /db/derby/code/trunk/java: client/org/apache/derby/client/net/ engine/org/apache/derby/catalog/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/load/ engine/org/apac...
Date Wed, 16 Feb 2011 17:32:13 GMT
Author: kahatlen
Date: Wed Feb 16 17:32:12 2011
New Revision: 1071320

URL: http://svn.apache.org/viewvc?rev=1071320&view=rev
Log:
DERBY-5017: push code assignments down to where they are used

Patch contributed by Dave Brosius <dbrosius@apache.org>.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DDUtils.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/StatementTablePermission.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportAbstract.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSchemaNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/D_HeapController.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/Reply.java Wed Feb 16 17:32:12
2011
@@ -505,14 +505,14 @@ public class Reply {
             int oldCount = count_;
             count_ = count_ - (encryptedByte.length - clearedByte.length);
             if (((clearedByte[2] & 0xff) << 8) + ((clearedByte[3] & 0xff) <<
0) == 0x146c) {
-                int firstLobLength = ((clearedByte[0] & 0xFF) << 8) +
-                        ((clearedByte[1] & 0xFF) << 0);
 
                 boolean flag = false;
                 if (gdsFormatter == 0x54) {
                     flag = true;
                 }
                 if (flag) {
+                    int firstLobLength = ((clearedByte[0] & 0xFF) << 8) +
+                        ((clearedByte[1] & 0xFF) << 0);
                     if (oldCount - oldDssLength < 6) {
                         int totalBytesRead = fill(6); //sometimes the 2nd EXTDTA doesn't
come back, need to fetch again to get it
                         if (totalBytesRead > 0) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java Wed Feb
16 17:32:12 2011
@@ -1983,10 +1983,10 @@ public class SystemProcedures  {
     private static void createXplainSchema(String schemaName)
         throws SQLException
     {
-        String escapedSchema = IdUtil.normalToDelimited(schemaName);
         Connection conn = getDefaultConn();
         if (!hasSchema(conn, schemaName))
         {
+            String escapedSchema = IdUtil.normalToDelimited(schemaName);
             Statement s = conn.createStatement();
             s.executeUpdate("CREATE SCHEMA " + escapedSchema);
             s.close();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java Wed
Feb 16 17:32:12 2011
@@ -424,12 +424,9 @@ public abstract class BrokeredConnection
 
 	*/
 	public void setState(boolean complete) throws SQLException {
-		Class[] CONN_PARAM = { Integer.TYPE };
-		Object[] CONN_ARG = { new Integer(stateHoldability)};
-
-		Connection conn = getRealConnection();
 
 		if (complete) {
+		    Connection conn = getRealConnection();
 			conn.setTransactionIsolation(stateIsolationLevel);
 			conn.setReadOnly(stateReadOnly);
 			conn.setAutoCommit(stateAutoCommit);
@@ -439,6 +436,8 @@ public abstract class BrokeredConnection
 			// jdk13 does not have Connection.setHoldability method and hence using
 			// reflection to cover both jdk13 and higher jdks
 			try {
+		        Class[] CONN_PARAM = { Integer.TYPE };
+		        Object[] CONN_ARG = { new Integer(stateHoldability)};
 				Method sh = conn.getClass().getMethod("setHoldability", CONN_PARAM);
 				sh.invoke(conn, CONN_ARG);
 			} catch( Exception e)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/ConstraintDescriptor.java
Wed Feb 16 17:32:12 2011
@@ -692,11 +692,11 @@ public abstract class ConstraintDescript
         boolean clearDependencies) throws StandardException
     {       
         DataDictionary dd = getDataDictionary();
-        DependencyManager dm = dd.getDependencyManager();
         TransactionController tc = lcc.getTransactionExecute();
 
         if (clearDependencies)
         {
+            DependencyManager dm = dd.getDependencyManager();
             dm.clearDependencies(lcc, this);
         }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DDUtils.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DDUtils.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DDUtils.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DDUtils.java Wed
Feb 16 17:32:12 2011
@@ -381,9 +381,6 @@ public	class	DDUtils
 
 		Integer rAction;
 
-		String refTableName = refTd.getSchemaName() + "." + refTd.getName();
-
-
 		/*
 		** Validate the new referentail action value with respect to the 
 		** already existing connections to this table we gathered  from
@@ -392,6 +389,7 @@ public	class	DDUtils
 
 		if(checkImmediateRefTable)
 		{
+		    String refTableName = refTd.getSchemaName() + "." + refTd.getName();
 			rAction = ((Integer)dch.get(refTableName));
 			
 			// check possible invalide cases incase of self referencing foreign key

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/StatementTablePermission.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/StatementTablePermission.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/StatementTablePermission.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/StatementTablePermission.java
Wed Feb 16 17:32:12 2011
@@ -114,10 +114,10 @@ public class StatementTablePermission ex
 					   Activation activation)
 		throws StandardException
 	{
-		DataDictionary dd = lcc.getDataDictionary();
 		ExecPreparedStatement ps = activation.getPreparedStatement();
 
         if (!hasPermissionOnTable(lcc, activation, forGrant, ps)) {
+		    DataDictionary dd = lcc.getDataDictionary();
 			TableDescriptor td = getTableDescriptor( dd);
             throw StandardException.newException(
                 (forGrant ? SQLState.AUTH_NO_TABLE_PERMISSION_FOR_GRANT

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportAbstract.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportAbstract.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportAbstract.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ExportAbstract.java Wed Feb
16 17:32:12 2011
@@ -77,10 +77,10 @@ abstract class ExportAbstract {
                                       boolean[] isLargeChar) 
         throws Exception 
 	{
-    int columnCount = exportResultSetForObject.getColumnCount();
 
-	ResultSetMetaData rsm=rs.getMetaData();
     if (rs.next()){
+       int columnCount = exportResultSetForObject.getColumnCount();
+	   ResultSetMetaData rsm=rs.getMetaData();
        String[] rowObjects = new String[columnCount];
        for (int colNum = 0; colNum < columnCount; colNum++) {
            if (lobsInExtFile && 

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=1071320&r1=1071319&r2=1071320&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
Wed Feb 16 17:32:12 2011
@@ -4123,12 +4123,12 @@ public final class	DataDictionaryImpl
 		}
 
 		schemaUUID = sd.getUUID();
-		stmtKey = new TableKey(schemaUUID, stmtName);
 
 		/* Only use the cache if we're in compile-only mode */
 		if ((spsNameCache != null) && 
 			(getCacheMode() == DataDictionary.COMPILE_ONLY_MODE))
 		{
+		    stmtKey = new TableKey(schemaUUID, stmtName);
 			SPSNameCacheable cacheEntry = (SPSNameCacheable) spsNameCache.find(stmtKey);
 			if (cacheEntry != null)
 			{
@@ -8651,11 +8651,11 @@ public final class	DataDictionaryImpl
             // while the Row interface is 1 based.
             NumberDataValue currentAI = (NumberDataValue)row.getColumn(columnNum);
             long currentAIValue = currentAI.getLong();
-            NumberDataValue increment = (NumberDataValue)row.getColumn(columnNum + 2);
             
             if (doUpdate)
             {
                 // we increment and store the new value in SYSCOLUMNS
+                NumberDataValue increment = (NumberDataValue)row.getColumn(columnNum + 2);
                 currentAI = currentAI.plus(currentAI, increment, currentAI);
                 row.setColumn(columnNum, currentAI);
                 heapCC.replace(rl, row.getRowArray(), columnToUpdate);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSchemaNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSchemaNode.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSchemaNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DropSchemaNode.java
Wed Feb 16 17:32:12 2011
@@ -63,7 +63,6 @@ public class DropSchemaNode extends DDLS
 		
         LanguageConnectionContext lcc = getLanguageConnectionContext();
         StatementContext stx = lcc.getStatementContext();
-        String currentUser = stx.getSQLSessionContext().getCurrentUser();
 		/* 
 		** Users are not permitted to drop
 		** the SYS or APP schemas.
@@ -81,6 +80,7 @@ public class DropSchemaNode extends DDLS
         */
         if (isPrivilegeCollectionRequired())
         {
+            String currentUser = stx.getSQLSessionContext().getCurrentUser();
             getCompilerContext().addRequiredSchemaPriv(schemaName, 
                 currentUser,
                 Authorizer.DROP_SCHEMA_PRIV);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
Wed Feb 16 17:32:12 2011
@@ -95,7 +95,6 @@ public class ExtractOperatorNode extends
 
 		opTypeId = operand.getTypeId();
 		operandType = opTypeId.getJDBCTypeId();
-		TypeCompiler tc = operand.getTypeCompiler();
 
 		/*
 		** Cast the operand, if necessary, - this function is allowed only on
@@ -105,6 +104,7 @@ public class ExtractOperatorNode extends
 		*/
 		if (opTypeId.isStringTypeId())
 		{
+            TypeCompiler tc = operand.getTypeCompiler();
 			int castType = (extractField < 3) ? Types.DATE : Types.TIME;
 			operand =  (ValueNode)
 				getNodeFactory().getNode(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Wed Feb 16 17:32:12 2011
@@ -2387,9 +2387,9 @@ class AlterTableConstantAction extends D
 		numIndexes = compressIRGs.length;
 		indexConglomerateNumbers = indexLister.getIndexConglomerateNumbers();
 
-		ArrayList newCongloms = new ArrayList();
 		if (! (compressTable || truncateTable))		// then it's drop column
 		{
+		    ArrayList newCongloms = new ArrayList();
 			for (int i = 0; i < compressIRGs.length; i++)
 			{
 				int[] baseColumnPositions = compressIRGs[i].baseColumnPositions();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/D_HeapController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/D_HeapController.java?rev=1071320&r1=1071319&r2=1071320&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/D_HeapController.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/D_HeapController.java
Wed Feb 16 17:32:12 2011
@@ -116,11 +116,11 @@ public class D_HeapController extends Di
     double  ratio,
     String  ratio_desc)
     {
-        String double_str = "" + ratio;
         String short_str;
 
         if (ratio > 0.001)
         {
+            String double_str = "" + ratio;
             short_str = double_str.substring(
                 0, 
                 Math.min(double_str.lastIndexOf(".") + 3, double_str.length()));



Mime
View raw message