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

executor: handle unsigned primary key for fast analyze #11074

Merged
merged 2 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,9 @@ func (e *AnalyzeFastExec) updateCollectorSamples(sValue []byte, sKey kv.Key, sam
}
v = types.NewIntDatum(key)
}
if mysql.HasUnsignedFlag(e.pkInfo.Flag) {
v.SetUint64(uint64(v.GetInt64()))
}
if e.collectors[0].Samples[samplePos] == nil {
e.collectors[0].Samples[samplePos] = &statistics.SampleItem{}
}
Expand Down
7 changes: 7 additions & 0 deletions executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ func (s *testSuite1) TestFastAnalyze(c *C) {
tk.MustQuery("explain select a, b from t1 where a = 1 and b = 2").Check(testkit.Rows(
"IndexReader_6 2.00 root index:IndexScan_5",
"└─IndexScan_5 2.00 cop table:t1, index:a, b, range:[1 2,1 2], keep order:false"))

tk.MustExec("create table t2 (a bigint unsigned, primary key(a))")
tk.MustExec("insert into t2 values (0), (18446744073709551615)")
tk.MustExec("analyze table t2")
tk.MustQuery("show stats_buckets where table_name = 't2'").Check(testkit.Rows(
"test t2 a 0 0 1 1 0 0",
"test t2 a 0 1 2 1 18446744073709551615 18446744073709551615"))
}

func (s *testSuite1) TestAnalyzeIncremental(c *C) {
Expand Down