Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ public enum OdbcEscapeType {
GUID("guid", true, false),

/** LIKE clause. */
LIKE("\'", false, true);
LIKE("\'", false, true),

/** Stored procedure call */
CALL("call", true, false);

/** Values in convenient order. */
private static final OdbcEscapeType[] VALS = new 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.
CALL, //TODO: ignite-3743: choose convenient place in array
OUTER_JOIN, // Joins are less frequent,
LIKE, TIME, GUID // LIKE, TIME and GUID are even less frequent.
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ private static String parseStandardExpression(String text, int startPos, int len
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() + ']');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,131 @@ public void testNonEscapeSequence() throws Exception {
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.
*
Expand Down