[MDEV-21805] bit_and returns garbage on empty set Created: 2020-02-24  Updated: 2020-03-04  Resolved: 2020-03-04

Status: Closed
Project: MariaDB Server
Component/s: Data types, Documentation
Affects Version/s: 10.1.26, 10.3.22
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Johan Björklund Assignee: Ian Gilfillan
Resolution: Fixed Votes: 0
Labels: None
Environment:

linux



 Description   

To reproduce:

create table bitsbug (s Boolean) engine=heap;
select bit_and(s) from bitsbug;
+----------------------+
| bit_and(s)           |
+----------------------+
| 18446744073709551615 |
+----------------------+
 
insert into bitsbug values (null);
select bit_and(s) from bitsbug;
+----------------------+
| bit_and(s)           |
+----------------------+
| 18446744073709551615 |
+----------------------+
 
insert into bitsbug values (0);
select bit_and(s) from bitsbug;
+------------+
| bit_and(s) |
+------------+
|          0 |
+------------+



 Comments   
Comment by Elena Stepanova [ 2020-02-24 ]

According to MySQL manual, it is the expected behavior:

If there are no matching rows, BIT_AND() returns a neutral value (all bits set to 1) having the same length as the argument values.

NULL values do not affect the result unless all values are NULL. In that case, the result is a neutral value having the same length as the argument values.

However, MariaDB documentation doesn't say anything, it needs to be updated.

Generated at Thu Feb 08 09:09:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.