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:17:10 UTC
svn commit: r984079 - in /db/derby/code/branches/10.5: ./
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:17:09 2010
New Revision: 984079
URL: http://svn.apache.org/viewvc?rev=984079&view=rev
Log:
DERBY-4748: StringIndexOutOfBoundsException on syntax error (invalid COMMIT)
Merged fix cleanly from trunk (revision 980684).
Modified:
db/derby/code/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/client/org/apache/derby/client/am/Statement.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 10 15:17:09 2010
@@ -1,2 +1,2 @@
/db/derby/code/branches/10.6:942027,957000,962738,965351
-/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792434,793089,793588,794106,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915733,916075,916897,918152,918359,921028,927430,928065,929085,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304
+/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792434,793089,793588,794106,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915733,916075,916897,918152,918359,921028,927430,928065,929085,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684
Modified: db/derby/code/branches/10.5/java/client/org/apache/derby/client/am/Statement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/client/org/apache/derby/client/am/Statement.java?rev=984079&r1=984078&r2=984079&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/client/org/apache/derby/client/am/Statement.java (original)
+++ db/derby/code/branches/10.5/java/client/org/apache/derby/client/am/Statement.java Tue Aug 10 15:17:09 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.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java?rev=984079&r1=984078&r2=984079&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java Tue Aug 10 15:17:09 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;");
}
/**