db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r824657 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/execute/ExecPreparedStatement.java impl/sql/GenericPreparedStatement.java impl/sql/execute/BaseActivation.java
Date Tue, 13 Oct 2009 10:00:27 GMT
Author: kahatlen
Date: Tue Oct 13 10:00:27 2009
New Revision: 824657

URL: http://svn.apache.org/viewvc?rev=824657&view=rev
Log:
DERBY-3024 (partial) Validation of shared plans hurts scalability

Moved some code that synchronized on a GenericPreparedStatement from
BaseActivation to GenericPreparedStatement for better encapsulation. This
also prevented the code from synchronizing on the same object twice, which
had a positive effect on the performance when the monitor was contented.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecPreparedStatement.java?rev=824657&r1=824656&r2=824657&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ExecPreparedStatement.java
Tue Oct 13 10:00:27 2009
@@ -89,6 +89,27 @@
 	 */
 	GeneratedClass getActivationClass() throws StandardException;
 
+    /**
+     * <p>
+     * Checks whether this PreparedStatement is up to date and its activation
+     * class is identical to the supplied generated class. A call to {@code
+     * upToDate(gc)} is supposed to perform the same work as the following code
+     * in one atomic operation:
+     * </p>
+     *
+     * <pre>
+     * getActivationClass() == gc && upToDate()
+     * </pre>
+     *
+     * @param gc a generated class that must be identical to {@code
+     * getActivationClass()} for this method to return {@code true}
+     * @return {@code true} if this statement is up to date and its activation
+     * class is identical to {@code gc}, {@code false} otherwise
+     * @see PreparedStatement#upToDate()
+     * @see #getActivationClass()
+     */
+    boolean upToDate(GeneratedClass gc) throws StandardException;
+
 	/**
 	 *  Mark the statement as unusable, i.e. the system is
 	 * finished with it and no one should be able to use it.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java?rev=824657&r1=824656&r2=824657&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
Tue Oct 13 10:00:27 2009
@@ -200,9 +200,29 @@
 	public synchronized boolean	upToDate()
 		throws StandardException
 	{
-		return  isValid && (activationClass != null) && !compilingStatement;
+		return isUpToDate();
 	}
 
+    /**
+     * Check whether this statement is up to date and its generated class is
+     * identical to the supplied class object.
+     * @see ExecPreparedStatement#upToDate(GeneratedClass)
+     */
+    public synchronized boolean upToDate(GeneratedClass gc) {
+        return (activationClass == gc) && isUpToDate();
+    }
+
+    /**
+     * Unsynchronized helper method for {@link #upToDate()} and {@link
+     * #upToDate(GeneratedClass)}. Checks whether this statement is up to date.
+     *
+     * @return {@code true} if this statement is up to date, {@code false}
+     * otherwise
+     */
+    private boolean isUpToDate() {
+        return isValid && (activationClass != null) && !compilingStatement;
+    }
+
 	public void rePrepare(LanguageConnectionContext lcc) 
 		throws StandardException {
 		if (!upToDate()) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java?rev=824657&r1=824656&r2=824657&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
Tue Oct 13 10:00:27 2009
@@ -267,15 +267,9 @@
 
 	public final void checkStatementValidity() throws StandardException {
 
-		if (preStmt == null)
+		if (preStmt == null || preStmt.upToDate(gc))
 			return;
 
-		synchronized (preStmt) {
-
-			if ((gc == preStmt.getActivationClass()) && preStmt.upToDate())
-				return;
-		}
-
 		StandardException se = StandardException.newException(SQLState.LANG_STATEMENT_NEEDS_RECOMPILE);
 		se.setReport(StandardException.REPORT_NEVER);
 		throw se;



Mime
View raw message