diff --git a/executor/showtest/show_test.go b/executor/showtest/show_test.go index 1a20a02868a5d..dfcbe6b670c53 100644 --- a/executor/showtest/show_test.go +++ b/executor/showtest/show_test.go @@ -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 ", "row_number() over (partition by num) bigint(21) YES ")) +} diff --git a/session/session.go b/session/session.go index c8895ea3b09e1..3708a212954f7 100644 --- a/session/session.go +++ b/session/session.go @@ -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.