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 2016/09/14 11:10:32 UTC
[16/50] ignite git commit: IGNITE-3743: ODBC: Added procedure call
escape sequence support. This closes #1008.
IGNITE-3743: ODBC: Added procedure call escape sequence support. This closes #1008.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/df8163f1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/df8163f1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/df8163f1
Branch: refs/heads/ignite-3661
Commit: df8163f1ad3a390bb8d51b0eb2f378b5b3663025
Parents: 42963e6
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Mon Sep 5 14:15:59 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Sep 5 14:15:59 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeType.java | 4 +
.../processors/odbc/escape/OdbcEscapeUtils.java | 5 +
.../odbc/OdbcEscapeSequenceSelfTest.java | 125 +++++++++++++++++++
3 files changed, 134 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/df8163f1/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
index 3bf0324..c7e3234 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
@@ -27,6 +27,9 @@ public enum OdbcEscapeType {
/** Outer join. */
OUTER_JOIN("oj", true, false),
+ /** Stored procedure call */
+ CALL("call", true, false),
+
/** Date. */
DATE("d", true, false),
@@ -47,6 +50,7 @@ public enum OdbcEscapeType {
SCALAR_FUNCTION, // Assume that scalar functions are very frequent.
DATE, TIMESTAMP, // Date and timestamp are relatively frequent as well; also TS must go before T.
OUTER_JOIN, // Joins are less frequent,
+ CALL, // Procedure calls are less frequent than joins.
LIKE, TIME, GUID // LIKE, TIME and GUID are even less frequent.
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/df8163f1/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index 48d4296..88afc52 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -278,6 +278,11 @@ public class OdbcEscapeUtils {
case OUTER_JOIN:
return parseExpression(text, startPos0, len0);
+ case CALL: {
+ String val = parseExpression(text, startPos0, len0);
+
+ return "CALL " + val;
+ }
default:
throw new IgniteException("Unsupported escape sequence token [text=" +
substring(text, startPos, len) + ", token=" + token.type().body() + ']');
http://git-wip-us.apache.org/repos/asf/ignite/blob/df8163f1/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
index 3fec7d3..26221ea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -540,6 +540,131 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
checkFail("{fn func(arg')}");
}
+
+ /**
+ * Test escape sequence series.
+ */
+ public void testSimpleCallProc() throws Exception {
+ check(
+ "CALL test()",
+ "{call test()}"
+ );
+
+ check(
+ "select CALL test()",
+ "select {call test()}"
+ );
+
+ check(
+ "select CALL test() from table;",
+ "select {call test()} from table;"
+ );
+
+ check(
+ "CALL func(field1) CALL func(field2)",
+ "{call func(field1)} {call func(field2)}"
+ );
+
+ check(
+ "select CALL func(field1), CALL func(field2)",
+ "select {call func(field1)}, {call func(field2)}"
+ );
+
+ check(
+ "select CALL func(field1), CALL func(field2) from table;",
+ "select {call func(field1)}, {call func(field2)} from table;"
+ );
+ }
+
+ /**
+ * Test simple nested escape sequences. Depth = 2.
+ */
+ public void testNestedCallProc() throws Exception {
+ check(
+ "CALL func1(field1, CALL func2(field2))",
+ "{call func1(field1, {call func2(field2)})}"
+ );
+
+ check(
+ "select CALL func1(field1, CALL func2(field2))",
+ "select {call func1(field1, {call func2(field2)})}"
+ );
+
+ check(
+ "select CALL func1(field1, CALL func2(field2), field3) from SomeTable;",
+ "select {call func1(field1, {call func2(field2)}, field3)} from SomeTable;"
+ );
+ }
+
+ /**
+ * Test nested escape sequences. Depth > 2.
+ */
+ public void testDeepNestedCallProc() {
+ check(
+ "CALL func1(CALL func2(CALL func3(field1)))",
+ "{call func1({call func2({call func3(field1)})})}"
+ );
+
+ check(
+ "CALL func1(CALL func2(CALL func3(CALL func4(field1))))",
+ "{call func1({call func2({call func3({call func4(field1)})})})}"
+ );
+
+ check(
+ "select CALL func1(field1, CALL func2(CALL func3(field2), field3))",
+ "select {call func1(field1, {call func2({call func3(field2)}, field3)})}"
+ );
+
+ check(
+ "select CALL func1(field1, CALL func2(CALL func3(field2), field3)) from SomeTable;",
+ "select {call func1(field1, {call func2({call func3(field2)}, field3)})} from SomeTable;"
+ );
+ }
+
+ /**
+ * Test series of nested escape sequences.
+ */
+ public void testNestedCallProcMixed() {
+ check(
+ "CALL func1(CALL func2(field1), CALL func3(field2))",
+ "{call func1({call func2(field1)}, {call func3(field2)})}"
+ );
+
+ check(
+ "select CALL func1(CALL func2(field1), CALL func3(field2)) from table;",
+ "select {call func1({call func2(field1)}, {call func3(field2)})} from table;"
+ );
+
+ check(
+ "CALL func1(CALL func2(CALL func3(field1))) CALL func1(CALL func2(field2))",
+ "{call func1({call func2({call func3(field1)})})} {call func1({call func2(field2)})}"
+ );
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidCallProcSequence() {
+ checkFail("{callfunc1()}");
+
+ checkFail("select {call func1(field1, {call func2(field2), field3)} from SomeTable;");
+
+ checkFail("select {call func1(field1, call func2(field2)}, field3)} from SomeTable;");
+ }
+
+ /**
+ * Test escape sequences with additional whitespace characters
+ */
+ public void testCallProcEscapeSequenceWithWhitespaces() throws Exception {
+ check("CALL func1()", "{ call func1()}");
+
+ check("CALL func1()", "{ call func1()}");
+
+ check("CALL func1()", "{ \n call\nfunc1()}");
+
+ checkFail("{ \n func1()}");
+ }
+
/**
* Check parsing logic.
*