bit|varbit #, xor operator - Mailing list pgsql-hackers

From Jim Nasby
Subject bit|varbit #, xor operator
Date
Msg-id 2826f2a9-f622-2572-8132-4083cf0a3f42@BlueTreble.com
Whole thread Raw
Responses Re: bit|varbit #, xor operator  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Related to [1], I want to add an operator that returns the count of set 
(or unset) bits in a bit|varbit input. Given the number of times people 
ask "how can I get a count of NULL fields" and similar, I expect this to 
become quite popular. The obvious choice would be to use #, but I was 
rather surprised to discover # is already used for XOR.

I think ^ is a pretty standard convention for XOR, but I can understand 
why we wouldn't want to just use that. But I also think the choice of # 
is pretty unfortunate.

# is currently mixed between XOR and counting[2]. IMHO we should 
disambiguate it. My bet is that the XOR versions are very seldom used 
and could be renamed without much grumbling. The versions that actually 
do counting are presumably more popular. I'm not sure about the 
intersection versions.

Personally I think it was a mistake to use # for intersection. Range 
doesn't do that (using * instead), and AFAICT PostGIS doesn't either 
(preferring &). So I propose renaming those operators, as well as the 
XOR ones. I think ^^ is pretty logical for XOR. I'm not sure about 
intersect... * doesn't seem like a good idea, && is overlaps, maybe &*.

Related to this I'd also like to add a boolean XOR operator as that's a 
relatively common request/question.

1: 
https://www.postgresql.org/message-id/9f1db94a-fa18-5975-3a6c-6850fabb3865%40BlueTreble.com
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461



pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Question on "record type has not been registered"
Next
From: Jeff Janes
Date:
Subject: Re: VACUUM's ancillary tasks