pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.32k stars 5.72k forks source link

planner: move checks for noop functions in select statements to preprocess #53279

Closed henrybw closed 2 weeks ago

henrybw commented 2 weeks ago

What problem does this PR solve?

Issue Number: close #52432

Problem Summary:

The LOCK IN SHARE MODE clause for SELECT statements is currently a noop, controlled by tidb_enable_noop_functions: when tidb_enable_noop_functions=OFF, using a noop like LOCK IN SHARE MODE should cause an error. However, point-get queries use a special "fast path" that accidentally bypasses this noop check, meaning that a query like select * from t where a=1 lock in share mode; (where a is a key column) will run even when tidb_enable_noop_functions=OFF.

What changed and how does it work?

Check List

Tests

Side effects

Documentation

Release note

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

None
sre-bot commented 2 weeks ago

CLA assistant check
All committers have signed the CLA.

tiprow[bot] commented 2 weeks ago

Hi @henrybw. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.9689%. Comparing base (acdb6f5) to head (d32550b). Report is 23 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #53279 +/- ## ================================================ + Coverage 72.4943% 73.9689% +1.4746% ================================================ Files 1493 1499 +6 Lines 429359 437655 +8296 ================================================ + Hits 311261 323729 +12468 + Misses 98889 93749 -5140 - Partials 19209 20177 +968 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb/pull/53279/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [integration](https://app.codecov.io/gh/pingcap/tidb/pull/53279/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `49.1701% <83.3333%> (?)` | | | [unit](https://app.codecov.io/gh/pingcap/tidb/pull/53279/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `71.2385% <100.0000%> (-0.1583%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/pingcap/tidb/pull/53279/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [dumpling](https://app.codecov.io/gh/pingcap/tidb/pull/53279/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.9957% <ø> (ø)` | | | [parser](https://app.codecov.io/gh/pingcap/tidb/pull/53279/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `∅ <ø> (∅)` | | | [br](https://app.codecov.io/gh/pingcap/tidb/pull/53279/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `50.7974% <ø> (+9.3404%)` | :arrow_up: |
lance6716 commented 2 weeks ago

/cc @hawkingrei

ti-chi-bot[bot] commented 2 weeks ago

[LGTM Timeline notifier]

Timeline:

henrybw commented 2 weeks ago

/retest

tiprow[bot] commented 2 weeks ago

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

In response to [this](https://github.com/pingcap/tidb/pull/53279#issuecomment-2115698630): >/retest Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
ti-chi-bot[bot] commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, hawkingrei, tangenta

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](https://github.com/pingcap/tidb/blob/master/OWNERS)~~ [D3Hunter,hawkingrei,tangenta] - ~~[pkg/planner/OWNERS](https://github.com/pingcap/tidb/blob/master/pkg/planner/OWNERS)~~ [hawkingrei] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
hawkingrei commented 2 weeks ago

/retest