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

planner: fix insert with select the same table result no error #issue 31363 #33565

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

Conversation

fanrenhoo
Copy link
Contributor

Signed-off-by: fanrenhoo [email protected]

What problem does this PR solve?

Issue Number: close #31363

Problem Summary: insert into with select query on a same table no error return, not compatible with MySQL

What is changed and how it works?

Added in the parser in InsertStmt with the logic, if has insert stmt has subquery select stmt, check to make sure select with different table or use as alias to a different name

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    mysql> drop table if exists t1;
    mysql> CREATE TABLE t1 (x int);
    mysql> INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));ERROR 1093 (HY000): You can't specify target table 't1' for update in FROM clause

mysql> INSERT INTO t1 (x) VALUES ((SELECT x FROM t1 as t));
Query OK, 1 row affected (0.00 sec)

  • No code

Side effects
no

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

Documentation
no

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

Release note

Make the insert into with select on a same table result error as MySQL does, and if use "as alias" to different name so will be OK. this fix the issue #31363

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 29, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • xhebox
  • xuyifangreeneyes

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-5.0 needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-6.0 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 29, 2022
@fanrenhoo
Copy link
Contributor Author

/cc @xhebox

@ti-chi-bot ti-chi-bot requested a review from xhebox March 29, 2022 13:06
@fanrenhoo fanrenhoo force-pushed the insertselectsametable branch 2 times, most recently from 3ac5d37 to f59d947 Compare March 29, 2022 15:10
@sre-bot
Copy link
Contributor

sre-bot commented Mar 29, 2022

@xhebox
Copy link
Contributor

xhebox commented Mar 30, 2022

/cc @winoros

@xhebox
Copy link
Contributor

xhebox commented Mar 30, 2022

BTW, we don't cherry-pick minor issue. I am not sure about the fix, it looks like a fix in preprocessor will make more sense.

@xhebox
Copy link
Contributor

xhebox commented Feb 3, 2023

/test all

@ti-chi-bot
Copy link
Member

@fanrenhoo: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@xhebox
Copy link
Contributor

xhebox commented Feb 3, 2023

/hold

unit-test failed.

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 3, 2023
@xhebox
Copy link
Contributor

xhebox commented Mar 16, 2023

/test all

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xhebox, xuyifangreeneyes

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:
  • OWNERS [xhebox,xuyifangreeneyes]

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 approved label Jul 10, 2023
@xhebox
Copy link
Contributor

xhebox commented Jul 10, 2023

/test all

@tiprow
Copy link

tiprow bot commented Jul 10, 2023

@xhebox: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test all

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Jul 10, 2023
@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Jul 10, 2023
@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Jul 10, 2023
Signed-off-by: xhe <[email protected]>
@xhebox
Copy link
Contributor

xhebox commented Jul 10, 2023

/test all

@tiprow
Copy link

tiprow bot commented Jul 10, 2023

@xhebox: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test all

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Jul 10, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jul 10, 2023

@fanrenhoo: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/check_dev_2 33ca045 link true /test check-dev2
idc-jenkins-ci-tidb/unit-test 33ca045 link true /test unit-test
idc-jenkins-ci-tidb/build 7f2bc97 link true /test build

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Jul 10, 2023
Signed-off-by: xhe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-cherry-pick-release-5.0 needs-cherry-pick-release-5.1 needs-cherry-pick-release-5.2 needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
8 participants