【 TiDB 使用环境】生产环境
【 TiDB 版本】6.1.1
遇到的问题:
使用 CTE递归查询出现[HY000][1105] runtime error: invalid memory address or nil pointer dereference错误
tidb错误日志:
[2025/01/07 16:34:58.478 +08:00] [ERROR] [conn.go:1056] [“connection running loop panic”] [conn=5015268358472348285] [lastSQL=“/* ApplicationName=DataGrip 2024.3.3 */ WITH RECURSIVE parent_dictionary(id, kv_key) AS\r\n (\r\n – 初始查询:找到根节点\r\n SELECT id, kv_key\r\n FROM hotel_kv\r\n WHERE id = 1 – 替换为你要查询的根节点ID\r\n UNION ALL\r\n – 递归查询:找到所有父节点\r\n SELECT d.id, d.kv_key\r\n FROM hotel_kv d\r\n INNER JOIN parent_dictionary pd ON d.kv_key = pd.kv_key\r\n )\r\n SELECT * FROM parent_dictionary”] [err=“runtime error: invalid memory address or nil pointer dereference”] [stack=“github.com/pingcap/tidb/server.(*clientConn).Run.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1059\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:838\nruntime.panicmem\n\t/usr/local/go/src/runtime/panic.go:220\nruntime.sigpanic\n\t/usr/local/go/src/runtime/signal_unix.go:818\ngithub.com/pingcap/tidb/executor.getDbFromResultNode\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:311\ngithub.com/pingcap/tidb/executor.getDbFromResultNode\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:305\ngithub.com/pingcap/tidb/executor.getDbFromResultNode\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:314\ngithub.com/pingcap/tidb/executor.getDbFromResultNode\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:308\ngithub.com/pingcap/tidb/executor.getStmtDbLabel\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:227\ngithub.com/pingcap/tidb/executor.CountStmtNode\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:187\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile\n\t/home/jenkins/agen
t/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:90\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:1916\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/driver_tidb.go:230\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:2022\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1876\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1371\ngithub.com/pingcap/tidb/server.(*clientConn).Run\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1121\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/server.go:559”]