On Tue, 2 Mar 2021 at 00:06, Joel Jacobson <j...@compiler.org> wrote:
> I find it strange two ranges of zero-length with different bounds are > considered equal: > > SELECT '[7,7)'::int4range = '[8,8)'::int4range; > ?column? > ---------- > t > (1 row) > > This seems like a bug to me. What am I missing here? > > Unless fixed, then the way I see it, I don't think we can use int4range[] > for regexp_positions(), > if we want to allow returning the positions for zero-length matches, which > would be nice. > Ranges are treated as sets. As such equality is defined by membership. That being said, I agree that there may be situations in which it would be convenient to have empty ranges at specific locations. Doing this would introduce numerous questions which would have to be resolved. For example, where/when is the empty range resulting from an intersection operation?