db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r600990 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
Date Tue, 04 Dec 2007 16:21:04 GMT
Author: kahatlen
Date: Tue Dec  4 08:21:03 2007
New Revision: 600990

URL: http://svn.apache.org/viewvc?rev=600990&view=rev
Log:
DERBY-3241: No syntax error when compiling statement with unterminated comment

Patch contributed by James F. Adams.

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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=600990&r1=600989&r2=600990&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Tue Dec
 4 08:21:03 2007
@@ -1708,26 +1708,40 @@
 	| "\r"
 }
 
-SKIP :
-{	/* comments */
-	  "--" : IN_COMMENT
-	| "/*" { commentNestingDepth = 1; } : IN_BRACKETED_COMMENT
+MORE :
+{
+	"/*" : IN_BRACKETED_COMMENT
+}
+
+<IN_BRACKETED_COMMENT> MORE :
+{
+	"/*" { commentNestingDepth = 1; } : IN_NESTED_BRACKETED_COMMENT
 }
 
 <IN_BRACKETED_COMMENT> SKIP :
 {
+	"*/" : DEFAULT
+}
+
+<IN_NESTED_BRACKETED_COMMENT> MORE :
+{
 	"/*" { commentNestingDepth++; }
 }
 
-<IN_BRACKETED_COMMENT> SKIP :
+<IN_NESTED_BRACKETED_COMMENT> MORE :
 {
 	"*/"
-	{ commentNestingDepth--; SwitchTo(commentNestingDepth == 0 ? DEFAULT : IN_BRACKETED_COMMENT);
}
+	{ commentNestingDepth--; SwitchTo(commentNestingDepth == 0 ? IN_BRACKETED_COMMENT : IN_NESTED_BRACKETED_COMMENT);
}
 }
 
-<IN_BRACKETED_COMMENT> SKIP :
+<IN_BRACKETED_COMMENT,IN_NESTED_BRACKETED_COMMENT> MORE :
 {
 	< ~[] >
+}
+
+SKIP :
+{	/* comments */
+	"--" : IN_COMMENT
 }
 
 <IN_COMMENT> SKIP :

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java?rev=600990&r1=600989&r2=600990&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CommentTest.java
Tue Dec  4 08:21:03 2007
@@ -119,6 +119,12 @@
         JDBC.assertFullResultSet(
             stmt.executeQuery("VALUES '/* a comment \n-- */'"),
             new String [][] {{"/* a comment \n-- */"}});
+
+        // unterminated comments
+        assertCallError("42X03", getConnection(), "VALUES 1 /*");
+        assertCallError("42X03", getConnection(), "VALUES 1 /* comment");
+        assertCallError("42X03", getConnection(), "VALUES 1 /* comment /*");
+        assertCallError("42X03", getConnection(), "VALUES 1 /* comment /* nested */");
     }
     
     /**



Mime
View raw message