[fix](variables) Fix bug that execute showVariablesStmt with where expression return empty resultset (#8094)

This Bug is introduced by PR #7936 , which change key type of connectionMap from Long to Integer,
which cause connectionMap could not find connectContext by connectionId
This commit is contained in:
caiconghui
2022-02-19 11:58:17 +08:00
committed by GitHub
parent 9cb9781d86
commit 9df5b2dfdc
8 changed files with 18 additions and 18 deletions

View File

@ -3506,15 +3506,15 @@ restore_stmt ::=
kill_stmt ::=
KW_KILL INTEGER_LITERAL:value
{:
RESULT = new KillStmt(true, value.longValue());
RESULT = new KillStmt(true, value.intValue());
:}
| KW_KILL KW_CONNECTION INTEGER_LITERAL:value
{:
RESULT = new KillStmt(true, value.longValue());
RESULT = new KillStmt(true, value.intValue());
:}
| KW_KILL KW_QUERY INTEGER_LITERAL:value
{:
RESULT = new KillStmt(false, value.longValue());
RESULT = new KillStmt(false, value.intValue());
:}
;

View File

@ -24,9 +24,9 @@ package org.apache.doris.analysis;
*/
public class KillStmt extends StatementBase {
private final boolean isConnectionKill;
private final long connectionId;
private final int connectionId;
public KillStmt(boolean isConnectionKill, long connectionId) {
public KillStmt(boolean isConnectionKill, int connectionId) {
this.isConnectionKill = isConnectionKill;
this.connectionId = connectionId;
}
@ -35,7 +35,7 @@ public class KillStmt extends StatementBase {
return isConnectionKill;
}
public long getConnectionId() {
public int getConnectionId() {
return connectionId;
}

View File

@ -47,7 +47,7 @@ public class ConnectionAction extends RestBaseAction {
sendResult(request, response, HttpResponseStatus.BAD_REQUEST);
return;
}
long connectionId = Long.valueOf(connStr.trim());
int connectionId = Integer.valueOf(connStr.trim());
ConnectContext context = ExecuteEnv.getInstance().getScheduler().getContext(connectionId);
if (context == null || context.queryId() == null) {
response.getContent().append("connection id " + connectionId + " not found.");

View File

@ -65,9 +65,9 @@ public class ConnectionAction extends RestBaseController {
return ResponseEntityBuilder.badRequest("Missing connection_id");
}
long connectionId = -1;
int connectionId = -1;
try {
connectionId = Long.valueOf(connStr.trim());
connectionId = Integer.valueOf(connStr.trim());
} catch (NumberFormatException e) {
return ResponseEntityBuilder.badRequest("Invalid connection id: " + e.getMessage());
}

View File

@ -128,7 +128,7 @@ public class ConnectScheduler {
}
}
public ConnectContext getContext(long connectionId) {
public ConnectContext getContext(int connectionId) {
return connectionMap.get(connectionId);
}

View File

@ -728,7 +728,7 @@ public class StmtExecutor implements ProfileWriter {
// Handle kill statement.
private void handleKill() throws DdlException {
KillStmt killStmt = (KillStmt) parsedStmt;
long id = killStmt.getConnectionId();
int id = killStmt.getConnectionId();
ConnectContext killCtx = context.getConnectScheduler().getContext(id);
if (killCtx == null) {
ErrorReport.reportDdlException(ErrorCode.ERR_NO_SUCH_THREAD, id);

View File

@ -426,7 +426,7 @@ public class FrontendServiceImpl implements FrontendService.Iface {
Map<String, String> map = Maps.newHashMap();
result.setVariables(map);
// Find connect
ConnectContext ctx = exeEnv.getScheduler().getContext(params.getThreadId());
ConnectContext ctx = exeEnv.getScheduler().getContext((int) params.getThreadId());
if (ctx == null) {
return result;
}

View File

@ -342,7 +342,7 @@ public class StmtExecutorTest {
new Expectations(scheduler) {
{
// suicide
scheduler.getContext(1L);
scheduler.getContext(1);
result = ctx;
}
};
@ -399,7 +399,7 @@ public class StmtExecutorTest {
new Expectations(scheduler) {
{
// suicide
scheduler.getContext(1L);
scheduler.getContext(1);
result = killCtx;
}
};
@ -420,7 +420,7 @@ public class StmtExecutorTest {
killStmt.getConnectionId();
minTimes = 0;
result = 1L;
result = 1;
killStmt.isConnectionKill();
minTimes = 0;
@ -455,7 +455,7 @@ public class StmtExecutorTest {
new Expectations(scheduler) {
{
// suicide
scheduler.getContext(1L);
scheduler.getContext(1);
result = killCtx;
}
};
@ -475,7 +475,7 @@ public class StmtExecutorTest {
killStmt.getConnectionId();
minTimes = 0;
result = 1L;
result = 1;
killStmt.getRedirectStatus();
minTimes = 0;
@ -490,7 +490,7 @@ public class StmtExecutorTest {
new Expectations(scheduler) {
{
scheduler.getContext(1L);
scheduler.getContext(1);
result = null;
}
};