db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r785570 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
Date Wed, 17 Jun 2009 12:24:42 GMT
Author: kahatlen
Date: Wed Jun 17 12:24:42 2009
New Revision: 785570

URL: http://svn.apache.org/viewvc?rev=785570&view=rev
Log:
DERBY-4274: SYSCS_UPDATE_STATISTICS takes unnecessary table lock

Return just after the statistics have been updated to prevent the
generic ALTER TABLE code from locking the table exclusively.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java

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=785570&r1=785569&r2=785570&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 Jun 17 12:24:42 2009
@@ -322,6 +322,7 @@
 		if (updateStatistics)
 		{
 			updateStatistics(activation);
+            return;
 		}
 		/*
 		** Inform the data dictionary that we are about to write to it.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java?rev=785570&r1=785569&r2=785570&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateStatisticsTest.java
Wed Jun 17 12:24:42 2009
@@ -21,6 +21,7 @@
 
 package org.apache.derbyTesting.functionTests.tests.lang;
 
+import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -173,4 +174,29 @@
         //End of test case for better index selection after statistics
         //availability
     }
+
+    /**
+     * Test that SYSCS_UPDATE_STATISTICS doesn't obtain exclusive locks on
+     * the table or rows in the table (DERBY-4274).
+     */
+    public void testNoExclusiveLockOnTable() throws SQLException {
+        Statement s = createStatement();
+        s.execute("create table t (x char(1))");
+        s.execute("create index ti on t(x)");
+        s.execute("insert into t values 'a','b','c','d'");
+
+        setAutoCommit(false);
+        s.execute("lock table t in share mode");
+
+        Connection c2 = openDefaultConnection();
+        Statement s2 = c2.createStatement();
+        // This call used to time out because SYSCS_UPDATE_STATISTICS tried
+        // to lock T exclusively.
+        s2.execute("call syscs_util.syscs_update_statistics('APP', 'T', null)");
+        s2.close();
+        c2.close();
+
+        s.execute("drop table t");
+        commit();
+    }
 }



Mime
View raw message