mirror of
https://github.com/actiontech/dble.git
synced 2026-05-04 05:20:48 -05:00
set syntax make conn dirty #321
This commit is contained in:
@@ -49,9 +49,9 @@ public final class SelectHandler {
|
||||
break;
|
||||
default:
|
||||
if (isSupportSelect(stmt)) {
|
||||
Iterator<PhysicalDBPool> iter = DbleServer.getInstance().getConfig().getDataHosts().values().iterator();
|
||||
if (iter.hasNext()) {
|
||||
PhysicalDBPool pool = iter.next();
|
||||
Iterator<PhysicalDBPool> iterator = DbleServer.getInstance().getConfig().getDataHosts().values().iterator();
|
||||
if (iterator.hasNext()) {
|
||||
PhysicalDBPool pool = iterator.next();
|
||||
final PhysicalDatasource source = pool.getSource();
|
||||
TransformSQLJob sqlJob = new TransformSQLJob(stmt, pool.getSchemas()[0], source, c);
|
||||
sqlJob.run();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package com.actiontech.dble.server.handler;
|
||||
|
||||
import com.actiontech.dble.DbleServer;
|
||||
import com.actiontech.dble.backend.datasource.PhysicalDBPool;
|
||||
import com.actiontech.dble.backend.mysql.CharsetUtil;
|
||||
import com.actiontech.dble.config.ErrorCode;
|
||||
import com.actiontech.dble.config.Isolations;
|
||||
@@ -31,6 +32,7 @@ import com.alibaba.druid.sql.parser.SQLStatementParser;
|
||||
|
||||
import java.sql.SQLSyntaxErrorException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -199,8 +201,14 @@ public final class SetHandler {
|
||||
private static void setStmtCallback(String multiStmt, ServerConnection c, List<Pair<KeyType, Pair<String, String>>> contextTask) {
|
||||
c.setContextTask(contextTask);
|
||||
OneRawSQLQueryResultHandler resultHandler = new OneRawSQLQueryResultHandler(new String[0], new SetCallBack(c));
|
||||
SetTestJob sqlJob = new SetTestJob(multiStmt, resultHandler, c);
|
||||
sqlJob.run();
|
||||
Iterator<PhysicalDBPool> iterator = DbleServer.getInstance().getConfig().getDataHosts().values().iterator();
|
||||
if (iterator.hasNext()) {
|
||||
PhysicalDBPool pool = iterator.next();
|
||||
SetTestJob sqlJob = new SetTestJob(multiStmt, pool.getSchemas()[0], resultHandler, c);
|
||||
sqlJob.run();
|
||||
} else {
|
||||
c.writeErrMessage(ErrorCode.ER_YES, "no valid data host");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean handleVariableInMultiStmt(SQLAssignItem assignItem, ServerConnection c, List<Pair<KeyType, Pair<String, String>>> contextTask) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.actiontech.dble.net.mysql.FieldPacket;
|
||||
import com.actiontech.dble.net.mysql.ResetConnectionPacket;
|
||||
import com.actiontech.dble.net.mysql.RowDataPacket;
|
||||
import com.actiontech.dble.server.ServerConnection;
|
||||
import com.actiontech.dble.server.util.SchemaUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -27,18 +26,14 @@ public class SetTestJob implements ResponseHandler, Runnable {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(SQLJob.class);
|
||||
|
||||
private final String sql;
|
||||
private final String dataNodeOrDatabase;
|
||||
private final String databaseName;
|
||||
private final SQLJobHandler jobHandler;
|
||||
private final ServerConnection sc;
|
||||
|
||||
public SetTestJob(String sql, SQLJobHandler jobHandler, ServerConnection sc) {
|
||||
public SetTestJob(String sql, String databaseName, SQLJobHandler jobHandler, ServerConnection sc) {
|
||||
super();
|
||||
this.sql = sql;
|
||||
String schema = sc.getSchema();
|
||||
if (schema == null) {
|
||||
schema = SchemaUtil.getRandomDb();
|
||||
}
|
||||
this.dataNodeOrDatabase = schema;
|
||||
this.databaseName = databaseName;
|
||||
this.jobHandler = jobHandler;
|
||||
this.sc = sc;
|
||||
}
|
||||
@@ -47,7 +42,7 @@ public class SetTestJob implements ResponseHandler, Runnable {
|
||||
try {
|
||||
Map<String, PhysicalDBPool> dataHosts = DbleServer.getInstance().getConfig().getDataHosts();
|
||||
for (PhysicalDBPool dn : dataHosts.values()) {
|
||||
dn.getSource().getConnection(dataNodeOrDatabase, true, this, null);
|
||||
dn.getSource().getConnection(databaseName, true, this, null);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -67,7 +62,7 @@ public class SetTestJob implements ResponseHandler, Runnable {
|
||||
}
|
||||
|
||||
private void doFinished(boolean failed) {
|
||||
jobHandler.finished(dataNodeOrDatabase, failed);
|
||||
jobHandler.finished(databaseName, failed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,7 +122,7 @@ public class SetTestJob implements ResponseHandler, Runnable {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SQLJob [dataNodeOrDatabase=" +
|
||||
dataNodeOrDatabase + ",sql=" + sql + ", jobHandler=" +
|
||||
databaseName + ",sql=" + sql + ", jobHandler=" +
|
||||
jobHandler + "]";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user