Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
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
1 change: 0 additions & 1 deletion engine_pilosa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,3 @@ func TestCreateIndex(t *testing.T) {
require.NoError(os.RemoveAll(tmpDir))
}()
}

52 changes: 26 additions & 26 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ var queries = []struct {
{
`SELECT COALESCE(NULL, NULL, NULL, COALESCE(NULL, 1234567890))`,
[]sql.Row{
{int64(1234567890)},
{int32(1234567890)},
},
},
{
Expand Down Expand Up @@ -981,7 +981,7 @@ var queries = []struct {
},
{
`SELECT -1`,
[]sql.Row{{int64(-1)}},
[]sql.Row{{int8(-1)}},
},
{
`
Expand Down Expand Up @@ -1043,13 +1043,13 @@ var queries = []struct {
{
`SELECT nullif(123, 321)`,
[]sql.Row{
{int64(123)},
{int8(123)},
},
},
{
`SELECT ifnull(123, NULL)`,
[]sql.Row{
{int64(123)},
{int8(123)},
},
},
{
Expand All @@ -1061,19 +1061,19 @@ var queries = []struct {
{
`SELECT ifnull(NULL, 123)`,
[]sql.Row{
{int64(123)},
{int8(123)},
},
},
{
`SELECT ifnull(123, 123)`,
[]sql.Row{
{int64(123)},
{int8(123)},
},
},
{
`SELECT ifnull(123, 321)`,
[]sql.Row{
{int64(123)},
{int8(123)},
},
},
{
Expand All @@ -1085,7 +1085,7 @@ var queries = []struct {
{
`SELECT round(15, 1)`,
[]sql.Row{
{int64(15)},
{int8(15)},
},
},
{
Expand Down Expand Up @@ -1452,7 +1452,7 @@ var queries = []struct {
},
{
`SELECT 1 FROM mytable GROUP BY i HAVING i > 1`,
[]sql.Row{{int64(1)}, {int64(1)}},
[]sql.Row{{int8(1)}, {int8(1)}},
},
{
`SELECT avg(i) FROM mytable GROUP BY i HAVING avg(i) > 1`,
Expand Down Expand Up @@ -1887,8 +1887,8 @@ func TestInsertInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(math.MaxInt8), int64(math.MaxInt16), int64(math.MaxInt32), int64(math.MaxInt64),
int64(math.MaxUint8), int64(math.MaxUint16), int64(math.MaxUint32), uint64(math.MaxUint64),
int64(999), int8(math.MaxInt8), int16(math.MaxInt16), int32(math.MaxInt32), int64(math.MaxInt64),
uint8(math.MaxUint8), uint16(math.MaxUint16), uint32(math.MaxUint32), uint64(math.MaxUint64),
float64(math.MaxFloat32), float64(math.MaxFloat64),
timeParse(sql.TimestampLayout, "2132-04-05 12:51:36"), timeParse(sql.DateLayout, "2231-11-07"),
"random text", true, `{"key":"value"}`, "blobdata",
Expand All @@ -1905,8 +1905,8 @@ func TestInsertInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(math.MaxInt8), int64(math.MaxInt16), int64(math.MaxInt32), int64(math.MaxInt64),
int64(math.MaxUint8), int64(math.MaxUint16), int64(math.MaxUint32), uint64(math.MaxUint64),
int64(999), int8(math.MaxInt8), int16(math.MaxInt16), int32(math.MaxInt32), int64(math.MaxInt64),
uint8(math.MaxUint8), uint16(math.MaxUint16), uint32(math.MaxUint32), uint64(math.MaxUint64),
float64(math.MaxFloat32), float64(math.MaxFloat64),
timeParse(sql.TimestampLayout, "2132-04-05 12:51:36"), timeParse(sql.DateLayout, "2231-11-07"),
"random text", true, `{"key":"value"}`, "blobdata",
Expand All @@ -1923,8 +1923,8 @@ func TestInsertInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(-math.MaxInt8 - 1), int64(-math.MaxInt16 - 1), int64(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
int64(0), int64(0), int64(0), int64(0),
int64(999), int8(-math.MaxInt8 - 1), int16(-math.MaxInt16 - 1), int32(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
uint8(0), uint16(0), uint32(0), uint64(0),
float64(math.SmallestNonzeroFloat32), float64(math.SmallestNonzeroFloat64),
timeParse(sql.TimestampLayout, "0010-04-05 12:51:36"), timeParse(sql.DateLayout, "0101-11-07"),
"", false, ``, "",
Expand All @@ -1941,8 +1941,8 @@ func TestInsertInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(-math.MaxInt8 - 1), int64(-math.MaxInt16 - 1), int64(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
int64(0), int64(0), int64(0), int64(0),
int64(999), int8(-math.MaxInt8 - 1), int16(-math.MaxInt16 - 1), int32(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
uint8(0), uint16(0), uint32(0), uint64(0),
float64(math.SmallestNonzeroFloat32), float64(math.SmallestNonzeroFloat64),
timeParse(sql.TimestampLayout, "0010-04-05 12:51:36"), timeParse(sql.DateLayout, "0101-11-07"),
"", false, ``, "",
Expand Down Expand Up @@ -2087,8 +2087,8 @@ func TestReplaceInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(math.MaxInt8), int64(math.MaxInt16), int64(math.MaxInt32), int64(math.MaxInt64),
int64(math.MaxUint8), int64(math.MaxUint16), int64(math.MaxUint32), uint64(math.MaxUint64),
int64(999), int8(math.MaxInt8), int16(math.MaxInt16), int32(math.MaxInt32), int64(math.MaxInt64),
uint8(math.MaxUint8), uint16(math.MaxUint16), uint32(math.MaxUint32), uint64(math.MaxUint64),
float64(math.MaxFloat32), float64(math.MaxFloat64),
timeParse(sql.TimestampLayout, "2132-04-05 12:51:36"), timeParse(sql.DateLayout, "2231-11-07"),
"random text", true, `{"key":"value"}`, "blobdata",
Expand All @@ -2105,8 +2105,8 @@ func TestReplaceInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(math.MaxInt8), int64(math.MaxInt16), int64(math.MaxInt32), int64(math.MaxInt64),
int64(math.MaxUint8), int64(math.MaxUint16), int64(math.MaxUint32), uint64(math.MaxUint64),
int64(999), int8(math.MaxInt8), int16(math.MaxInt16), int32(math.MaxInt32), int64(math.MaxInt64),
uint8(math.MaxUint8), uint16(math.MaxUint16), uint32(math.MaxUint32), uint64(math.MaxUint64),
float64(math.MaxFloat32), float64(math.MaxFloat64),
timeParse(sql.TimestampLayout, "2132-04-05 12:51:36"), timeParse(sql.DateLayout, "2231-11-07"),
"random text", true, `{"key":"value"}`, "blobdata",
Expand All @@ -2123,8 +2123,8 @@ func TestReplaceInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(-math.MaxInt8 - 1), int64(-math.MaxInt16 - 1), int64(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
int64(0), int64(0), int64(0), int64(0),
int64(999), int8(-math.MaxInt8 - 1), int16(-math.MaxInt16 - 1), int32(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
uint8(0), uint16(0), uint32(0), uint64(0),
float64(math.SmallestNonzeroFloat32), float64(math.SmallestNonzeroFloat64),
timeParse(sql.TimestampLayout, "0010-04-05 12:51:36"), timeParse(sql.DateLayout, "0101-11-07"),
"", false, ``, "",
Expand All @@ -2141,8 +2141,8 @@ func TestReplaceInto(t *testing.T) {
[]sql.Row{{int64(1)}},
"SELECT * FROM typestable WHERE id = 999;",
[]sql.Row{{
int64(999), int64(-math.MaxInt8 - 1), int64(-math.MaxInt16 - 1), int64(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
int64(0), int64(0), int64(0), int64(0),
int64(999), int8(-math.MaxInt8 - 1), int16(-math.MaxInt16 - 1), int32(-math.MaxInt32 - 1), int64(-math.MaxInt64 - 1),
uint8(0), uint16(0), uint32(0), uint64(0),
float64(math.SmallestNonzeroFloat32), float64(math.SmallestNonzeroFloat64),
timeParse(sql.TimestampLayout, "0010-04-05 12:51:36"), timeParse(sql.DateLayout, "0101-11-07"),
"", false, ``, "",
Expand Down Expand Up @@ -2947,7 +2947,7 @@ func TestSessionVariables(t *testing.T) {
rows, err := sql.RowIterToRows(iter)
require.NoError(err)

require.Equal([]sql.Row{{int64(1), ",STRICT_TRANS_TABLES"}}, rows)
require.Equal([]sql.Row{{int8(1), ",STRICT_TRANS_TABLES"}}, rows)
}

func TestSessionVariablesONOFF(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/sockstate/netstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
const (
pathTCP4Tab = "/proc/net/tcp"
pathTCP6Tab = "/proc/net/tcp6"
ipv4StrLen = 8
ipv6StrLen = 32
ipv4StrLen = 8
ipv6StrLen = 32
)

type procFd struct {
Expand Down
24 changes: 24 additions & 0 deletions sql/expression/function/ceil_round_floor.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ func (r *Round) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
dVal = float64(dNum)
case int32:
dVal = float64(dNum)
case int16:
dVal = float64(dNum)
case int8:
dVal = float64(dNum)
case uint64:
dVal = float64(dNum)
case uint32:
dVal = float64(dNum)
case uint16:
dVal = float64(dNum)
case uint8:
dVal = float64(dNum)
case int:
dVal = float64(dNum)
default:
Expand Down Expand Up @@ -233,6 +245,18 @@ func (r *Round) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
return int64(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case int32:
return int32(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case int16:
return int16(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case int8:
return int8(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case uint64:
return uint64(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case uint32:
return uint32(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case uint16:
return uint16(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case uint8:
return uint8(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
case int:
return int(math.Round(float64(xNum)*math.Pow(10.0, dVal)) / math.Pow(10.0, dVal)), nil
default:
Expand Down
44 changes: 44 additions & 0 deletions sql/expression/function/ceil_round_floor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,50 @@ func TestRound(t *testing.T) {
{"int32 with float d", sql.Int32, sql.Float64, sql.NewRow(int32(5), float32(2.123)), int32(5), nil},
{"int32 with float negative d", sql.Int32, sql.Float64, sql.NewRow(int32(52), float32(-1)), int32(50), nil},
{"int32 with blob d", sql.Int32, sql.Blob, sql.NewRow(int32(5), []byte{1, 2, 3}), int32(5), nil},
{"int16 is nil", sql.Int16, sql.Int16, sql.NewRow(nil, nil), nil, nil},
{"int16 without d", sql.Int16, sql.Int16, sql.NewRow(int16(5), nil), int16(5), nil},
{"int16 with d", sql.Int16, sql.Int16, sql.NewRow(int16(5), 2), int16(5), nil},
{"int16 with negative d", sql.Int16, sql.Int16, sql.NewRow(int16(52), -1), int16(50), nil},
{"int16 with float d", sql.Int16, sql.Float64, sql.NewRow(int16(5), float32(2.123)), int16(5), nil},
{"int16 with float negative d", sql.Int16, sql.Float64, sql.NewRow(int16(52), float32(-1)), int16(50), nil},
{"int16 with blob d", sql.Int16, sql.Blob, sql.NewRow(int16(5), []byte{1, 2, 3}), int16(5), nil},
{"int8 is nil", sql.Int8, sql.Int8, sql.NewRow(nil, nil), nil, nil},
{"int8 without d", sql.Int8, sql.Int8, sql.NewRow(int8(5), nil), int8(5), nil},
{"int8 with d", sql.Int8, sql.Int8, sql.NewRow(int8(5), 2), int8(5), nil},
{"int8 with negative d", sql.Int8, sql.Int8, sql.NewRow(int8(52), -1), int8(50), nil},
{"int8 with float d", sql.Int8, sql.Float64, sql.NewRow(int8(5), float32(2.123)), int8(5), nil},
{"int8 with float negative d", sql.Int8, sql.Float64, sql.NewRow(int8(52), float32(-1)), int8(50), nil},
{"int8 with blob d", sql.Int8, sql.Blob, sql.NewRow(int8(5), []byte{1, 2, 3}), int8(5), nil},
{"uint64 is nil", sql.Uint64, sql.Int32, sql.NewRow(nil, nil), nil, nil},
{"uint64 without d", sql.Uint64, sql.Int32, sql.NewRow(uint64(5), nil), uint64(5), nil},
{"uint64 with d", sql.Uint64, sql.Int32, sql.NewRow(uint64(5), 2), uint64(5), nil},
{"uint64 with negative d", sql.Uint64, sql.Int32, sql.NewRow(uint64(52), -1), uint64(50), nil},
{"uint64 with float d", sql.Uint64, sql.Float64, sql.NewRow(uint64(5), float32(2.123)), uint64(5), nil},
{"uint64 with float negative d", sql.Uint64, sql.Float64, sql.NewRow(uint64(52), float32(-1)), uint64(50), nil},
{"uint32 with blob d", sql.Uint32, sql.Blob, sql.NewRow(uint32(5), []byte{1, 2, 3}), uint32(5), nil},
{"uint32 is nil", sql.Uint32, sql.Int32, sql.NewRow(nil, nil), nil, nil},
{"uint32 without d", sql.Uint32, sql.Int32, sql.NewRow(uint32(5), nil), uint32(5), nil},
{"uint32 with d", sql.Uint32, sql.Int32, sql.NewRow(uint32(5), 2), uint32(5), nil},
{"uint32 with negative d", sql.Uint32, sql.Int32, sql.NewRow(uint32(52), -1), uint32(50), nil},
{"uint32 with float d", sql.Uint32, sql.Float64, sql.NewRow(uint32(5), float32(2.123)), uint32(5), nil},
{"uint32 with float negative d", sql.Uint32, sql.Float64, sql.NewRow(uint32(52), float32(-1)), uint32(50), nil},
{"uint32 with blob d", sql.Uint32, sql.Blob, sql.NewRow(uint32(5), []byte{1, 2, 3}), uint32(5), nil},
{"uint16 with blob d", sql.Uint16, sql.Blob, sql.NewRow(uint16(5), []byte{1, 2, 3}), uint16(5), nil},
{"uint16 is nil", sql.Uint16, sql.Int16, sql.NewRow(nil, nil), nil, nil},
{"uint16 without d", sql.Uint16, sql.Int16, sql.NewRow(uint16(5), nil), uint16(5), nil},
{"uint16 with d", sql.Uint16, sql.Int16, sql.NewRow(uint16(5), 2), uint16(5), nil},
{"uint16 with negative d", sql.Uint16, sql.Int16, sql.NewRow(uint16(52), -1), uint16(50), nil},
{"uint16 with float d", sql.Uint16, sql.Float64, sql.NewRow(uint16(5), float32(2.123)), uint16(5), nil},
{"uint16 with float negative d", sql.Uint16, sql.Float64, sql.NewRow(uint16(52), float32(-1)), uint16(50), nil},
{"uint16 with blob d", sql.Uint16, sql.Blob, sql.NewRow(uint16(5), []byte{1, 2, 3}), uint16(5), nil},
{"uint8 with blob d", sql.Uint8, sql.Blob, sql.NewRow(uint8(5), []byte{1, 2, 3}), uint8(5), nil},
{"uint8 is nil", sql.Uint8, sql.Int8, sql.NewRow(nil, nil), nil, nil},
{"uint8 without d", sql.Uint8, sql.Int8, sql.NewRow(uint8(5), nil), uint8(5), nil},
{"uint8 with d", sql.Uint8, sql.Int8, sql.NewRow(uint8(5), 2), uint8(5), nil},
{"uint8 with negative d", sql.Uint8, sql.Int8, sql.NewRow(uint8(52), -1), uint8(50), nil},
{"uint8 with float d", sql.Uint8, sql.Float64, sql.NewRow(uint8(5), float32(2.123)), uint8(5), nil},
{"uint8 with float negative d", sql.Uint8, sql.Float64, sql.NewRow(uint8(52), float32(-1)), uint8(50), nil},
{"uint8 with blob d", sql.Uint8, sql.Blob, sql.NewRow(uint8(5), []byte{1, 2, 3}), uint8(5), nil},
{"blob is nil", sql.Blob, sql.Int32, sql.NewRow(nil, nil), nil, nil},
{"blob is ok", sql.Blob, sql.Int32, sql.NewRow([]byte{1, 2, 3}, nil), int32(0), nil},
{"text int without d", sql.Text, sql.Int32, sql.NewRow("5", nil), int32(5), nil},
Expand Down
6 changes: 4 additions & 2 deletions sql/expression/function/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ func (d *YearWeek) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
return nil, err
}
if val != nil {
if mode, ok = val.(int64); ok {
mode %= 8 // mode in [0, 7]
if i64, err := sql.Int64.Convert(val); err == nil {
if mode, ok = i64.(int64); ok {
mode %= 8 // mode in [0, 7]
}
}
}
yyyy, week := calcWeek(yyyy, mm, dd, weekMode(mode)|weekBehaviourYear)
Expand Down
76 changes: 76 additions & 0 deletions sql/index/pilosa/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,14 @@ func decodeGob(k []byte, value interface{}) (interface{}, error) {
var v string
err := decoder.Decode(&v)
return v, err
case int8:
var v int8
err := decoder.Decode(&v)
return v, err
case int16:
var v int16
err := decoder.Decode(&v)
return v, err
case int32:
var v int32
err := decoder.Decode(&v)
Expand All @@ -629,6 +637,14 @@ func decodeGob(k []byte, value interface{}) (interface{}, error) {
var v int64
err := decoder.Decode(&v)
return v, err
case uint8:
var v uint8
err := decoder.Decode(&v)
return v, err
case uint16:
var v uint16
err := decoder.Decode(&v)
return v, err
case uint32:
var v uint32
err := decoder.Decode(&v)
Expand Down Expand Up @@ -688,6 +704,36 @@ func compare(a, b interface{}) (int, error) {
}

return strings.Compare(a, v), nil
case int8:
v, ok := b.(int8)
if !ok {
return 0, errTypeMismatch.New(a, b)
}

if a == v {
return 0, nil
}

if a < v {
return -1, nil
}

return 1, nil
case int16:
v, ok := b.(int16)
if !ok {
return 0, errTypeMismatch.New(a, b)
}

if a == v {
return 0, nil
}

if a < v {
return -1, nil
}

return 1, nil
case int32:
v, ok := b.(int32)
if !ok {
Expand Down Expand Up @@ -717,6 +763,36 @@ func compare(a, b interface{}) (int, error) {
return -1, nil
}

return 1, nil
case uint8:
v, ok := b.(uint8)
if !ok {
return 0, errTypeMismatch.New(a, b)
}

if a == v {
return 0, nil
}

if a < v {
return -1, nil
}

return 1, nil
case uint16:
v, ok := b.(uint16)
if !ok {
return 0, errTypeMismatch.New(a, b)
}

if a == v {
return 0, nil
}

if a < v {
return -1, nil
}

return 1, nil
case uint32:
v, ok := b.(uint32)
Expand Down
Loading