db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r544993 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/ engine/org/apache/derby/diag/ engine/org/apache/derby/impl/sql/catalog/ engine/org/apache/derby/impl/sql/conn/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Wed, 06 Jun 2007 23:45:43 GMT
Author: djd
Date: Wed Jun  6 16:45:42 2007
New Revision: 544993

URL: http://svn.apache.org/viewvc?view=rev&rev=544993
Log:
DERBY-2772 Add system procedure SYSCS_UTIL.SYSCS_EMPTY_STATEMENT_CACHE() that ages statements
out of the cache.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.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/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java

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?view=diff&rev=544993&r1=544992&r2=544993
==============================================================================
--- 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 Jun
 6 16:45:42 2007
@@ -39,6 +39,7 @@
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.Property;
 import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.cache.CacheManager;
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.services.property.PropertyUtil;
 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
@@ -1647,5 +1648,22 @@
             throw PublicAPI.wrapStandardException(se);
         }
     }
-
+    
+    /**
+     * Empty as much of the cache as possible. It is not guaranteed 
+     * that the cache is empty after this call, as statements may be kept
+     * by currently executing queries, activations that are about to be garbage
+     * collected.
+     */
+    public static void SYSCS_EMPTY_STATEMENT_CACHE()
+       throws SQLException
+    {
+       LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
+       
+       CacheManager statementCache =
+           lcc.getLanguageConnectionFactory().getStatementCache();
+       
+       if (statementCache != null)
+           statementCache.ageOut();
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java?view=diff&rev=544993&r1=544992&r2=544993
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/StatementCache.java Wed Jun  6 16:45:42
2007
@@ -21,30 +21,25 @@
 
 package org.apache.derby.diag;
 
-import org.apache.derby.vti.VTITemplate;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
 
+import org.apache.derby.iapi.reference.Limits;
+import org.apache.derby.iapi.services.cache.CacheManager;
+import org.apache.derby.iapi.sql.ResultColumnDescriptor;
 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
+import org.apache.derby.iapi.util.StringUtil;
+import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
 import org.apache.derby.impl.sql.GenericPreparedStatement;
 import org.apache.derby.impl.sql.GenericStatement;
-
-import org.apache.derby.iapi.sql.ResultColumnDescriptor;
-import org.apache.derby.impl.jdbc.EmbedResultSetMetaData;
-import org.apache.derby.iapi.reference.Limits;
-import org.apache.derby.iapi.util.StringUtil;
-
-import java.sql.Types;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-
 import org.apache.derby.impl.sql.conn.CachedStatement;
-
-
-import java.util.Vector;
-
-import java.util.Iterator;
-import java.util.Collection;
+import org.apache.derby.vti.VTITemplate;
 
 /**
 	StatementCache is a virtual table that shows the contents of the SQL statement cache.
@@ -78,29 +73,15 @@
 	private GenericPreparedStatement currentPs;
 	private boolean wasNull;
 
-	/**
-		Empty the statement cache. Must be called from a SQL statement, e.g.
-		<PRE>
-		CALL org.apache.derby.diag.StatementCache::emptyCache()
-		</PRE>
-
-	*/
-	public static void emptyCache() throws SQLException {
-
-		org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext lcc =
-			(org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext) ConnectionUtil.getCurrentLCC();
-
-		lcc.emptyCache();
-	}
-
 	public StatementCache() throws SQLException {
 
-		org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext lcc =
-			(org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext)
-			ConnectionUtil.getCurrentLCC();
+		LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
+        
+        CacheManager statementCache =
+            lcc.getLanguageConnectionFactory().getStatementCache();
 
-		if (lcc.statementCache != null) {
-			final Collection values = lcc.statementCache.values();
+		if (statementCache != null) {
+			final Collection values = statementCache.values();
 			data = new Vector(values.size());
 			for (Iterator i = values.iterator(); i.hasNext(); ) {
 				final CachedStatement cs = (CachedStatement) i.next();

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?view=diff&rev=544993&r1=544992&r2=544993
==============================================================================
--- 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 Jun  6 16:45:42 2007
@@ -10740,8 +10740,7 @@
                 tc);
         }
         
-        // void SYSCS_UTIL.SYSCS_SET_USER_ACCESS(USER_NAME VARCHAR(128),
-        // CONNECTION_PERMISSION VARCHAR(128))
+        // VARCHAR(128) SYSCS_UTIL.SYSCS_SET_USER_ACCESS(USER_NAME VARCHAR(128))
         {               
             TypeDescriptor[] arg_types = { varchar128 };
 
@@ -10754,6 +10753,20 @@
                 0,
                 RoutineAliasInfo.READS_SQL_DATA,
                 varchar128,
+                tc);
+        }
+        
+        // void SYSCS_UTIL.SYSCS_EMPTY_STATEMENT_CACHE()
+        {               
+            createSystemProcedureOrFunction(
+                "SYSCS_EMPTY_STATEMENT_CACHE",
+                sysUtilUUID,
+                (String[]) null,
+                (TypeDescriptor[]) null,
+                0,
+                0,
+                RoutineAliasInfo.NO_SQL,
+                (TypeDescriptor) null,
                 tc);
         }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?view=diff&rev=544993&r1=544992&r2=544993
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Wed Jun  6 16:45:42 2007
@@ -254,9 +254,6 @@
 	// cache of ai being handled in memory (bulk insert + alter table).
 	private HashMap autoincrementCacheHashtable;
 
-	// temp public
-	public CacheManager statementCache;
-
 	/*
 	   constructor
 	*/
@@ -310,8 +307,6 @@
 		stmtValidators = new ArrayList();
 		triggerExecutionContexts = new ArrayList();
 		triggerTables = new ArrayList();
-		
-		statementCache = lcf.getStatementCache();
 	}
 
 	public void initialize(boolean sqlConnection) throws StandardException
@@ -409,17 +404,6 @@
 		return lockEscalationThreshold;
 	}
 
-	/*
-		The methods that follow are for consistency checking purposes
-	 */
-
-	public int getCacheSize() {
-		if (statementCache != null)
-			return statementCache.getNumberInUse();
-		else
-			return 0;
-	}
-
 	/**
 	 * Add the activation to those known about by this connection.
 	 */
@@ -855,6 +839,9 @@
 	*/	
 	public void removeStatement(Statement statement)
 		throws StandardException {
+        
+        CacheManager statementCache =
+            getLanguageConnectionFactory().getStatementCache();
 
 		if (statementCache == null)
 			return;
@@ -875,7 +862,9 @@
 	public PreparedStatement lookupStatement(GenericStatement statement)
 		throws StandardException {
 
-
+        CacheManager statementCache =
+            getLanguageConnectionFactory().getStatementCache();
+            
 		if (statementCache == null)
 			return null;
 
@@ -1833,20 +1822,6 @@
 	{
 		identityVal = val;
 		identityNotNull = true;
-	}
-
-	/**
-		Empty as much of the cache as possible. It is not guaranteed
-		that the cache is empty after this call, as statements may be kept
-		by currently executing queries, activations that are about to be garbage
-		collected.
-	*/
-	public void emptyCache() {
-		/* We know prepared statements don't become dirty
-		** statementCache.cleanAll(); 
-		*/
-		if (statementCache != null)
-			statementCache.ageOut(); 
 	}
 
 	/**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java?view=diff&rev=544993&r1=544992&r2=544993
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StatementPlanCacheTest.java
Wed Jun  6 16:45:42 2007
@@ -77,15 +77,7 @@
                 "derby.language.statementCacheSize", "0", true));
         
         
-        return new CleanDatabaseTestSetup(suite) {
-            protected void decorateSQL(Statement s) throws SQLException {
-                s.execute("CREATE PROCEDURE EMPTY_STATEMENT_CACHE() " +
-                        "LANGUAGE JAVA PARAMETER STYLE JAVA " +
-                        "NO SQL " +
-                        "EXTERNAL NAME 'org.apache.derby.diag.StatementCache.emptyCache'");
-            }
-            
-        };
+        return new CleanDatabaseTestSetup(suite);
     }
     
     private static Test suiteWithSizeSet(int cacheSize)
@@ -119,7 +111,7 @@
                 "SELECT COUNT(ID) FROM SYSCS_DIAG.STATEMENT_CACHE WHERE " +
                 "SCHEMANAME = ? AND SQL_TEXT = ?");
         Statement s = createStatement();
-        s.execute("CALL EMPTY_STATEMENT_CACHE()");
+        s.execute("CALL SYSCS_UTIL.SYSCS_EMPTY_STATEMENT_CACHE()");
         s.close();
        
     }



Mime
View raw message