You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2018/04/26 09:27:52 UTC

ignite git commit: IGNITE-8342: SQL: Fixed parameter parsing in CREATE INDEX command leading to infinite loop. This closes #3893.

Repository: ignite
Updated Branches:
  refs/heads/master d31aa12ed -> a0107c0b0


IGNITE-8342: SQL: Fixed parameter parsing in CREATE INDEX command leading to infinite loop. This closes #3893.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a0107c0b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a0107c0b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a0107c0b

Branch: refs/heads/master
Commit: a0107c0b075004770101f6ed74e04da54d8e5231
Parents: d31aa12
Author: shtykh_roman <rs...@yahoo.com>
Authored: Thu Apr 26 12:27:44 2018 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Apr 26 12:27:44 2018 +0300

----------------------------------------------------------------------
 .../sql/command/SqlCreateIndexCommand.java      | 38 +++++++++-----------
 .../sql/SqlParserCreateIndexSelfTest.java       |  2 ++
 2 files changed, 19 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a0107c0b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
index f3f38d4..2f31973 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
@@ -21,7 +21,6 @@ import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.internal.sql.SqlLexer;
 import org.apache.ignite.internal.sql.SqlLexerTokenType;
 import org.apache.ignite.internal.sql.SqlLexerToken;
-import org.apache.ignite.internal.sql.SqlParserUtils;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -175,7 +174,7 @@ public class SqlCreateIndexCommand implements SqlCommand {
     }
 
     /**
-     * Pasrse index name.
+     * Parse index name.
      *
      * @param lex Lexer.
      * @return Index name.
@@ -249,34 +248,31 @@ public class SqlCreateIndexCommand implements SqlCommand {
         while (true) {
             SqlLexerToken token = lex.lookAhead();
 
-            if (token.tokenType() == SqlLexerTokenType.EOF)
-                return;
+            if (token.tokenType() != SqlLexerTokenType.DEFAULT)
+                break;
 
-            if (token.tokenType() == SqlLexerTokenType.DEFAULT) {
-                switch (token.token()) {
-                    case PARALLEL:
-                        parallel = getIntProperty(lex, PARALLEL, foundProps);
+            switch (token.token()) {
+                case PARALLEL:
+                    parallel = getIntProperty(lex, PARALLEL, foundProps);
 
-                        if (parallel < 0)
-                            throw error(lex, "Illegal " + PARALLEL + " value. Should be positive: " + parallel);
+                    if (parallel < 0)
+                        throw error(lex, "Illegal " + PARALLEL + " value. Should be positive: " + parallel);
 
-                        break;
+                    break;
 
-                    case INLINE_SIZE:
-                        inlineSize = getIntProperty(lex, INLINE_SIZE, foundProps);
+                case INLINE_SIZE:
+                    inlineSize = getIntProperty(lex, INLINE_SIZE, foundProps);
 
-                        if (inlineSize < 0)
-                            throw error(lex, "Illegal " + INLINE_SIZE +
-                                " value. Should be positive: " + inlineSize);
+                    if (inlineSize < 0)
+                        throw error(lex, "Illegal " + INLINE_SIZE +
+                            " value. Should be positive: " + inlineSize);
 
-                        break;
+                    break;
 
-                    default:
-                        return;
-                }
+                default:
+                    return;
             }
         }
-
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/a0107c0b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
index 80328ab..465e8d1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
@@ -46,8 +46,10 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
     public void testCreateIndex() throws Exception {
         // Base.
         parseValidate(null, "CREATE INDEX idx ON tbl(a)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false);
+        parseValidate(null, "CREATE INDEX idx ON tbl(a);", null, "TBL", "IDX", DEFAULT_PROPS, "A", false);
         parseValidate(null, "CREATE INDEX idx ON tbl(a ASC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false);
         parseValidate(null, "CREATE INDEX idx ON tbl(a DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", true);
+        assertParseError(null, "CREATE INDEX idx ON tbl(a) ,", "Unexpected token: \",\"");
 
         // Case (in)sensitivity.
         parseValidate(null, "CREATE INDEX IDX ON TBL(COL)", null, "TBL", "IDX", DEFAULT_PROPS, "COL", false);