Skip to content

Commit

Permalink
statistics: make the naming more coherent (#3827)
Browse files Browse the repository at this point in the history
  • Loading branch information
alivxxx authored and hanfei1991 committed Jul 20, 2017
1 parent edb9110 commit 62fcf2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions statistics/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ func (hg *Histogram) SaveToStorage(ctx context.Context, tableID int64, count int
return errors.Trace(err)
}

func (h *Handle) histogramFromStorage(tableID int64, colID int64, tp *types.FieldType, distinct int64, isIndex int, ver uint64, nullCount int64) (*Histogram, error) {
func histogramFromStorage(ctx context.Context, tableID int64, colID int64, tp *types.FieldType, distinct int64, isIndex int, ver uint64, nullCount int64) (*Histogram, error) {
selSQL := fmt.Sprintf("select bucket_id, count, repeats, lower_bound, upper_bound from mysql.stats_buckets where table_id = %d and is_index = %d and hist_id = %d", tableID, isIndex, colID)
rows, _, err := h.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(h.ctx, selSQL)
rows, _, err := ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(ctx, selSQL)
if err != nil {
return nil, errors.Trace(err)
}
Expand All @@ -127,11 +127,11 @@ func (h *Handle) histogramFromStorage(tableID int64, colID int64, tp *types.Fiel
if isIndex == 1 {
lowerBound, upperBound = rows[i].Data[3], rows[i].Data[4]
} else {
lowerBound, err = rows[i].Data[3].ConvertTo(h.ctx.GetSessionVars().StmtCtx, tp)
lowerBound, err = rows[i].Data[3].ConvertTo(ctx.GetSessionVars().StmtCtx, tp)
if err != nil {
return nil, errors.Trace(err)
}
upperBound, err = rows[i].Data[4].ConvertTo(h.ctx.GetSessionVars().StmtCtx, tp)
upperBound, err = rows[i].Data[4].ConvertTo(ctx.GetSessionVars().StmtCtx, tp)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
4 changes: 2 additions & 2 deletions statistics/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (h *Handle) tableStatsFromStorage(tableInfo *model.TableInfo) (*Table, erro
for _, idxInfo := range tableInfo.Indices {
if histID == idxInfo.ID {
if idx == nil || idx.LastUpdateVersion < histVer {
hg, err := h.histogramFromStorage(tableInfo.ID, histID, nil, distinct, 1, histVer, nullCount)
hg, err := histogramFromStorage(h.ctx, tableInfo.ID, histID, nil, distinct, 1, histVer, nullCount)
if err != nil {
return nil, errors.Trace(err)
}
Expand All @@ -120,7 +120,7 @@ func (h *Handle) tableStatsFromStorage(tableInfo *model.TableInfo) (*Table, erro
for _, colInfo := range tableInfo.Columns {
if histID == colInfo.ID {
if col == nil || col.LastUpdateVersion < histVer {
hg, err := h.histogramFromStorage(tableInfo.ID, histID, &colInfo.FieldType, distinct, 0, histVer, nullCount)
hg, err := histogramFromStorage(h.ctx, tableInfo.ID, histID, &colInfo.FieldType, distinct, 0, histVer, nullCount)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit 62fcf2c

Please sign in to comment.