Skip to content

Commit fb6c836

Browse files
committed
Fix CHAR(0) to return null byte instead of empty byte array
CHAR(0) should return a single null byte (\0) not an empty byte array. This was exposed by string-to-number conversion changes that now correctly convert empty strings to 0 instead of erroring. Before: CHAR('') -> error path -> append null byte After: CHAR('') -> converts to 0 -> CHAR(0) -> should return null byte Fixes the failing test: select if('', 1, char(''))
1 parent e145143 commit fb6c836

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/expression/function/char.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (c *Char) CollationCoercibility(ctx *sql.Context) (collation sql.CollationI
8989
// This function is essentially converting the number to base 256
9090
func char(num uint32) []byte {
9191
if num == 0 {
92-
return []byte{}
92+
return []byte{0}
9393
}
9494
return append(char(num>>8), byte(num&255))
9595
}

0 commit comments

Comments
 (0)