Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions enginetest/queries/script_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ var ScriptTests = []ScriptTest{
"INSERT INTO t2(c0) VALUES (-32768);",
"CREATE TABLE t3(c0 TINYINT);",
"INSERT INTO t3(c0) VALUES (-128);",
"CREATE TABLE tab1 (col4 INT)",
"INSERT INTO tab1 VALUES (10), (20), (30)",
},
Assertions: []ScriptTestAssertion{
{
Expand Down Expand Up @@ -311,6 +313,10 @@ var ScriptTests = []ScriptTest{
Expected: []sql.Row{{int64(-128)}},
ExpectedColumns: sql.Schema{{Name: "-(-CAST(-128 AS SIGNED))", Type: types.Int64}},
},
{
Query: "SELECT * FROM tab1 AS cor0 WHERE NOT - CAST(NULL AS SIGNED) < +35 * +col4 + - -39",
Expected: []sql.Row{},
},
},
},
{
Expand Down
5 changes: 3 additions & 2 deletions sql/expression/arithmetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,9 @@ func (e *UnaryMinus) Type() sql.Type {
typ = types.Int64
case types.Int64:
if lit, ok := e.Child.(*Literal); ok {
if lit.Value().(int64) == math.MinInt64 {
typ = types.InternalDecimalType
// nil val at this stage is possible on NULL cast
if v, ok := lit.Value().(int64); ok && v == math.MinInt64 {
return types.InternalDecimalType
}
}
}
Expand Down