You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by kr...@apache.org on 2010/08/10 17:18:08 UTC
svn commit: r984080 - in /db/derby/code/branches/10.4: ./
java/client/org/apache/derby/client/am/Statement.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
Author: kristwaa
Date: Tue Aug 10 15:18:05 2010
New Revision: 984080
URL: http://svn.apache.org/viewvc?rev=984080&view=rev
Log:
DERBY-4748: StringIndexOutOfBoundsException on syntax error (invalid COMMIT)
Merged fix cleanly from trunk (revision 980684).
Modified:
db/derby/code/branches/10.4/ (props changed)
db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Statement.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
Propchange: db/derby/code/branches/10.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 10 15:18:05 2010
@@ -1,2 +1,2 @@
/db/derby/code/branches/10.5:814216,958230
-/db/derby/code/trunk:788436,793588,794303,796316,796372,797147,798347,798742,800523,803548,805696,809643,812669,816536,835286,882732,898635,915733,928065,934996,946794,954544,958163,958230,959550
+/db/derby/code/trunk:788436,793588,794303,796316,796372,797147,798347,798742,800523,803548,805696,809643,812669,816536,835286,882732,898635,915733,928065,934996,946794,954544,958163,958230,959550,980684
Modified: db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Statement.java?rev=984080&r1=984079&r2=984080&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/branches/10.4/java/client/org/apache/derby/client/am/Statement.java Tue Aug 10 15:18:05 2010
@@ -2357,27 +2357,16 @@ public class Statement implements java.s
* @return identifier or unmodified string
*/
private String isolateAnyInitialIdentifier (String sql) {
- int idx = 0;
- int length = sql.length();
-
- if (length == 0) {
- return sql;
- }
-
- char next = sql.charAt(idx);
-
- if (!Character.isLetter(next)) {
- return sql;
- }
-
- while (idx < length) {
- if (!Character.isLetter(next)) {
+ int idx;
+ for (idx = 0; idx < sql.length(); idx++) {
+ char ch = sql.charAt(idx);
+ if (!Character.isLetter(ch)) {
+ // first non-token char found
break;
}
- next = sql.charAt(++idx);
}
-
- return sql.substring(0, idx);
+ // return initial token if one is found, or the entire string otherwise
+ return (idx > 0) ? sql.substring(0, idx) : sql;
}
/**
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java?rev=984080&r1=984079&r2=984080&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java Tue Aug 10 15:18:05 2010
@@ -22,8 +22,6 @@
package org.apache.derbyTesting.functionTests.tests.lang;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
@@ -31,15 +29,13 @@ import java.sql.Types;
import junit.framework.Assert;
import junit.framework.Test;
-import junit.framework.TestSuite;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
import org.apache.derbyTesting.junit.JDBC;
import org.apache.derbyTesting.junit.TestConfiguration;
/**
- * Test for comments.
+ * Test for comments, and a few tests related to parsing non-comment SQL.
*/
public final class CommentTest extends BaseJDBCTestCase {
@@ -216,6 +212,10 @@ public final class CommentTest extends B
s.executeQuery("select'a' from sys.systables"));
JDBC.assertDrainResults(
s.executeQuery("select\"TABLEID\" from sys.systables"));
+
+ // Added for DERBY-4748.
+ assertCompileError("42X01", "commit");
+ assertCompileError("42X01", "commit;");
}
/**