Re: Improve examples for range operators

Bruce Momjian <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <[email protected]>
On Wed, Feb 20, 2019 at 12:27:26PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/11/functions-range.html
> Description:
> 
> Hi.
> 
> It would be nice if next examples:
> 
> << 	strictly left of 	int8range(1,10) << int8range(100,110) 	t
> >> 	strictly right of 	int8range(50,60) >> int8range(20,30) 	t
> &< 	does not extend to the right of 	int8range(1,20) &< int8range(18,20)
> 	t
> &> 	does not extend to the left of 	int8range(7,20) &> int8range(5,10) 	t
> 
> are extended by:
> **not** strictly left of, **not** strictly right of, **extends** to the
> right of, **extends** to the left of
> 
> Because without manual experiments I can not imagine the ranges that cause
> 'false' result for the examples above.

Well, they are not technically negatives of each other.  << means the
first is all left of the second, while &< means that it doesn't go to
the right of the second, e.g.,

	SELECT int8range(1,10) &< int8range(100,110);
	 ?column?
	----------
	 t
	
	SELECT int8range(1,105) &< int8range(100,110);
	 ?column?
	----------
	 t
	
	SELECT int8range(1,200) &< int8range(100,110);
	 ?column?
	----------
	 f

Notice it changed from true to false and none of these was strictly to
the right.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.