Skip to content

Commit

Permalink
*: make "unconvert" happy (pingcap#4700)
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-jason authored Sep 30, 2017
1 parent 8a28b7b commit 665f629
Show file tree
Hide file tree
Showing 31 changed files with 63 additions and 63 deletions.
12 changes: 6 additions & 6 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func columnDefToCol(ctx context.Context, offset int, colDef *ast.ColumnDef) (*ta
case ast.ColumnOptionNotNull:
col.Flag |= mysql.NotNullFlag
case ast.ColumnOptionNull:
col.Flag &= ^uint(mysql.NotNullFlag)
col.Flag &= ^mysql.NotNullFlag
removeOnUpdateNowFlag(col)
case ast.ColumnOptionAutoIncrement:
col.Flag |= mysql.AutoIncrementFlag
Expand Down Expand Up @@ -397,7 +397,7 @@ func removeOnUpdateNowFlag(c *table.Column) {
// For timestamp Col, if it is set null or default value,
// OnUpdateNowFlag should be removed.
if mysql.HasTimestampFlag(c.Flag) {
c.Flag &= ^uint(mysql.OnUpdateNowFlag)
c.Flag &= ^mysql.OnUpdateNowFlag
}
}

Expand Down Expand Up @@ -1035,8 +1035,8 @@ func modifiable(origin *types.FieldType, to *types.FieldType) error {
msg := fmt.Sprintf("collate %s not match origin %s", to.Collate, origin.Collate)
return errUnsupportedModifyColumn.GenByArgs(msg)
}
toUnsigned := mysql.HasUnsignedFlag(uint(to.Flag))
originUnsigned := mysql.HasUnsignedFlag(uint(origin.Flag))
toUnsigned := mysql.HasUnsignedFlag(to.Flag)
originUnsigned := mysql.HasUnsignedFlag(origin.Flag)
if originUnsigned != toUnsigned {
msg := fmt.Sprintf("unsigned %v not match origin %v", toUnsigned, originUnsigned)
return errUnsupportedModifyColumn.GenByArgs(msg)
Expand Down Expand Up @@ -1109,7 +1109,7 @@ func setDefaultAndComment(ctx context.Context, col *table.Column, options []*ast
case ast.ColumnOptionNotNull:
col.Flag |= mysql.NotNullFlag
case ast.ColumnOptionNull:
col.Flag &= ^uint(mysql.NotNullFlag)
col.Flag &= ^mysql.NotNullFlag
case ast.ColumnOptionAutoIncrement:
col.Flag |= mysql.AutoIncrementFlag
case ast.ColumnOptionPrimaryKey, ast.ColumnOptionUniqKey:
Expand Down Expand Up @@ -1291,7 +1291,7 @@ func (d *ddl) AlterColumn(ctx context.Context, ident ast.Ident, spec *ast.AlterT
}

// Clean the NoDefaultValueFlag value.
col.Flag &= ^uint(mysql.NoDefaultValueFlag)
col.Flag &= ^mysql.NoDefaultValueFlag
if len(spec.NewColumn.Options) == 0 {
col.DefaultValue = nil
setNoDefaultValueFlag(col, false)
Expand Down
6 changes: 3 additions & 3 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ func dropIndexColumnFlag(tblInfo *model.TableInfo, indexInfo *model.IndexInfo) {
col := indexInfo.Columns[0]

if indexInfo.Unique && len(indexInfo.Columns) == 1 {
tblInfo.Columns[col.Offset].Flag &= ^uint(mysql.UniqueKeyFlag)
tblInfo.Columns[col.Offset].Flag &= ^mysql.UniqueKeyFlag
} else {
tblInfo.Columns[col.Offset].Flag &= ^uint(mysql.MultipleKeyFlag)
tblInfo.Columns[col.Offset].Flag &= ^mysql.MultipleKeyFlag
}

// other index may still cover this col
Expand Down Expand Up @@ -569,7 +569,7 @@ func (d *ddl) addTableIndex(t table.Table, indexInfo *model.IndexInfo, reorgInfo
wg.Wait()

taskAddedCount, nextHandle, isEnd, err := getCountAndHandle(workers)
addedCount += int64(taskAddedCount)
addedCount += taskAddedCount
sub := time.Since(startTime).Seconds()
if err == nil {
err = d.isReorgRunnable()
Expand Down
2 changes: 1 addition & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func buildColumnInfo(tableName string, col columnInfo) *model.ColumnInfo {
Collate: mCollation,
Tp: col.tp,
Flen: col.size,
Flag: uint(mFlag),
Flag: mFlag,
}
return &model.ColumnInfo{
Name: model.NewCIStr(col.name),
Expand Down
6 changes: 3 additions & 3 deletions parser/yy_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func toInt(l yyLexer, lval *yySymType, str string) int {
case n < math.MaxInt64:
lval.item = int64(n)
default:
lval.item = uint64(n)
lval.item = n
}
return intLit
}
Expand All @@ -190,7 +190,7 @@ func toFloat(l yyLexer, lval *yySymType, str string) int {
return int(unicode.ReplacementChar)
}

lval.item = float64(n)
lval.item = n
return floatLit
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func getUint64FromNUM(num interface{}) uint64 {
case int64:
return uint64(v)
case uint64:
return uint64(v)
return v
}
return 0
}
4 changes: 2 additions & 2 deletions perfschema/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func buildUsualColumnInfo(offset int, name string, tp byte, size int, flag uint,
Collate: mCollation,
Tp: tp,
Flen: size,
Flag: uint(flag),
Flag: flag,
}
colInfo := &model.ColumnInfo{
Name: model.NewCIStr(name),
Expand All @@ -285,7 +285,7 @@ func buildEnumColumnInfo(offset int, name string, elems []string, flag uint, def
Charset: mCharset,
Collate: mCollation,
Tp: mysql.TypeEnum,
Flag: uint(flag),
Flag: flag,
Elems: elems,
}
colInfo := &model.ColumnInfo{
Expand Down
2 changes: 1 addition & 1 deletion plan/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func buildColumn(tableName, name string, tp byte, size int) *expression.Column {
Collate: cl,
Tp: tp,
Flen: size,
Flag: uint(flag),
Flag: flag,
}
return &expression.Column{
ColName: model.NewCIStr(name),
Expand Down
2 changes: 1 addition & 1 deletion server/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (column *ColumnInfo) Dump(alloc arena.Allocator) []byte {

if column.DefaultValue != nil {
data = append(data, dumpUint64(uint64(len(column.DefaultValue)))...)
data = append(data, []byte(column.DefaultValue)...)
data = append(data, column.DefaultValue...)
}

return data
Expand Down
6 changes: 3 additions & 3 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (cc *clientConn) readOptionalSSLRequestAndHandshakeResponse() error {
tlsState := cc.tlsConn.ConnectionState()
tlsStatePtr = &tlsState
}
cc.ctx, err = cc.server.driver.OpenCtx(uint64(cc.connectionID), cc.capability, uint8(cc.collation), cc.dbname, tlsStatePtr)
cc.ctx, err = cc.server.driver.OpenCtx(uint64(cc.connectionID), cc.capability, cc.collation, cc.dbname, tlsStatePtr)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -558,8 +558,8 @@ func (cc *clientConn) flush() error {
func (cc *clientConn) writeOK() error {
data := cc.alloc.AllocWithLen(4, 32)
data = append(data, mysql.OKHeader)
data = append(data, dumpLengthEncodedInt(uint64(cc.ctx.AffectedRows()))...)
data = append(data, dumpLengthEncodedInt(uint64(cc.ctx.LastInsertID()))...)
data = append(data, dumpLengthEncodedInt(cc.ctx.AffectedRows())...)
data = append(data, dumpLengthEncodedInt(cc.ctx.LastInsertID())...)
if cc.capability&mysql.ClientProtocol41 > 0 {
data = append(data, dumpUint16(cc.ctx.Status())...)
data = append(data, dumpUint16(cc.ctx.WarningCount())...)
Expand Down
2 changes: 1 addition & 1 deletion server/driver_tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func convertColumnInfo(fld *ast.ResultField) (ci *ColumnInfo) {
} else {
ci.Decimal = uint8(fld.Column.Decimal)
}
ci.Type = uint8(fld.Column.Tp)
ci.Type = fld.Column.Tp

// Keep things compatible for old clients.
// Refer to mysql-server/sql/protocol.cc send_result_set_metadata()
Expand Down
2 changes: 1 addition & 1 deletion server/packetio.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (p *packetIO) readOnePacket() ([]byte, error) {
return nil, errors.Trace(err)
}

sequence := uint8(header[3])
sequence := header[3]
if sequence != p.sequence {
return nil, errInvalidSequence.Gen("invalid sequence %d != %d", sequence, p.sequence)
}
Expand Down
6 changes: 3 additions & 3 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ func uniformValue(value interface{}) interface{} {
case int32:
return int64(v)
case int64:
return int64(v)
return v
case uint8:
return uint64(v)
case uint16:
return uint64(v)
case uint32:
return uint64(v)
case uint64:
return uint64(v)
return v
default:
return value
}
Expand Down Expand Up @@ -285,7 +285,7 @@ func dumpRowValuesBinary(alloc arena.Allocator, columns []*ColumnInfo, row []typ
case mysql.TypeInt24, mysql.TypeLong:
data = append(data, dumpUint32(uint32(v))...)
case mysql.TypeLonglong:
data = append(data, dumpUint64(uint64(v))...)
data = append(data, dumpUint64(v)...)
}
case types.KindFloat32:
floatBits := math.Float32bits(val.GetFloat32())
Expand Down
2 changes: 1 addition & 1 deletion statistics/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func getPseudoRowCountByIndexRanges(sc *variable.StatementContext, indexRanges [
if err != nil {
return 0, errors.Trace(err)
}
count = count / float64(tableRowCount) * float64(rowCount)
count = count / tableRowCount * rowCount
// If the condition is a = 1, b = 1, c = 1, d = 1, we think every a=1, b=1, c=1 only filtrate 1/100 data,
// so as to avoid collapsing too fast.
for j := 0; j < i; j++ {
Expand Down
2 changes: 1 addition & 1 deletion store/localstore/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (s *dbStore) doCommit(txn *dbTxn) error {
}
b := s.db.NewBatch()
txn.us.WalkBuffer(func(k kv.Key, value []byte) error {
mvccKey := MvccEncodeVersionKey(kv.Key(k), commitVer)
mvccKey := MvccEncodeVersionKey(k, commitVer)
if len(value) == 0 { // Deleted marker
b.Put(mvccKey, nil)
s.compactor.OnDelete(k)
Expand Down
4 changes: 2 additions & 2 deletions store/localstore/local_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (rs *localRegion) Handle(req *regionRequest) (*regionResponse, error) {
if err != nil {
return nil, errors.Trace(err)
}
txn := newTxn(rs.store, kv.Version{Ver: uint64(sel.StartTs)})
txn := newTxn(rs.store, kv.Version{Ver: sel.StartTs})
ctx := &selectContext{
sel: sel,
txn: txn,
Expand Down Expand Up @@ -707,7 +707,7 @@ func (rs *localRegion) getRowsFromIndexReq(ctx *selectContext) error {
if err != nil {
return errors.Trace(err)
}
limit -= int64(count)
limit -= count
}
if ctx.aggregate {
return rs.getRowsFromAgg(ctx)
Expand Down
2 changes: 1 addition & 1 deletion store/localstore/local_version_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (l *LocalVersionProvider) CurrentVersion() (kv.Version, error) {
continue
}

if l.lastTimestamp == uint64(ts) {
if l.lastTimestamp == ts {
l.logical++
if l.logical >= 1<<timePrecisionOffset {
return kv.Version{}, ErrOverflow
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func txnLockTTL(startTime monotime.Time, txnSize int) uint64 {
lockTTL := defaultLockTTL
if txnSize >= txnCommitBatchSize {
sizeMiB := float64(txnSize) / bytesPerMiB
lockTTL = uint64(float64(ttlFactor) * math.Sqrt(float64(sizeMiB)))
lockTTL = uint64(float64(ttlFactor) * math.Sqrt(sizeMiB))
if lockTTL < defaultLockTTL {
lockTTL = defaultLockTTL
}
Expand Down
4 changes: 2 additions & 2 deletions store/tikv/gc_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (w *GCWorker) checkGCInterval(now time.Time) (bool, error) {
if err != nil {
return false, errors.Trace(err)
}
gcConfigGauge.WithLabelValues(gcRunIntervalKey).Set(float64(runInterval.Seconds()))
gcConfigGauge.WithLabelValues(gcRunIntervalKey).Set(runInterval.Seconds())
lastRun, err := w.loadTime(gcLastRunTimeKey, w.session)
if err != nil {
return false, errors.Trace(err)
Expand All @@ -375,7 +375,7 @@ func (w *GCWorker) calculateNewSafePoint(now time.Time) (*time.Time, error) {
if err != nil {
return nil, errors.Trace(err)
}
gcConfigGauge.WithLabelValues(gcLifeTimeKey).Set(float64(lifeTime.Seconds()))
gcConfigGauge.WithLabelValues(gcLifeTimeKey).Set(lifeTime.Seconds())
lastSafePoint, err := w.loadTime(gcSafePointKey, w.session)
if err != nil {
return nil, errors.Trace(err)
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/mock-tikv/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (c *Cluster) SplitRaw(regionID, newRegionID uint64, rawKey []byte, peerIDs
c.Lock()
defer c.Unlock()

newRegion := c.regions[regionID].split(newRegionID, []byte(rawKey), peerIDs, leaderPeerID)
newRegion := c.regions[regionID].split(newRegionID, rawKey, peerIDs, leaderPeerID)
c.regions[newRegionID] = newRegion
}

Expand Down
2 changes: 1 addition & 1 deletion store/tikv/mock-tikv/cop_handler_dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (h *rpcHandler) extractKVRanges(keyRanges []*coprocessor.KeyRange, descScan
continue
}
lowerKey := kran.GetStart()
if len(h.rawEndKey) != 0 && bytes.Compare([]byte(lowerKey), h.rawEndKey) >= 0 {
if len(h.rawEndKey) != 0 && bytes.Compare(lowerKey, h.rawEndKey) >= 0 {
break
}
var kvr kv.KeyRange
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/mock-tikv/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (e *tableScanExec) getRowFromPoint(ran kv.KeyRange) ([][]byte, error) {
if len(val) == 0 {
return nil, nil
}
handle, err := tablecodec.DecodeRowKey(kv.Key(ran.StartKey))
handle, err := tablecodec.DecodeRowKey(ran.StartKey)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/mock-tikv/mvcc_leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func mvccEncode(key []byte, ver uint64) []byte {
// just returns the origin key.
func mvccDecode(encodedKey []byte) ([]byte, uint64, error) {
// Skip DataPrefix
remainBytes, key, err := codec.DecodeBytes([]byte(encodedKey))
remainBytes, key, err := codec.DecodeBytes(encodedKey)
if err != nil {
// should never happen
return nil, 0, errors.Trace(err)
Expand Down
4 changes: 2 additions & 2 deletions store/tikv/oracle/oracles/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func (l *localOracle) GetTimestamp(goctx.Context) (uint64, error) {
ts := oracle.ComposeTS(physical, 0)
if l.lastTimeStampTS == ts {
l.n++
return uint64(ts + l.n), nil
return ts + l.n, nil
}
l.lastTimeStampTS = ts
l.n = 0
return uint64(ts), nil
return ts, nil
}

func (l *localOracle) GetTimestampAsync(ctx goctx.Context) oracle.Future {
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *Scanner) getData(bo *Backoffer) error {
req := &tikvrpc.Request{
Type: tikvrpc.CmdScan,
Scan: &pb.ScanRequest{
StartKey: []byte(s.nextStartKey),
StartKey: s.nextStartKey,
Limit: uint32(s.batchSize),
Version: s.startTS(),
},
Expand Down
4 changes: 2 additions & 2 deletions table/tables/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type index struct {

// NewIndexWithBuffer builds a new Index object whit the buffer.
func NewIndexWithBuffer(tableInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Index {
idxPrefix := kv.Key(tablecodec.EncodeTableIndexPrefix(tableInfo.ID, indexInfo.ID))
idxPrefix := tablecodec.EncodeTableIndexPrefix(tableInfo.ID, indexInfo.ID)
index := &index{
tblInfo: tableInfo,
idxInfo: indexInfo,
Expand All @@ -118,7 +118,7 @@ func NewIndex(tableInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Inde
index := &index{
tblInfo: tableInfo,
idxInfo: indexInfo,
prefix: kv.Key(tablecodec.EncodeTableIndexPrefix(tableInfo.ID, indexInfo.ID)),
prefix: tablecodec.EncodeTableIndexPrefix(tableInfo.ID, indexInfo.ID),
}
return index
}
Expand Down
6 changes: 3 additions & 3 deletions util/types/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,13 @@ func ToString(value interface{}) (string, error) {
case int:
return strconv.FormatInt(int64(v), 10), nil
case int64:
return strconv.FormatInt(int64(v), 10), nil
return strconv.FormatInt(v, 10), nil
case uint64:
return strconv.FormatUint(uint64(v), 10), nil
return strconv.FormatUint(v, 10), nil
case float32:
return strconv.FormatFloat(float64(v), 'f', -1, 32), nil
case float64:
return strconv.FormatFloat(float64(v), 'f', -1, 64), nil
return strconv.FormatFloat(v, 'f', -1, 64), nil
case string:
return v, nil
case []byte:
Expand Down
2 changes: 1 addition & 1 deletion util/types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ func (d *Datum) ToString() (string, error) {
case KindFloat32:
return strconv.FormatFloat(float64(d.GetFloat32()), 'f', -1, 32), nil
case KindFloat64:
return strconv.FormatFloat(float64(d.GetFloat64()), 'f', -1, 64), nil
return strconv.FormatFloat(d.GetFloat64(), 'f', -1, 64), nil
case KindString:
return d.GetString(), nil
case KindBytes:
Expand Down
2 changes: 1 addition & 1 deletion util/types/datum_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func ComputeMod(sc *variable.StatementContext, a, b Datum) (d Datum, err error)
return d, nil
} else if y < 0 {
// first is uint64, return uint64.
d.SetUint64(uint64(x % uint64(-y)))
d.SetUint64(x % uint64(-y))
return d, nil
}
d.SetUint64(x % uint64(y))
Expand Down
Loading

0 comments on commit 665f629

Please sign in to comment.