Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix_placeholder_in_joincondition_notco…
Browse files Browse the repository at this point in the history
…nsidered
  • Loading branch information
funky-eyes committed Nov 17, 2022
2 parents 27ad395 + acf880a commit 284dc51
Show file tree
Hide file tree
Showing 13 changed files with 799 additions and 4 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -49,3 +49,38 @@ jobs:
else
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
fi
arm64-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
springboot: [
2.7.2 -Dspring-framework.version=5.3.22,
2.6.10 -Dspring-framework.version=5.3.22,
2.5.14 -Dspring-framework.version=5.3.20,
2.4.13 -Dspring-framework.version=5.3.13,
2.3.12.RELEASE -Dspring-framework.version=5.2.15.RELEASE,
2.2.13.RELEASE -Dspring-framework.version=5.2.12.RELEASE,
#2.1.18.RELEASE,
#2.0.9.RELEASE,
#1.5.22.RELEASE,
#1.4.7.RELEASE,
#1.3.8.RELEASE,
#1.2.8.RELEASE,
#1.1.12.RELEASE,
#1.0.2.RELEASE
]
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
- name: install
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
arm64v8/ubuntu:20.04 \
bash -exc 'apt-get update -y && \
apt-get install maven -y'
- name: test-arm64
run: |
./mvnw -T 4C clean test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
4 changes: 3 additions & 1 deletion changes/en-us/develop.md
Expand Up @@ -36,6 +36,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#5050](https://github.com/seata/seata/pull/5050)] fix global session is not change to Committed in saga mode
- [[#5052](https://github.com/seata/seata/pull/5052)] fix update join condition placeholder param error
- [[#5031](https://github.com/seata/seata/pull/5031)] fix mysql InsertOnDuplicateUpdate should not use null index value as image sql query condition
- [[#5075](https://github.com/seata/seata/pull/5075)] fix InsertOnDuplicateUpdateExecutor could not intercept the sql which has no primary and unique key


### optimize:
Expand Down Expand Up @@ -66,7 +67,7 @@ Add changes here for all PR submitted to the develop branch.
- [[#4995](https://github.com/seata/seata/pull/4995)] fix mysql InsertOnDuplicateUpdate duplicate pk condition in after image query sql
- [[#5047](https://github.com/seata/seata/pull/5047)] remove useless code
- [[#5051](https://github.com/seata/seata/pull/5051)] undo log dirty throw BranchRollbackFailed_Unretriable

- [[#5075](https://github.com/seata/seata/pull/5075)] intercept the InsertOnDuplicateUpdate statement which has no primary key and unique index value

### test:
- [[#4794](https://github.com/seata/seata/pull/4794)] try to fix the test `DataSourceProxyTest.getResourceIdTest()`
Expand Down Expand Up @@ -96,5 +97,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [neillee95](https://github.com/neillee95)
- [crazy-sheep](https://github.com/crazy-sheep)
- [zhangzq7](https://github.com/zhangzq7)
- [l81893521](https://github.com/l81893521)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
6 changes: 6 additions & 0 deletions changes/zh-cn/develop.md
Expand Up @@ -38,6 +38,7 @@
- [[#5050](https://github.com/seata/seata/pull/5050)] 修复Saga模式下全局状态未正确更改成Committed
- [[#5052](https://github.com/seata/seata/pull/5052)] 修复update join条件中占位符参数问题
- [[#5031](https://github.com/seata/seata/pull/5031)] 修复InsertOnDuplicateUpdate中不应该使用null值索引作为查询条件
- [[#5075](https://github.com/seata/seata/pull/5075)] 修复InsertOnDuplicateUpdate无法拦截无主键和唯一索引的SQL

### optimize:
- [[#4774](https://github.com/seata/seata/pull/4774)] 优化 seataio/seata-server 镜像中的 mysql8 依赖
Expand Down Expand Up @@ -66,8 +67,10 @@
- [[#4995](https://github.com/seata/seata/pull/4995)] 修复mysql InsertOnDuplicateUpdate后置镜像查询SQL中重复的主键查询条件
- [[#5047](https://github.com/seata/seata/pull/5047)] 移除无用代码
- [[#5051](https://github.com/seata/seata/pull/5051)] 回滚时undolog产生脏写需要抛出不再重试(BranchRollbackFailed_Unretriable)的异常
- [[#5075](https://github.com/seata/seata/pull/5075)] 拦截没有主键及唯一索引值的insert on duplicate update语句

### test:
- [[#4411](https://github.com/seata/seata/pull/4411)] 测试Oracle数据库AT模式下类型支持
- [[#4794](https://github.com/seata/seata/pull/4794)] 重构代码,尝试修复单元测试 `DataSourceProxyTest.getResourceIdTest()`


Expand All @@ -82,6 +85,8 @@
- [AlexStocks](https://github.com/AlexStocks)
- [liujunlin5168](https://github.com/liujunlin5168)
- [pengten](https://github.com/pengten)
- [YSF-A](https://github.com/YSF-A)
- [doubleDimple](https://github.com/doubleDimple)
- [liuqiufeng](https://github.com/liuqiufeng)
- [yujianfei1986](https://github.com/yujianfei1986)
- [Bughue](https://github.com/Bughue)
Expand All @@ -95,5 +100,6 @@
- [neillee95](https://github.com/neillee95)
- [crazy-sheep](https://github.com/crazy-sheep)
- [zhangzq7](https://github.com/zhangzq7)
- [l81893521](https://github.com/l81893521)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Expand Up @@ -268,6 +268,9 @@ public TableRecords beforeImage() throws SQLException {
* @throws SQLException then execute fail
*/
public TableRecords buildTableRecords2(TableMeta tableMeta, String selectSQL, ArrayList<List<Object>> paramAppenderList, List<Object> primaryKeys) throws SQLException {
if (CollectionUtils.isEmpty(paramAppenderList)) {
throw new NotSupportYetException("the SQL statement has no primary key or unique index value, it will not hit any row data.recommend to convert to a normal insert statement");
}
ResultSet rs = null;
try (PreparedStatement ps = statementProxy.getConnection()
.prepareStatement(primaryKeys.isEmpty() ? selectSQL + " FOR UPDATE" : selectSQL)) {
Expand Down Expand Up @@ -312,7 +315,7 @@ public String buildImageSQL(TableMeta tableMeta) {
int finalI = i;
List<Object> paramAppenderTempList = new ArrayList<>();
tableMeta.getAllIndexes().forEach((k, v) -> {
if (!v.isNonUnique() && isIndexValueNotNull(v,imageParameterMap,finalI)) {
if (!v.isNonUnique() && isIndexValueNotNull(v, imageParameterMap, finalI)) {
boolean columnIsNull = true;
List<String> uniqueList = new ArrayList<>();
for (ColumnMeta m : v.getValues()) {
Expand Down Expand Up @@ -343,7 +346,9 @@ public String buildImageSQL(TableMeta tableMeta) {
}
}
});
paramAppenderList.add(paramAppenderTempList);
if (CollectionUtils.isNotEmpty(paramAppenderTempList)) {
paramAppenderList.add(paramAppenderTempList);
}
}
StringJoiner selectSQLJoin = new StringJoiner(", ", prefix, suffix.toString());
return selectSQLJoin.toString();
Expand Down Expand Up @@ -399,7 +404,7 @@ public Map<String, ArrayList<Object>> buildImageParameters(SQLInsertRecognizer r
return imageParameterMap;
}

private boolean isIndexValueNotNull(IndexMeta indexMeta, Map<String, ArrayList<Object>> imageParameterMap,int rowIndex) {
private boolean isIndexValueNotNull(IndexMeta indexMeta, Map<String, ArrayList<Object>> imageParameterMap, int rowIndex) {
for (ColumnMeta columnMeta : indexMeta.getValues()) {
String columnName = columnMeta.getColumnName();
List<Object> imageParameters = imageParameterMap.get(columnName);
Expand Down
Empty file.
Expand Up @@ -25,6 +25,7 @@
import java.util.Collections;

import com.google.common.collect.Lists;
import io.seata.common.exception.NotSupportYetException;
import io.seata.rm.datasource.ConnectionProxy;
import io.seata.rm.datasource.PreparedStatementProxy;
import io.seata.rm.datasource.StatementProxy;
Expand Down Expand Up @@ -152,6 +153,20 @@ public void testBeforeImage(){
throwables.printStackTrace();
}
}
@Test
public void testBeforeImageWithNoUnique(){
mockImageParameterMap_contain_constant();
List<List<Object>> insertRows = new ArrayList<>();
insertRows.add(Arrays.asList("?,?,?,userStatus1"));
insertRows.add(Arrays.asList("?,?,?,userStatus2"));
when(sqlInsertRecognizer.getInsertRows(pkIndexMap.values())).thenReturn(insertRows);
mockInsertColumns();
mockAllIndexes();
doReturn(tableMeta).when(insertOrUpdateExecutor).getTableMeta();
Assertions.assertThrows(NotSupportYetException.class, () -> {
insertOrUpdateExecutor.beforeImage();
});
}

private void mockAllIndexes(){
Map<String, IndexMeta> allIndex = new HashMap<>();
Expand Down

0 comments on commit 284dc51

Please sign in to comment.