From 2e3db79144cd315e2277807cfb187e1d8f7ebc6e Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Wed, 29 Jul 2020 13:31:32 +0800 Subject: [PATCH] executor: fix issue of getting stuck when querying information_schema.columns (#18847) (#18849) Signed-off-by: ti-srebot --- executor/infoschema_reader.go | 2 +- infoschema/tables_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/executor/infoschema_reader.go b/executor/infoschema_reader.go index 1d90bffd7f8ea..81fedbb08724e 100644 --- a/executor/infoschema_reader.go +++ b/executor/infoschema_reader.go @@ -535,12 +535,12 @@ func (e *hugeMemTableRetriever) setDataForColumns(ctx sessionctx.Context) error schema := e.dbs[e.dbsIdx] for e.tblIdx < len(schema.Tables) { table := schema.Tables[e.tblIdx] + e.tblIdx++ if checker != nil && !checker.RequestVerification(ctx.GetSessionVars().ActiveRoles, schema.Name.L, table.Name.L, "", mysql.AllPrivMask) { continue } e.dataForColumnsInTable(schema, table) - e.tblIdx++ if len(e.rows) >= batch { return nil } diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index 155813adf6577..6af6956b2d437 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -1124,6 +1124,18 @@ func (s *testTableSuite) TestStmtSummaryTable(c *C) { }, nil, nil) } +func (s *testTableSuite) TestIssue18845(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec(`CREATE USER 'user18845'@'localhost';`) + tk.Se.Auth(&auth.UserIdentity{ + Username: "user18845", + Hostname: "localhost", + AuthUsername: "user18845", + AuthHostname: "localhost", + }, nil, nil) + tk.MustQuery(`select count(*) from information_schema.columns;`) +} + // Test statements_summary_history. func (s *testTableSuite) TestStmtSummaryHistoryTable(c *C) { tk := s.newTestKitWithRoot(c)