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

server: use stmt should apply to subsequent stmts in multi-stmt mode #26905

Merged
merged 5 commits into from
Aug 9, 2021

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Aug 4, 2021

What problem does this PR solve?

Issue Number: close #26688

Problem Summary:

When multi-statement is enabled, chaining statements following a "use" stmt was not successful. i.e.

use test; create table if not exists t1 (id int); drop table t1;

This is because of prefetching for point plans. It seems unsafe to prefetch the plan if the schema could be changed (but the query might still be valid). So my solution was to disable prefetching if there is a use stmt.

What is changed and how it works?

What's Changed:

Fixes a bug in multi-stmt mode.

Check List

Tests

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

Side effects

  • Performance regression: Consumes more CPU (Point plan cache will be disabled in some edge-case scenarios that are not expected to appear in most user queries).
  • 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

When executing multiple statements in one `COM_QUERY` API call, TiDB did not correctly handle the case that a `use db` statement applies to all remaining statements.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 4, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • xhebox

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 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 4, 2021
@bb7133
Copy link
Member

bb7133 commented Aug 5, 2021

/bench

@morgo morgo requested a review from a team August 5, 2021 03:54
server/server_test.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 5, 2021
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 9, 2021
@bb7133
Copy link
Member

bb7133 commented Aug 9, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 12c3558

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 9, 2021
@bb7133
Copy link
Member

bb7133 commented Aug 9, 2021

/rebuild

@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #27394

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 19, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #27395

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 19, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #27397

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 19, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.2 in PR #27398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/mysql-protocol release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/sql-infra SIG: SQL Infra size/S Denotes a PR that changes 10-29 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
Development

Successfully merging this pull request may close these issues.

different behavior between mysql and tidb about use clause in transaction
5 participants