Skip to content

Commit

Permalink
executor: enable TiDBEnableWindowFunction in SystemVar (#37077) (#37138)
Browse files Browse the repository at this point in the history
close #35916, close #37045
  • Loading branch information
ti-srebot authored Sep 5, 2022
1 parent 368597e commit 696f08e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,17 @@ func TestShowBindingCacheStatus(t *testing.T) {
"1 1 198 Bytes 250 Bytes"))
}

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

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> "))
}

func TestShowDatabasesLike(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
Expand Down
4 changes: 4 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,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 696f08e

Please sign in to comment.