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

using explain to explain a sql which has SET_VAR in binding, SET_VAR becomes session level #59822

Open
winoros opened this issue Feb 27, 2025 · 0 comments · May be fixed by #59825
Open

using explain to explain a sql which has SET_VAR in binding, SET_VAR becomes session level #59822

winoros opened this issue Feb 27, 2025 · 0 comments · May be fixed by #59825
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@winoros
Copy link
Member

winoros commented Feb 27, 2025

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set @@max_execution_time=2000;
select @@max_execution_time;
explain select /*+ set_var(max_execution_time=100) */ @@max_execution_time;
select @@max_execution_time;
drop table if exists t;
create table t(a int);
create global binding for select * from t where a = 1 and sleep(0.1) using select /*+ SET_VAR(max_execution_time=500) */ * from t where a = 1 and sleep(0.1);
select * from t where a = 1 and sleep(0.1);
select @@last_plan_from_binding;
select @@max_execution_time;
explain select * from t where a = 1 and sleep(0.1);
select @@last_plan_from_binding;
select @@max_execution_time;

2. What did you expect to see? (Required)

directly explain the SQL or execute it with binding, the session var is not changed after the execution is finished.

but if we explain the SQL which has a binding, and the binding has SET_VAR, we'll see that the SET_VAR changes the value of session var.

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

master branch

@winoros winoros added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant