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

statistics: change the dnv of default null column to 0 #4825

Merged
merged 3 commits into from Oct 19, 2017
Jump to file or symbol
Failed to load files and symbols.
+2 −1
Diff settings

Always

Just for now

View
@@ -137,7 +137,7 @@ func (h *Handle) insertColStats2KV(tableID int64, colInfo *model.ColumnInfo) err
}
if value.IsNull() {
// If the adding column has default value null, all the existing rows have null value on the newly added column.
_, err = exec.Execute(fmt.Sprintf("insert into mysql.stats_histograms (version, table_id, is_index, hist_id, distinct_count, null_count) values (%d, %d, 0, %d, 1, %d)", h.ctx.Txn().StartTS(), tableID, colInfo.ID, count))
_, err = exec.Execute(fmt.Sprintf("insert into mysql.stats_histograms (version, table_id, is_index, hist_id, distinct_count, null_count) values (%d, %d, 0, %d, 0, %d)", h.ctx.Txn().StartTS(), tableID, colInfo.ID, count))
if err != nil {
return errors.Trace(err)
}
View
@@ -125,6 +125,7 @@ func (s *testStatsCacheSuite) TestDDLHistogram(c *C) {
c.Assert(statsTbl.Pseudo, IsFalse)
sc := new(variable.StatementContext)
c.Assert(statsTbl.ColumnIsInvalid(tableInfo.Columns[2]), IsTrue)
c.Check(statsTbl.Columns[tableInfo.Columns[2].ID].NDV, Equals, int64(0))
testKit.MustExec("alter table t add column c3 int NOT NULL")
err = h.HandleDDLEvent(<-h.DDLEventCh())
ProTip! Use n and p to navigate between commits in a pull request.