[NO ISSUE][*DB][MISC] Avoid appending trailing ; on statements ending with a ;
Change-Id: Iae6db76195ad834f01c8e35fc8a30d3b7148764c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10883
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Till Westmann <tillw@apache.org>
Contrib: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
index 5153ebb..a043050 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/QueryServiceServlet.java
@@ -280,10 +280,12 @@
final ResultProperties resultProperties = new ResultProperties(delivery, param.getMaxResultReads());
buildResponseHeaders(requestRef, sessionOutput, param, responsePrinter, delivery);
responsePrinter.printHeaders();
- validateStatement(param.getStatement());
- String statementsText = param.getStatement() + ";";
+ String statement = param.getStatement();
+ statement = statement == null || (!statement.isEmpty() && statement.charAt(statement.length() - 1) == ';')
+ ? statement : (statement + ";");
+ validateStatement(statement);
if (param.isParseOnly()) {
- ResultUtil.ParseOnlyResult parseOnlyResult = parseStatement(statementsText);
+ ResultUtil.ParseOnlyResult parseOnlyResult = parseStatement(statement);
setAccessControlHeaders(request, response);
executionState.setStatus(ResultStatus.SUCCESS, HttpResponseStatus.OK);
response.setStatus(executionState.getHttpStatus());
@@ -296,9 +298,9 @@
IStatementExecutor.StatementProperties statementProperties =
new IStatementExecutor.StatementProperties();
response.setStatus(HttpResponseStatus.OK);
- executeStatement(request, requestRef, statementsText, sessionOutput, resultProperties,
- statementProperties, stats, param, executionState, param.getOptionalParams(), statementParams,
- responsePrinter, warnings);
+ executeStatement(request, requestRef, statement, sessionOutput, resultProperties, statementProperties,
+ stats, param, executionState, param.getOptionalParams(), statementParams, responsePrinter,
+ warnings);
executionState.setStatus(ResultStatus.SUCCESS, HttpResponseStatus.OK);
}
errorCount = 0;