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

*: remove CorrelatedCol.HashCode to avoid potential bug #45034

Merged
merged 5 commits into from
Jun 30, 2023

Conversation

guo-shaoge
Copy link
Collaborator

@guo-shaoge guo-shaoge commented Jun 28, 2023

What problem does this PR solve?

Issue Number: close #45033

Problem Summary: Introduced by this pr: #44782 . #44782 add CorrelatedColumn.HashCode, which will update Column.hashcode.

  1. In rule_decorrelate, extract Column of CorrelatedColumn directly, check https://github.com/pingcap/tidb/blob/master/planner/core/rule_decorrelate.go#L215C44-L215C44 and https://github.com/pingcap/tidb/blob/master/expression/column.go#L177. The hashcode of Column has changed(it's the hash code of CorrelatedColumn instead the original Column)
  2. In rule_eliminate_projection, planner will try to replace CondExpr in HashJoin by the output of Projection, here we use hashcode to decide whether to repace or not. But the hash code of CondExpr of HashJoin has changed, so the repacement didn't happen.
  3. So the Projection is removed, but the CondExpr of HashJoin still use the removed Projection's output.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-triage-completed labels Jun 28, 2023
@guo-shaoge guo-shaoge requested review from AilinKid and wshwsh12 June 28, 2023 12:02
Signed-off-by: guo-shaoge <[email protected]>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 28, 2023
@hawkingrei
Copy link
Member

/retest

1 similar comment
@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/test all

Signed-off-by: guo-shaoge <[email protected]>
@hawkingrei
Copy link
Member

/test all

Signed-off-by: guo-shaoge <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 29, 2023
@hawkingrei
Copy link
Member

/retest

5 similar comments
@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/retest

@guo-shaoge
Copy link
Collaborator Author

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, wshwsh12

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the lgtm label Jun 30, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 30, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 30, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-06-28 16:11:49.098331343 +0000 UTC m=+810474.499581778: ☑️ agreed by wshwsh12.
  • 2023-06-30 03:37:26.077654792 +0000 UTC m=+56729.452232645: ☑️ agreed by AilinKid.

@hawkingrei
Copy link
Member

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complicated CTE query got cannot find column in schema error
4 participants