Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
luky116 authored Dec 7, 2024
2 parents b31926c + 406b8ba commit 71c56a7
Show file tree
Hide file tree
Showing 12 changed files with 1,974 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue-robot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: tomsun28/issues-translate-action@v2.6
- uses: usthe/issues-translate-action@v2.7
with:
# it is not necessary to decide whether you need to modify the issue header content
IS_MODIFY_TITLE: false
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
dubbo.apache.org/dubbo-go/v3 v3.0.4
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/apache/dubbo-getty v1.4.10
github.com/apache/dubbo-getty v1.5.0
github.com/arana-db/parser v0.2.5
github.com/bluele/gcache v0.0.2
github.com/dsnet/compress v0.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ github.com/alibaba/sentinel-golang v1.0.4/go.mod h1:Lag5rIYyJiPOylK8Kku2P+a23gdK
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/dubbo-getty v1.4.9-0.20221022181821-4dc6252ce98c/go.mod h1:6qmrqBSPGs3B35zwEuGhEYNVsx1nfGT/xzV2yOt2amM=
github.com/apache/dubbo-getty v1.4.10 h1:ZmkpHJa/qgS0evX2tTNqNCz6rClI/9Wwp7ctyMml82w=
github.com/apache/dubbo-getty v1.4.10/go.mod h1:V64WqLIxksEgNu5aBJBOxNIvpOZyfUJ7J/DXBlKSUoA=
github.com/apache/dubbo-getty v1.5.0 h1:40RMjEoSfTuoG5EwKbGgfhjd7m6Zc7qBfOFgQv1jHCI=
github.com/apache/dubbo-getty v1.5.0/go.mod h1:V64WqLIxksEgNu5aBJBOxNIvpOZyfUJ7J/DXBlKSUoA=
github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
github.com/apache/dubbo-go-hessian2 v1.11.4 h1:u8spEogpaZ82/k3bmv1PLYnha/wiwsIme15FuZZgkiI=
Expand Down
4 changes: 2 additions & 2 deletions pkg/datasource/sql/undo/base/undo.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (m *BaseUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, con
}

parseContext := make(map[string]string, 0)
parseContext[serializerKey] = "json"
parseContext[serializerKey] = undo.UndoConfig.LogSerialization
parseContext[compressorTypeKey] = undo.UndoConfig.CompressConfig.Type
undoLogContent := m.encodeUndoLogCtx(parseContext)
rollbackInfo, err := m.serializeBranchUndoLog(&branchUndoLog, parseContext[serializerKey])
Expand Down Expand Up @@ -377,7 +377,7 @@ func (m *BaseUndoLogManager) Undo(ctx context.Context, dbType types.DBType, xid
func (m *BaseUndoLogManager) insertUndoLogWithGlobalFinished(ctx context.Context, xid string, branchID uint64, conn *sql.Conn) error {
// todo use config to replace
parseContext := make(map[string]string, 0)
parseContext[serializerKey] = "json"
parseContext[serializerKey] = undo.UndoConfig.LogSerialization
parseContext[compressorTypeKey] = undo.UndoConfig.CompressConfig.Type
undoLogContent := m.encodeUndoLogCtx(parseContext)

Expand Down
4 changes: 4 additions & 0 deletions pkg/datasource/sql/undo/builder/basic_undo_log_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ func (b *BasicUndoLogBuilder) traversalArgs(node ast.Node, argsIndex *[]int32) {
b.traversalArgs(exprs[i], argsIndex)
}
break
case *ast.ParenthesesExpr:
expr := node.(*ast.ParenthesesExpr)
b.traversalArgs(expr.Expr, argsIndex)
break
case *test_driver.ParamMarkerExpr:
*argsIndex = append(*argsIndex, int32(node.(*test_driver.ParamMarkerExpr).Order))
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ import (
)

func TestBuildSelectSQLByUpdate(t *testing.T) {
t.SkipNow()
//t.SkipNow()
var (
builder = MySQLUpdateUndoLogBuilder{}
)

stub := gomonkey.ApplyMethod(reflect.TypeOf(datasource.GetTableCache(types.DBTypeMySQL)), "GetTableMeta", func(_ *mysql.TableMetaCache, ctx context.Context, dbName, tableName string, conn driver.Conn) (*types.TableMeta, error) {
datasource.RegisterTableCache(types.DBTypeMySQL, &mysql.TableMetaCache{})

stub := gomonkey.ApplyMethod(reflect.TypeOf(datasource.GetTableCache(types.DBTypeMySQL)), "GetTableMeta", func(_ *mysql.TableMetaCache, ctx context.Context, dbName, tableName string) (*types.TableMeta, error) {
return &types.TableMeta{
Indexs: map[string]types.IndexMeta{
"id": {
Expand Down Expand Up @@ -77,6 +79,12 @@ func TestBuildSelectSQLByUpdate(t *testing.T) {
expectQuery: "SELECT SQL_NO_CACHE name,age,id FROM t_user WHERE id=? AND name=_UTF8MB4Jack AND age BETWEEN ? AND ? FOR UPDATE",
expectQueryArgs: []driver.Value{100, 18, 28},
},
{
sourceQuery: "update t_user set name = ?, age = ? where (id = ? or name = 'Jack') and age between ? and ?",
sourceQueryArgs: []driver.Value{"Jack", 1, 100, 18, 28},
expectQuery: "SELECT SQL_NO_CACHE name,age,id FROM t_user WHERE (id=? OR name=_UTF8MB4Jack) AND age BETWEEN ? AND ? FOR UPDATE",
expectQueryArgs: []driver.Value{100, 18, 28},
},
{
sourceQuery: "update t_user set name = ?, age = ? where id = ? and name = 'Jack' and age in (?,?)",
sourceQueryArgs: []driver.Value{"Jack", 1, 100, 18, 28},
Expand Down
Loading

0 comments on commit 71c56a7

Please sign in to comment.