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

Prepare statement panic when query block not found in hint #46817

Closed
jackysp opened this issue Sep 10, 2023 · 1 comment · Fixed by #46818
Closed

Prepare statement panic when query block not found in hint #46817

jackysp opened this issue Sep 10, 2023 · 1 comment · Fixed by #46818
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. found/gs found by gs severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@jackysp
Copy link
Member

jackysp commented Sep 10, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (i int);
prepare stmt from 'with a as (select /*+ qb_name(qb1) */ * from t)  select /*+ leading(@qb1)*/ * from a;'

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

No panic

3. What did you see instead (Required)

SQL panic

github.com/pingcap/tidb/server.(*clientConn).Run.func1
    /Users/yusp/work/tidb/server/conn.go:1090
runtime.gopanic
    /usr/local/go/src/runtime/panic.go:914
github.com/pingcap/tidb/executor.(*ExecStmt).Exec.func1
    /Users/yusp/work/tidb/executor/adapter.go:453
runtime.gopanic
    /usr/local/go/src/runtime/panic.go:914
runtime.panicmem
    /usr/local/go/src/runtime/panic.go:261
runtime.sigpanic
    /usr/local/go/src/runtime/signal_unix.go:861
github.com/pingcap/tidb/util/hint.(*BlockHintProcessor).GetCurrentStmtHints
    /Users/yusp/work/tidb/util/hint/hint_processor.go:599
github.com/pingcap/tidb/planner/core.(*PlanBuilder).pushTableHints
    /Users/yusp/work/tidb/planner/core/logical_plan_builder.go:3578
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildSelect
    /Users/yusp/work/tidb/planner/core/logical_plan_builder.go:3823
github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build
    /Users/yusp/work/tidb/planner/core/planbuilder.go:804
github.com/pingcap/tidb/planner/core.GeneratePlanCacheStmtWithAST
    /Users/yusp/work/tidb/planner/core/plan_cache_utils.go:141
github.com/pingcap/tidb/executor.(*PrepareExec).Next
    /Users/yusp/work/tidb/executor/prepared.go:120
github.com/pingcap/tidb/executor.Next
    /Users/yusp/work/tidb/executor/executor.go:328
github.com/pingcap/tidb/executor.(*ExecStmt).next
    /Users/yusp/work/tidb/executor/adapter.go:1154
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor
    /Users/yusp/work/tidb/executor/adapter.go:927
github.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay
    /Users/yusp/work/tidb/executor/adapter.go:776
github.com/pingcap/tidb/executor.(*ExecStmt).Exec
    /Users/yusp/work/tidb/executor/adapter.go:571
github.com/pingcap/tidb/session.runStmt
    /Users/yusp/work/tidb/session/session.go:2373
github.com/pingcap/tidb/session.(*session).ExecuteStmt
    /Users/yusp/work/tidb/session/session.go:2237
github.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt
    /Users/yusp/work/tidb/server/driver_tidb.go:252
github.com/pingcap/tidb/server.(*clientConn).handleStmt
    /Users/yusp/work/tidb/server/conn.go:2122
github.com/pingcap/tidb/server.(*clientConn).handleQuery
    /Users/yusp/work/tidb/server/conn.go:1972
github.com/pingcap/tidb/server.(*clientConn).dispatch
    /Users/yusp/work/tidb/server/conn.go:1403
github.com/pingcap/tidb/server.(*clientConn).Run
    /Users/yusp/work/tidb/server/conn.go:1152
github.com/pingcap/tidb/server.(*Server).onConn
    /Users/yusp/work/tidb/server/server.go:648

4. What is your TiDB version? (Required)

d3d30f5 and v6.5.3

@seiya-annie
Copy link

/found gs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. found/gs found by gs 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.

4 participants