Skip to content
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

Merged
merged 12 commits into from
Mar 4, 2023
Merged

reactor:multiple delete executor #482

merged 12 commits into from
Mar 4, 2023

Conversation

liiibpm
Copy link
Contributor

@liiibpm liiibpm commented Feb 19, 2023

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?:


@CLAassistant
Copy link

CLAassistant commented Feb 19, 2023

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2023

Codecov Report

Merging #482 (6d76920) into master (e3060d0) will increase coverage by 0.11%.
The diff coverage is 44.59%.

📣 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     
Impacted Files Coverage Δ
pkg/datasource/sql/exec/at/multi_executor.go 0.00% <0.00%> (ø)
pkg/datasource/sql/exec/at/multi_update_excutor.go 32.35% <ø> (ø)
...kg/datasource/sql/exec/at/multi_delete_executor.go 45.51% <45.51%> (ø)
pkg/datasource/sql/exec/at/base_executor.go 39.13% <0.00%> (+1.18%) ⬆️

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add License header

Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format import header

Copy link
Contributor

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 {
Copy link
Contributor

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

@luky116
Copy link
Contributor

luky116 commented Feb 20, 2023

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Refer to this PR and improve the at_executor.go file
https://github.com/seata/seata-go/pull/481/files#diff-84f163a33322f2f1282a877450c2dbe24769b8caf415962d4724f8fbfd90554a

@@ -0,0 +1,193 @@
package at
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor

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 {
Copy link
Contributor

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]
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

牛蛙

@luky116
Copy link
Contributor

luky116 commented Feb 28, 2023

这里加上这些代码:
image

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Add these codes here:
image

@luky116
Copy link
Contributor

luky116 commented Feb 28, 2023

移除这部分代码,因为multidelete时候,前后镜像是不一样的
image

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Uploading image.png…

@luky116
Copy link
Contributor

luky116 commented Feb 28, 2023

multi_executor文件改动:
image

for _, beforeImage := range beforeImages {
    m.execContext.TxCtx.RoundImages.AppendBeofreImage(beforeImage)
}
for _, afterImage := range afterImages {
    m.execContext.TxCtx.RoundImages.AppendAfterImage(afterImage)
}

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


multi_executor文件改动:
image

for _, beforeImage := range beforeImages {
    m.execContext.TxCtx.RoundImages.AppendBeofreImage(beforeImage)
}
for _, afterImage := range beforeImages {
    m.execContext.TxCtx.RoundImages.AppendAfterImage(afterImage)
}

@luky116 luky116 requested a review from 106umao March 4, 2023 08:50
@luky116 luky116 merged commit f2d7d8a into apache:master Mar 4, 2023
georgehao pushed a commit to georgehao/seata-go that referenced this pull request May 7, 2023
* reactor:multiple delete executor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add undo executor for multi delete sql
6 participants