Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statstics,ddl: fix FK table forgets to send CreateTable event (#53654) #53661

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix linter
hawkingrei committed May 29, 2024
commit 24f7bdb3c51438a8ea9ace888211a919030f7564
1,516 changes: 0 additions & 1,516 deletions pkg/statistics/handle/ddl/ddl_test.go

This file was deleted.

24 changes: 24 additions & 0 deletions pkg/statistics/handle/ddl_test.go
Original file line number Diff line number Diff line change
@@ -95,6 +95,30 @@ func TestDDLTable(t *testing.T) {
require.Nil(t, h.Update(is))
statsTbl = h.GetTableStats(tableInfo)
require.False(t, statsTbl.Pseudo)

// For FK table's CreateTable Event
// https://github.com/pingcap/tidb/issues/53652
testKit.MustExec("create table t_parent (id int primary key)")
is = do.InfoSchema()
tbl, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("t_parent"))
require.NoError(t, err)
tableInfo = tbl.Meta()
err = h.HandleDDLEvent(<-h.DDLEventCh())
require.NoError(t, err)
require.Nil(t, h.Update(is))
statsTbl = h.GetTableStats(tableInfo)
require.False(t, statsTbl.Pseudo)

testKit.MustExec("create table t_child (id int primary key, pid int, foreign key (pid) references t_parent(id) on delete cascade on update cascade);")
is = do.InfoSchema()
tbl, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("t_child"))
require.NoError(t, err)
tableInfo = tbl.Meta()
err = h.HandleDDLEvent(<-h.DDLEventCh())
require.NoError(t, err)
require.Nil(t, h.Update(is))
statsTbl = h.GetTableStats(tableInfo)
require.False(t, statsTbl.Pseudo)
}

func TestDDLHistogram(t *testing.T) {