Skip to content

Commit

Permalink
executor: enable TiDBEnableWindowFunction in SystemVar (#37077)
Browse files Browse the repository at this point in the history
close #35916, close #37045
  • Loading branch information
hawkingrei authored Aug 16, 2022
1 parent 0039dd2 commit 3d9a471
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions executor/showtest/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1870,3 +1870,13 @@ func TestShowCollationsLike(t *testing.T) {
tk.MustQuery("SHOW COLLATION LIKE 'UTF8MB4_BI%'").Check(testkit.Rows("utf8mb4_bin utf8mb4 46 Yes Yes 1"))
tk.MustQuery("SHOW COLLATION LIKE 'utf8mb4_bi%'").Check(testkit.Rows("utf8mb4_bin utf8mb4 46 Yes Yes 1"))
}

func TestShowViewWithWindowFunction(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("CREATE TABLE `test1` (`id` int(0) NOT NULL,`num` int(0) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;")
tk.MustExec("create or replace view test1_v as(select id,row_number() over (partition by num) from test1);")
tk.MustQuery("desc test1_v;").Check(testkit.Rows("id int(0) NO <nil> ", "row_number() over (partition by num) bigint(21) YES <nil> "))
}
4 changes: 4 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,10 @@ func createSessionFunc(store kv.Storage) pools.Factory {
if err != nil {
return nil, errors.Trace(err)
}
err = se.sessionVars.SetSystemVar(variable.TiDBEnableWindowFunction, variable.BoolToOnOff(variable.DefEnableWindowFunction))
if err != nil {
return nil, errors.Trace(err)
}
se.sessionVars.CommonGlobalLoaded = true
se.sessionVars.InRestrictedSQL = true
// Internal session uses default format to prevent memory leak problem.
Expand Down

0 comments on commit 3d9a471

Please sign in to comment.