db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1567604 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
Date Wed, 12 Feb 2014 11:49:45 GMT
Author: kahatlen
Date: Wed Feb 12 11:49:45 2014
New Revision: 1567604

URL: http://svn.apache.org/r1567604
Log:
DERBY-6477: OutOfMemoryError selecting from SYS.SYSALIASES

Disable LIKE optimization for very long columns.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?rev=1567604&r1=1567603&r2=1567604&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
Wed Feb 12 11:49:45 2014
@@ -25,6 +25,7 @@ import java.sql.Types;
 import java.util.Arrays;
 import java.util.List;
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.Limits;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
@@ -588,6 +589,16 @@ public final class LikeEscapeOperatorNod
 
             int maxWidth = receiver.getTypeServices().getMaximumWidth();
 
+            // DERBY-6477: Skip this optimization if the receiver column has
+            // a very high maximum width (typically columns in the system
+            // tables, as they don't have the same restrictions as columns
+            // in user tables). Since greaterEqualString and lessThanString
+            // are padded to the maximum width, this optimization may cause
+            // OOME if the maximum width is high.
+            if (maxWidth > Limits.DB2_LONGVARCHAR_MAXWIDTH) {
+                return this;
+            }
+
             greaterEqualString = 
                 Like.greaterEqualString(pattern, escape, maxWidth);
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java?rev=1567604&r1=1567603&r2=1567604&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
Wed Feb 12 11:49:45 2014
@@ -26,7 +26,6 @@ import java.sql.Statement;
 import junit.framework.Test;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.RuntimeStatisticsParser;
 import org.apache.derbyTesting.junit.SQLUtilities;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -70,4 +69,13 @@ public class LikeTest extends BaseJDBCTe
                 expectedRows);
         assertTrue(SQLUtilities.getRuntimeStatisticsParser(s).usedIndexScan());
     }
+
+    public void testDerby6477() throws SQLException {
+        // DERBY-6477: This statement used to fail with an OutOfMemoryError.
+        JDBC.assertSingleValueResultSet(createStatement().executeQuery(
+                "select javaclassname from sys.sysaliases where "
+                    + "javaclassname like "
+                    + "'org.apache.derby.catalog.Java5SystemProcedures%'"),
+                "org.apache.derby.catalog.Java5SystemProcedures");
+    }
 }



Mime
View raw message