db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1571790 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
Date Tue, 25 Feb 2014 19:22:24 GMT
Author: myrnavl
Date: Tue Feb 25 19:22:23 2014
New Revision: 1571790

URL: http://svn.apache.org/r1571790
Log:
DERBY-6477; OutOfMemoryError selecting from SYS.SYSALIASES
   backport of revision 1567604 from trunk

Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1567604

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?rev=1571790&r1=1571789&r2=1571790&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
Tue Feb 25 19:22:23 2014
@@ -33,6 +33,7 @@ import org.apache.derby.iapi.types.DataT
 
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
 
+import org.apache.derby.iapi.reference.Limits;
 import org.apache.derby.iapi.reference.SQLState;
 
 
@@ -607,6 +608,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/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java?rev=1571790&r1=1571789&r2=1571790&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LikeTest.java
Tue Feb 25 19:22:23 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