Skip to content

Support Update join #761

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Support Update join #761

wants to merge 19 commits into from

Conversation

lxfeng1997
Copy link
Contributor

What this PR does:
This pr will support update join

Which issue(s) this PR fixes:

Fixes #703

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Copy link

@@ -244,6 +244,10 @@ func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e
)
}

func (c *Conn) GetDbVersion() string {
return c.res.GetDbVersion()
Copy link
Contributor

@luky116 luky116 Feb 15, 2025

Choose a reason for hiding this comment

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

这个有需要支持吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我认为是需要支持的,不过或许可以提另外的issues分开去做?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -244,6 +244,10 @@ func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e
)
}

func (c *Conn) GetDbVersion() string {
return c.res.GetDbVersion()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe 'c.res' was nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

另一个issue 进行开发


// NewUpdateJoinExecutor get executor
func NewUpdateJoinExecutor(parserCtx *types.ParseContext, execContent *types.ExecContext, hooks []exec.SQLHook) executor {
minimumVersion, _ := util.ConvertDbVersion("5.7.5")
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using the magic value '5.7.5'.

Copy link
Contributor

Choose a reason for hiding this comment

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

改为配置或是常量的方式定义 version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ForestLH
Copy link
Contributor

待添加新的issue,读取数据库的元数据,查询版本

@Code-Fight
Copy link
Contributor

待添加新的issue,读取数据库的元数据,查询版本

Merged

@luky116 luky116 requested a review from Copilot May 19, 2025 00:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for UPDATE … JOIN statements by introducing a dedicated executor, extending argument traversal, select-field building, and covering the logic with new tests.

  • Introduce updateJoinExecutor to build before-/after-image SELECTs for joined updates
  • Route NewUpdateExecutor to use the join executor when a JOIN is present
  • Extend baseExecutor with join-aware argument traversal, select-field logic, and a common rowsPrepare helper
  • Add comprehensive unit tests in update_join_executor_test.go

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/datasource/sql/exec/at/update_join_executor_test.go New tests for building before-image SQL in UPDATE … JOIN cases
pkg/datasource/sql/exec/at/update_join_executor.go Implementation of updateJoinExecutor and SQL builders
pkg/datasource/sql/exec/at/update_executor.go Dispatches to join executor when a JOIN clause is detected
pkg/datasource/sql/exec/at/base_executor.go Added join argument traversal, select-field builder, and rowsPrepare

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[at] support update join SQL
4 participants