Skip to content

Commit

Permalink
executor: Revert "executor: fix tidb can not show view data_type (#22363
Browse files Browse the repository at this point in the history
)" (#36501)

ref #36496
  • Loading branch information
xiongjiwei authored Jul 24, 2022
1 parent be48447 commit 8c020ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
8 changes: 2 additions & 6 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ func (e *hugeMemTableRetriever) setDataForColumns(ctx context.Context, sctx sess
}
}

e.dataForColumnsInTable(ctx, sctx, schema, table, priv)
e.dataForColumnsInTable(schema, table, priv)
if len(e.rows) >= batch {
return nil
}
Expand All @@ -688,11 +688,7 @@ func (e *hugeMemTableRetriever) setDataForColumns(ctx context.Context, sctx sess
return nil
}

func (e *hugeMemTableRetriever) dataForColumnsInTable(ctx context.Context, sctx sessionctx.Context, schema *model.DBInfo, tbl *model.TableInfo, priv mysql.PrivilegeType) {
if err := tryFillViewColumnType(ctx, sctx, sctx.GetInfoSchema().(infoschema.InfoSchema), schema.Name, tbl); err != nil {
sctx.GetSessionVars().StmtCtx.AppendWarning(err)
return
}
func (e *hugeMemTableRetriever) dataForColumnsInTable(schema *model.DBInfo, tbl *model.TableInfo, priv mysql.PrivilegeType) {
for i, col := range tbl.Columns {
if col.Hidden {
continue
Expand Down
33 changes: 0 additions & 33 deletions table/tables/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import (
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/meta/autoid"
"github.com/pingcap/tidb/parser/auth"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/table/tables"
Expand Down Expand Up @@ -706,37 +704,6 @@ func TestConstraintCheckForUniqueIndex(t *testing.T) {
require.Equal(t, 1, <-ch)
}

func TestViewColumns(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int primary key, b varchar(20))")
tk.MustExec("drop view if exists v")
tk.MustExec("create view v as select * from t")
tk.MustExec("drop view if exists va")
tk.MustExec("create view va as select count(a) from t")
testCases := []struct {
query string
expected []string
}{
{"select data_type from INFORMATION_SCHEMA.columns where table_name = 'v'", []string{types.TypeToStr(mysql.TypeLong, ""), types.TypeToStr(mysql.TypeVarchar, "")}},
{"select data_type from INFORMATION_SCHEMA.columns where table_name = 'va'", []string{types.TypeToStr(mysql.TypeLonglong, "")}},
}
for _, testCase := range testCases {
tk.MustQuery(testCase.query).Check(testutil.RowsWithSep("|", testCase.expected...))
}
tk.MustExec("drop table if exists t")
for _, testCase := range testCases {
require.Len(t, tk.MustQuery(testCase.query).Rows(), 0)
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|",
"Warning|1356|View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them",
"Warning|1356|View 'test.va' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them"))
}
}

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

0 comments on commit 8c020ba

Please sign in to comment.