// BuildHandleColsForAnalyze is exported for test.
BuildHandleColsForAnalyze is exported for test.
// BuildHandleColsForAnalyze is exported for test .
func BuildHandleColsForAnalyze(ctx sessionctx.Context, tblInfo *model.TableInfo) HandleCols {
	var handleCols HandleCols
	switch {
	case tblInfo.PKIsHandle:
		pkCol := tblInfo.GetPkColInfo()
		handleCols = &IntHandleCols{col: &expression.Column{
			ID:      pkCol.ID,
			RetType: &pkCol.FieldType,
			Index:   pkCol.Offset,
		}}
	case tblInfo.IsCommonHandle:
		pkIdx := tables.FindPrimaryIndex(tblInfo)
		pkColLen := len(pkIdx.Columns)
		columns := make([]*expression.Column, pkColLen)
		for i := 0; i < pkColLen; i++ {
			colInfo := tblInfo.Columns[pkIdx.Columns[i].Offset]
			columns[i] = &expression.Column{
				ID:      colInfo.ID,
				RetType: &colInfo.FieldType,
				Index:   colInfo.Offset,
			}
		}
		handleCols = &CommonHandleCols{
			tblInfo: tblInfo,
			idxInfo: pkIdx,
			columns: columns,
			sc:      ctx.GetSessionVars().StmtCtx,
		}
	}
	return handleCols
}
func BuildHandleColsForAnalyze ( ctx sessionctx . Context , tblInfo * model . TableInfo ) HandleCols { var handleCols HandleCols switch { case tblInfo . PKIsHandle : pkCol := tblInfo . GetPkColInfo ( ) handleCols = & IntHandleCols { col : & expression . Column { ID : pkCol . ID , RetType : & pkCol . FieldType , Index : pkCol . Offset , } } case tblInfo . IsCommonHandle : pkIdx := tables . FindPrimaryIndex ( tblInfo ) pkColLen := len ( pkIdx . Columns ) columns := make ( [ ] * expression . Column , pkColLen ) for i := 0 ; i < pkColLen ; i ++ { colInfo := tblInfo . Columns [ pkIdx . Columns [ i ] . Offset ] columns [ i ] = & expression . Column { ID : colInfo . ID , RetType : & colInfo . FieldType , Index : colInfo . Offset , } } handleCols = & CommonHandleCols { tblInfo : tblInfo , idxInfo : pkIdx , columns : columns , sc : ctx . GetSessionVars ( ) . StmtCtx , } } return handleCols }
BuildHandleColsForAnalyze is exported for test.
BuildHandleColsForAnalyze is exported for test .