Skip to content

Commit

Permalink
executor, util: refine row.GetMyDecimal (pingcap#6077)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu authored and shenli committed Mar 16, 2018
1 parent 4cbdf1e commit c2c85b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ func (s *testSuite) TestAggregation(c *C) {
// test without any aggregate function
tk.MustQuery("select 10 from idx_agg group by b").Check(testkit.Rows("10", "10"))
tk.MustQuery("select 11 from idx_agg group by a").Check(testkit.Rows("11", "11"))

tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int(11), b decimal(15,2))")
tk.MustExec("insert into t values(1,771.64),(2,378.49),(3,920.92),(4,113.97)")
tk.MustQuery("select a, max(b) from t group by a limit 2").Check(testkit.Rows("1 771.64", "2 378.49"))
}

func (s *testSuite) TestStreamAggPushDown(c *C) {
Expand Down
3 changes: 2 additions & 1 deletion util/chunk/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ func (r Row) GetSet(colIdx int) types.Set {
// GetMyDecimal returns the MyDecimal value with the colIdx.
func (r Row) GetMyDecimal(colIdx int) *types.MyDecimal {
col := r.c.columns[colIdx]
return (*types.MyDecimal)(unsafe.Pointer(&col.data[r.idx*types.MyDecimalStructSize]))
dec := *(*types.MyDecimal)(unsafe.Pointer(&col.data[r.idx*types.MyDecimalStructSize]))
return &dec
}

// GetJSON returns the JSON value with the colIdx.
Expand Down

0 comments on commit c2c85b3

Please sign in to comment.