forked from MyCATApache/Mycat-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request MyCATApache#687 from digdeep126/master
fix当update语句的where中有子查询时无法处理的bug
- Loading branch information
Showing
6 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/io/mycat/sqlengine/MultiRowSQLQueryResultHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.mycat.sqlengine; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
|
||
/** | ||
* 当SQLJob的结果有多行时,利用该处理器进行处理 | ||
* @author [email protected] | ||
*/ | ||
public class MultiRowSQLQueryResultHandler extends OneRawSQLQueryResultHandler{ | ||
private static final Logger LOGGER = LoggerFactory | ||
.getLogger(MultiRowSQLQueryResultHandler.class); | ||
// 获得结果之后,利用该对象进行回调进行通知和处理结果 | ||
private final SQLQueryResultListener<SQLQueryResult<List<Map<String, String>>>> callback; | ||
|
||
private List<Map<String, String>> resultRows = new LinkedList<>(); // 保存结果行 | ||
|
||
public MultiRowSQLQueryResultHandler(String[] fetchCols, | ||
SQLQueryResultListener<SQLQueryResult<List<Map<String, String>>>> callback) { | ||
super(fetchCols, null); | ||
this.callback = callback; | ||
} | ||
|
||
@Override | ||
public boolean onRowData(String dataNode, byte[] rowData) { | ||
super.onRowData(dataNode, rowData); | ||
resultRows.add(getResult()); | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public void finished(String dataNode, boolean failed) { | ||
SQLQueryResult<List<Map<String, String>>> queryResult = | ||
new SQLQueryResult<List<Map<String, String>>>(this.resultRows, !failed); | ||
if(callback != null) | ||
this.callback.onResult(queryResult); // callback 是构造函数传进来,在得到结果是进行回调 | ||
else | ||
LOGGER.warn(" callback is null "); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters