Skip to content

Commit ccb2007

Browse files
committed
update or add IsNullable implementation for log and math functions
1 parent 0b1008f commit ccb2007

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

sql/expression/function/logarithm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (*LogBase) CollationCoercibility(ctx *sql.Context) (collation sql.Collation
112112

113113
// IsNullable implements the sql.Expression interface.
114114
func (l *LogBase) IsNullable() bool {
115-
return l.base == float64(1) || l.base <= float64(0) || l.Child.IsNullable()
115+
return true
116116
}
117117

118118
// Eval implements the Expression interface.
@@ -196,7 +196,7 @@ func (*Log) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
196196

197197
// IsNullable implements the Expression interface.
198198
func (l *Log) IsNullable() bool {
199-
return l.LeftChild.IsNullable() || l.RightChild.IsNullable()
199+
return true
200200
}
201201

202202
// Eval implements the Expression interface.

sql/expression/function/math.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ func (*Tan) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
268268
return sql.Collation_binary, 5
269269
}
270270

271+
// IsNullable implements sql.Expression
272+
func (t *Tan) IsNullable() bool {
273+
return true
274+
}
275+
271276
// Eval implements sql.Expression
272277
func (t *Tan) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
273278
val, err := t.EvalChild(ctx, row)
@@ -325,6 +330,11 @@ func (*Asin) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
325330
return sql.Collation_binary, 5
326331
}
327332

333+
// IsNullable implements sql.Expression
334+
func (a *Asin) IsNullable() bool {
335+
return true
336+
}
337+
328338
// Eval implements sql.Expression
329339
func (a *Asin) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
330340
val, err := a.EvalChild(ctx, row)
@@ -382,6 +392,11 @@ func (*Acos) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
382392
return sql.Collation_binary, 5
383393
}
384394

395+
// IsNullable implements sql.Expression
396+
func (a *Acos) IsNullable() bool {
397+
return true
398+
}
399+
385400
// Eval implements sql.Expression
386401
func (a *Acos) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
387402
val, err := a.EvalChild(ctx, row)
@@ -559,6 +574,11 @@ func (*Cot) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID,
559574
return sql.Collation_binary, 5
560575
}
561576

577+
// IsNullable implements sql.Expression
578+
func (c *Cot) IsNullable() bool {
579+
return true
580+
}
581+
562582
// Eval implements sql.Expression
563583
func (c *Cot) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
564584
val, err := c.EvalChild(ctx, row)
@@ -991,6 +1011,11 @@ func (e *Exp) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID
9911011
return sql.Collation_binary, 5
9921012
}
9931013

1014+
// IsNullable implements sql.Expression
1015+
func (e *Exp) IsNullable() bool {
1016+
return true
1017+
}
1018+
9941019
// Eval implements the Expression interface.
9951020
func (e *Exp) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
9961021
if e.Child == nil {

0 commit comments

Comments
 (0)