Skip to content

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

Closed
@jackysp

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.found/gsfound by gsseverity/moderatesig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions