{"action":"opened","issue":{"url":"https://api.github.com/repos/pingcap/tidb/issues/4302","repository_url":"https://api.github.com/repos/pingcap/tidb","labels_url":"https://api.github.com/repos/pingcap/tidb/issues/4302/labels{/name}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/4302/comments","events_url":"https://api.github.com/repos/pingcap/tidb/issues/4302/events","html_url":"https://github.com/pingcap/tidb/issues/4302","id":252205278,"number":4302,"title":"set @varname=(select a from t limit 1) causes error","user":{"login":"XuHuaiyu","id":9039012,"avatar_url":"https://avatars1.githubusercontent.com/u/9039012?v=4","gravatar_id":"","url":"https://api.github.com/users/XuHuaiyu","html_url":"https://github.com/XuHuaiyu","followers_url":"https://api.github.com/users/XuHuaiyu/followers","following_url":"https://api.github.com/users/XuHuaiyu/following{/other_user}","gists_url":"https://api.github.com/users/XuHuaiyu/gists{/gist_id}","starred_url":"https://api.github.com/users/XuHuaiyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuHuaiyu/subscriptions","organizations_url":"https://api.github.com/users/XuHuaiyu/orgs","repos_url":"https://api.github.com/users/XuHuaiyu/repos","events_url":"https://api.github.com/users/XuHuaiyu/events{/privacy}","received_events_url":"https://api.github.com/users/XuHuaiyu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-23T08:44:29Z","updated_at":"2017-08-23T08:44:29Z","closed_at":null,"body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n1. What did you do?\r\n``` sql\r\ndrop table if exists t;\r\ncreate table t(a int);\r\ninsert into t value(1);\r\nset @varname = (select a from t limit 1);\r\n```\r\n\r\n\r\n2. What did you expect to see?\r\n``` sql\r\nmysql> set @varname = (select a from t limit 1);\r\nQuery OK, 0 rows affected (0.00 sec)\r\n```\r\n\r\n\r\n3. What did you see instead?\r\nerror log \r\n```\r\n2017/08/23 16:41:21 conn.go:344: [error] lastCmd set @varname = (select a from t limit 1), runtime error: invalid memory address or nil pointer dereference, goroutine 174 [running]:\r\ngithub.com/pingcap/tidb/server.(*clientConn).Run.func1(0xc42052fc30)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:342 +0xcd\r\npanic(0x1c6d740, 0x2841290)\r\n\t/Users/xuhuaiyu/.gvm/gos/go1.8/src/runtime/panic.go:489 +0x2cf\r\ngithub.com/pingcap/tidb/expression.(*Schema).Clone(0x0, 0xc4204ff200)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/expression/schema.go:63 +0x3a\r\ngithub.com/pingcap/tidb/plan.(*expressionRewriter).buildSubquery(0xc420865b20, 0xc42072e8f0, 0xc420691350, 0x8)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/expression_rewriter.go:212 +0x33\r\ngithub.com/pingcap/tidb/plan.(*expressionRewriter).handleScalarSubquery(0xc420865b20, 0xc42072e8f0, 0x25216e0, 0x70, 0x70)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/expression_rewriter.go:616 +0x50\r\ngithub.com/pingcap/tidb/plan.(*expressionRewriter).Enter(0xc420865b20, 0x2522660, 0xc42072e8f0, 0x70, 0x1d84560, 0x100d501)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/expression_rewriter.go:268 +0x49c\r\ngithub.com/pingcap/tidb/ast.(*SubqueryExpr).Accept(0xc42072e8f0, 0x2519be0, 0xc420865b20, 0xc4206915f8, 0x100f5c2, 0xc42090acc0)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/ast/expressions.go:268 +0x4b\r\ngithub.com/pingcap/tidb/plan.(*planBuilder).rewriteWithPreprocess(0xc420900300, 0x252b6c0, 0xc42072e8f0, 0x0, 0x0, 0x0, 0x100d501, 0x0, 0xc420691628, 0x100fe18, ...)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/expression_rewriter.go:84 +0x120\r\ngithub.com/pingcap/tidb/plan.(*planBuilder).rewrite(0xc420900300, 0x252b6c0, 0xc42072e8f0, 0x0, 0x0, 0x0, 0xc42072e801, 0xc4206916b8, 0x30, 0x30, ...)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/expression_rewriter.go:65 +0x88\r\ngithub.com/pingcap/tidb/plan.(*planBuilder).buildSet(0xc420900300, 0xc42090ab70, 0x1f0f4f0b, 0xc42090ac90)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/planbuilder.go:222 +0x41d\r\ngithub.com/pingcap/tidb/plan.(*planBuilder).build(0xc420900300, 0x25225e0, 0xc42090ab70, 0x0, 0xc42090ac90)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/planbuilder.go:166 +0xbbf\r\ngithub.com/pingcap/tidb/plan.Optimize(0x252c120, 0xc42052fd90, 0x25225e0, 0xc42090ab70, 0x2c49040, 0xc42078cc60, 0x0, 0x0, 0x2856d40, 0x2b68960)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/plan/optimizer.go:71 +0x1a7\r\ngithub.com/pingcap/tidb/executor.(*Compiler).Compile(0xc4206918f0, 0x252c120, 0xc42052fd90, 0x2c138b8, 0xc42090ab70, 0x1059c35, 0x1086b92, 0xc4202a4dc0, 0xc420552f50)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/executor/compiler.go:41 +0x1b7\r\ngithub.com/pingcap/tidb.Compile(0x252c120, 0xc42052fd90, 0x2c138b8, 0xc42090ab70, 0x0, 0x0, 0x0, 0xc4202aa2b0)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/tidb.go:150 +0x57\r\ngithub.com/pingcap/tidb.(*session).Execute(0xc42052fd90, 0xc42090aab1, 0x28, 0xc420691bb8, 0x101094c, 0xc420691bb8, 0x1010f22, 0xc420566028)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/session.go:640 +0x515\r\ngithub.com/pingcap/tidb/server.(*TiDBContext).Execute(0xc4208081e0, 0xc42090aab1, 0x28, 0x0, 0x0, 0xc420691c88, 0x106ef38, 0xc4206ece98)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/driver_tidb.go:188 +0x62\r\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc42052fc30, 0xc42090aab1, 0x28, 0x0, 0x0)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:684 +0x8d\r\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch(0xc42052fc30, 0xc42090aab1, 0x29, 0x28, 0x0, 0x0)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:473 +0x42e\r\ngithub.com/pingcap/tidb/server.(*clientConn).Run(0xc42052fc30)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/server/conn.go:364 +0x13c\r\ngithub.com/pingcap/tidb/server.(*Server).onConn(0xc4209857c0, 0x252a7a0, 0xc4202b24e8)\r\n\t/Users/xuhuaiyu/Development/GOPATH/src/github.com/pingcap/tidb/serv\r\n2017/08/23 16:41:21 server.go:206: [info] [1] close connection\r\n```\r\n\r\n\r\n4. What version of TiDB are you using (`tidb-server -V`)?\r\n\r\n```\r\n+------------------------------------------------------------------------------------------------------------------------------------------------+\r\n| tidb_version()                                                                                                                                 |\r\n+------------------------------------------------------------------------------------------------------------------------------------------------+\r\n| Release Version: 0.8.0\r\nGit Commit Hash: e607ca25c7ddae6e0b3a08b93a70698fb8f8e4a4\r\nGit Branch: xhy/monthname\r\nUTC Build Time: 2017-08-23 08:05:14 |\r\n+------------------------------------------------------------------------------------------------------------------------------------------------+\r\n1 row in set (0.01 sec)\r\n```"}}
{"actor":{"display_login":"XuHuaiyu"}}