-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reactor:multiple delete executor #482
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #482 +/- ##
==========================================
+ Coverage 38.72% 38.84% +0.11%
==========================================
Files 149 150 +1
Lines 9984 10131 +147
==========================================
+ Hits 3866 3935 +69
- Misses 5798 5875 +77
- Partials 320 321 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -0,0 +1,193 @@ | |||
package at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add License header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接执行 sh goimport.sh脚本就行
"fmt" | ||
"github.com/arana-db/parser/ast" | ||
"github.com/arana-db/parser/format" | ||
"github.com/seata/seata-go/pkg/datasource/sql/datasource" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format import header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这格式还是不对
} | ||
|
||
//NewMultiDeleteExecutor get multiDelete executor | ||
func NewMultiDeleteExecutor(parserCtx *types.ParseContext, execContent *types.ExecContext, hooks []exec.SQLHook) executor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move NewMultiDeleteExecutor to type multiDeleteExecutor struct
next line
Refer to this PR and improve the at_executor.go file |
@@ -0,0 +1,193 @@ | |||
package at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接执行 sh goimport.sh脚本就行
return &multiDeleteExecutor{parserCtx: parserCtx, execContext: execContent, baseExecutor: baseExecutor{hooks: hooks}} | ||
} | ||
|
||
func (m *multiDeleteExecutor) BeforeImage(ctx context.Context) ([]*types.RecordImage, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
首字母小写:beforeImage
|
||
} | ||
|
||
func (m *multiDeleteExecutor) AfterImage(ctx context.Context) ([]*types.RecordImage, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
首字母小写:afterImage
return nil, nil | ||
} | ||
|
||
func (m *multiDeleteExecutor) buildBeforeImageSQL(multiQuery []string, args []driver.NamedValue) ([]string, []driver.NamedValue, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiQuery 参数可以从m.execContext.Query拿到,args参数可以从m.execContext.NamedValues拿到,这里可以不传参数进来
lockKey := m.buildLockKey(image, *metaData) | ||
m.execContext.TxCtx.LockKeys[lockKey] = struct{}{} | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else 逻辑 改为 if !ok{} ,放在79行前面
} | ||
var ( | ||
rowsi driver.Rows | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete 空行
log.Errorf("target conn should been driver.QueryerContext or driver.Queryer") | ||
return nil, fmt.Errorf("invalid conn") | ||
} | ||
if ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ok的条件可以删了,因为上面已经退出了
} | ||
tableName = p.DeleteStmt.TableRefs.TableRefs.Left.(*ast.TableSource).Source.(*ast.TableName).Name.O | ||
|
||
v, ok := tables[tableName] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
151~156行代码改为如下:
ps, err := parser.DoParser(m.execContext.Query)
if err != nil {
return nil, nil, err
}
for _, p = range ps.MultiStmt {
tableName = p.DeleteStmt.TableRefs.TableRefs.Left.(*ast.TableSource).Source.(*ast.TableName).Name.O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
牛蛙
for _, beforeImage := range beforeImages {
m.execContext.TxCtx.RoundImages.AppendBeofreImage(beforeImage)
}
for _, afterImage := range beforeImages {
m.execContext.TxCtx.RoundImages.AppendAfterImage(afterImage)
} |
* reactor:multiple delete executor
What this PR does:
Which issue(s) this PR fixes:
Fixes #475
Special notes for your reviewer:
Does this PR introduce a user-facing change?: