head	1.23;
access;
symbols
	REL7_1:1.22
	REL7_0_PATCHES:1.16.0.2
	REL7_0:1.16
	REL6_5_PATCHES:1.11.0.2
	REL6_5:1.11
	REL6_4:1.5.0.2;
locks; strict;
comment	@# @;


1.23
date	2000.12.14.22.30.56;	author petere;	state dead;
branches;
next	1.22;

1.22
date	2000.11.10.20.13.25;	author tgl;	state Exp;
branches;
next	1.21;

1.21
date	2000.10.24.20.13.31;	author petere;	state Exp;
branches;
next	1.20;

1.20
date	2000.10.04.15.47.45;	author petere;	state Exp;
branches;
next	1.19;

1.19
date	2000.09.29.20.21.34;	author petere;	state Exp;
branches;
next	1.18;

1.18
date	2000.09.15.20.20.11;	author tgl;	state Exp;
branches;
next	1.17;

1.17
date	2000.08.12.05.15.24;	author tgl;	state Exp;
branches;
next	1.16;

1.16
date	2000.05.02.20.01.52;	author thomas;	state Exp;
branches;
next	1.15;

1.15
date	2000.03.31.03.27.41;	author thomas;	state Exp;
branches;
next	1.14;

1.14
date	2000.03.20.04.19.47;	author tgl;	state Exp;
branches;
next	1.13;

1.13
date	2000.01.24.02.12.53;	author momjian;	state Exp;
branches;
next	1.12;

1.12
date	99.07.22.15.11.04;	author thomas;	state Exp;
branches;
next	1.11;

1.11
date	99.05.12.07.32.46;	author thomas;	state Exp;
branches;
next	1.10;

1.10
date	99.03.20.00.15.40;	author momjian;	state Exp;
branches;
next	1.9;

1.9
date	99.03.17.21.38.13;	author momjian;	state Exp;
branches;
next	1.8;

1.8
date	99.03.17.21.27.02;	author momjian;	state Exp;
branches;
next	1.7;

1.7
date	99.03.17.21.24.17;	author momjian;	state Exp;
branches;
next	1.6;

1.6
date	98.12.29.02.24.18;	author thomas;	state Exp;
branches;
next	1.5;

1.5
date	98.10.27.06.14.41;	author thomas;	state Exp;
branches;
next	1.4;

1.4
date	98.10.14.16.28.31;	author thomas;	state Exp;
branches;
next	1.3;

1.3
date	98.09.30.05.41.48;	author thomas;	state Exp;
branches;
next	1.2;

1.2
date	98.07.29.06.32.46;	author thomas;	state Exp;
branches;
next	1.1;

1.1
date	98.07.08.13.53.14;	author thomas;	state Exp;
branches;
next	;


desc
@@


1.23
log
@Merge functions and operators chapters.  Lots of updates.
@
text
@<!--
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.22 2000/11/10 20:13:25 tgl Exp $
-->

 <Chapter Id="operators">
  <Title id="operators-title">Operators</Title>

  <Abstract>
   <Para>
    Describes the built-in operators available in 
    <ProductName>Postgres</ProductName>.
   </Para>
  </Abstract>

  <Para>
   <ProductName>Postgres</ProductName> provides a large number of 
   built-in operators on system types.
   These operators are declared in the system catalog
   <literal>pg_operator</literal>.  Every entry in <literal>pg_operator</literal> includes
   the name of the procedure that implements the operator and the
   class <Acronym>OIDs</Acronym> of the input and output types.
  </Para>

  <Para>
   To view all variations of the "<literal>||</literal>" string concatenation operator, 
   try
   <ProgramListing>
    SELECT oprleft, oprright, oprresult, oprcode
    FROM pg_operator WHERE oprname = '||';

oprleft|oprright|oprresult|oprcode
-------+--------+---------+-------
     25|      25|       25|textcat
   1042|    1042|     1042|textcat
   1043|    1043|     1043|textcat
(3 rows)
   </ProgramListing>
  </Para>

  <Para>
   Users may invoke operators using the operator name, as in:

   <ProgramListing>
select * from emp where salary < 40000;
   </ProgramListing>

   Alternatively, users may call the functions that implement the
   operators directly.  In this case, the query above would be expressed
   as:
   <ProgramListing>
select * from emp where int4lt(salary, 40000);
   </ProgramListing>
  </Para>

  <Para>
   <Application>psql</Application>
   has a command (<Command>\dd</Command>) to show these operators.
  </Para>

  <sect1 id="oper-precedence">
   <title>Lexical Precedence</title>

   <para>
    Operators have a precedence which is currently hardcoded into the parser.
    Most operators have the same precedence and are left-associative. This may lead
    to non-intuitive behavior; for example the boolean operators "&lt;" and "&gt;"
    have a different precedence than the boolean operators "&lt;=" and "&gt;=".

<table tocentry="1">
<title>
Operator Ordering (decreasing precedence)
</title>

<tgroup cols="2">
<thead>
<row>
<entry>Element</entry>
<entry>Precedence</entry>
<entry>Description</entry>
</row>
</thead>

<tbody>
<row>
<entry>
::
</entry>
<entry>
left
</entry>
<entry>
<productname>Postgres</productname> typecasting
</entry>
</row>
<row>
<entry>
[ ]
</entry>
<entry>
left
</entry>
<entry>
array delimiters
</entry>
</row>
<row>
<entry>
.
</entry>
<entry>
left
</entry>
<entry>
table/column delimiter
</entry>
</row>
<row>
<entry>
-
</entry>
<entry>
right
</entry>
<entry>
unary minus
</entry>
</row>
<row>
<entry>
|
</entry>
<entry>
left
</entry>
<entry>
start of interval
</entry>
</row>
<row>
<entry>
^
</entry>
<entry>
left
</entry>
<entry>
power, exclusive or
</entry>
</row>
<row>
<entry>
* / %
</entry>
<entry>
left
</entry>
<entry>
multiplication, division, modulo
</entry>
</row>
<row>
<entry>
+ -
</entry>
<entry>
left
</entry>
<entry>
addition, subtraction
</entry>
</row>
<row>
<entry>
IS
</entry>
<entry>
</entry>
<entry>
test for TRUE, FALSE, NULL
</entry>
</row>
<row>
<entry>
ISNULL
</entry>
<entry>
</entry>
<entry>
test for NULL
</entry>
</row>
<row>
<entry>
NOTNULL
</entry>
<entry>
</entry>
<entry>
test for NOT NULL
</entry>
</row>
<row>
<entry>
(all other operators)
</entry>
<entry>
left
</entry>
<entry>
native and user-defined
</entry>
</row>
<row>
<entry>
IN
</entry>
<entry>
</entry>
<entry>
set membership
</entry>
</row>
<row>
<entry>
BETWEEN
</entry>
<entry>
</entry>
<entry>
containment
</entry>
</row>
<row>
<entry>
OVERLAPS
</entry>
<entry>
</entry>
<entry>
time interval overlap
</entry>
</row>
<row>
<entry>
LIKE ILIKE
</entry>
<entry>
</entry>
<entry>
string pattern matching
</entry>
</row>
<row>
<entry>
&lt; &gt;
</entry>
<entry>
</entry>
<entry>
inequality
</entry>
</row>
<row>
<entry>
=
</entry>
<entry>
right
</entry>
<entry>
equality
</entry>
</row>
<row>
<entry>
NOT
</entry>
<entry>
right
</entry>
<entry>
logical negation
</entry>
</row>
<row>
<entry>
AND
</entry>
<entry>
left
</entry>
<entry>
logical intersection
</entry>
</row>
<row>
<entry>
OR
</entry>
<entry>
left
</entry>
<entry>
logical union
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</sect1>

  <sect1 id="general-operators">
   <title>General Operators</title>

   <para>
    The operators listed here are defined for a number of native data types, 
    ranging from numeric types to data/time types.
   </para>

   <Para>
    <TABLE TOCENTRY="1">
     <TITLE><ProductName>Postgres</ProductName> Operators</TITLE>
     <TITLEABBREV>Operators</TITLEABBREV>
     <TGROUP COLS="3">
      <THEAD>
       <ROW>
	<ENTRY>Operator</ENTRY>
	<ENTRY>Description</ENTRY>
	<ENTRY>Usage</ENTRY>
       </ROW>
      </THEAD>
      <TBODY>
       <ROW>
	<ENTRY> &lt; </ENTRY>
	<ENTRY>Less than?</ENTRY>
	<ENTRY>1 &lt; 2</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;= </ENTRY>
	<ENTRY>Less than or equal to?</ENTRY>
	<ENTRY>1 &lt;= 2</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&gt; </ENTRY>
	<ENTRY>Not equal?</ENTRY>
	<ENTRY>1 &lt;&gt; 2</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> = </ENTRY>
	<ENTRY>Equal?</ENTRY>
	<ENTRY>1 = 1</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt; </ENTRY>
	<ENTRY>Greater than?</ENTRY>
	<ENTRY>2 &gt; 1</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;= </ENTRY>
	<ENTRY>Greater than or equal to?</ENTRY>
	<ENTRY>2 &gt;= 1</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> || </ENTRY>
	<ENTRY>Concatenate strings</ENTRY>
	<ENTRY>'Postgre' || 'SQL'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> !!= </ENTRY>
	<ENTRY>NOT IN</ENTRY>
	<ENTRY>3 !!= i</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~~ </ENTRY>
	<ENTRY>LIKE</ENTRY>
	<ENTRY>'scrappy,marc,hermit' ~~ '%scrappy%'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> !~~ </ENTRY>
	<ENTRY>NOT LIKE</ENTRY>
	<ENTRY>'bruce' !~~ '%al%'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~~* </ENTRY>
	<ENTRY>ILIKE</ENTRY>
	<ENTRY>'scrappy,marc,hermit' ~~* '%Scrappy%'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> !~~* </ENTRY>
	<ENTRY>NOT ILIKE</ENTRY>
	<ENTRY>'Bruce' !~~* '%al%'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~ </ENTRY>
	<ENTRY>Match (regex), case sensitive</ENTRY>
	<ENTRY>'thomas' ~ '.*thomas.*'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~* </ENTRY>
	<ENTRY>Match (regex), case insensitive</ENTRY>
	<ENTRY>'thomas' ~* '.*Thomas.*'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> !~ </ENTRY>
	<ENTRY>Does not match (regex), case sensitive</ENTRY>
	<ENTRY>'thomas' !~ '.*Thomas.*'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> !~* </ENTRY>
	<ENTRY>Does not match (regex), case insensitive</ENTRY>
	<ENTRY>'thomas' !~* '.*vadim.*'</ENTRY>
       </ROW>
      </TBODY>
     </TGROUP>
    </TABLE>
   </Para>
  </sect1>

  <sect1 id="numerical-operators">
   <title>Numerical Operators</title>

   <Para>
    <TABLE TOCENTRY="1">
     <TITLE><ProductName>Postgres</ProductName> Numerical Operators</TITLE>
     <TITLEABBREV>Operators</TITLEABBREV>
     <TGROUP COLS="3">
      <THEAD>
       <ROW>
	<ENTRY>Operator</ENTRY>
	<ENTRY>Description</ENTRY>
	<ENTRY>Usage</ENTRY>
       </ROW>
      </THEAD>
      <TBODY>
       <ROW>
	<ENTRY> !  </ENTRY>
	<ENTRY>Factorial</ENTRY>
	<ENTRY>3 !</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> !!  </ENTRY>
	<ENTRY>Factorial (left operator)</ENTRY>
	<ENTRY>!! 3</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> % </ENTRY>
	<ENTRY>Modulo</ENTRY>
	<ENTRY>5 % 4</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> % </ENTRY>
	<ENTRY>Truncate</ENTRY>
	<ENTRY>% 4.5</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> * </ENTRY>
	<ENTRY>Multiplication</ENTRY>
	<ENTRY>2 * 3</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> + </ENTRY>
	<ENTRY>Addition</ENTRY>
	<ENTRY>2 + 3</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> - </ENTRY>
	<ENTRY>Subtraction</ENTRY>
	<ENTRY>2 - 3</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> / </ENTRY>
	<ENTRY>Division</ENTRY>
	<ENTRY>4 / 2</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> @@ </ENTRY>
	<ENTRY>Absolute value</ENTRY>
	<ENTRY>@@ -5.0</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ^ </ENTRY>
	<ENTRY>Exponentiation</ENTRY>
	<ENTRY>2.0 ^ 3.0</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> |/ </ENTRY>
	<ENTRY>Square root</ENTRY>
	<ENTRY>|/ 25.0</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ||/ </ENTRY>
	<ENTRY>Cube root</ENTRY>
	<ENTRY>||/ 27.0</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> & </ENTRY>
	<ENTRY>Binary AND</ENTRY>
	<ENTRY>91 & 15</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> | </ENTRY>
	<ENTRY>Binary OR</ENTRY>
	<ENTRY>32 | 3</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> # </ENTRY>
	<ENTRY>Binary XOR</ENTRY>
	<ENTRY>15 # 4</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~ </ENTRY>
	<ENTRY>Binary NOT</ENTRY>
	<ENTRY>~1</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt; </ENTRY>
	<ENTRY>Binary shift left</ENTRY>
	<ENTRY>1 &lt;&lt; 4</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;&gt; </ENTRY>
	<ENTRY>Binary shift right</ENTRY>
	<ENTRY>8 &gt;&gt; 2</ENTRY>
       </ROW>
      </TBODY>
     </TGROUP>
    </TABLE>
   </Para>
  </sect1>

  <sect1 id="geometric-operators">
   <title>Geometric Operators</title>

   <Para>
    <TABLE TOCENTRY="1">
     <TITLE><ProductName>Postgres</ProductName> Geometric Operators</TITLE>
     <TITLEABBREV>Operators</TITLEABBREV>
     <TGROUP COLS="3">
      <THEAD>
       <ROW>
	<ENTRY>Operator</ENTRY>
	<ENTRY>Description</ENTRY>
	<ENTRY>Usage</ENTRY>
       </ROW>
      </THEAD>
      <TBODY>
       <ROW>
	<ENTRY> + </ENTRY>
	<ENTRY>Translation</ENTRY>
	<ENTRY>'((0,0),(1,1))'::box + '(2.0,0)'::point</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> - </ENTRY>
	<ENTRY>Translation</ENTRY>
	<ENTRY>'((0,0),(1,1))'::box - '(2.0,0)'::point</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> * </ENTRY>
	<ENTRY>Scaling/rotation</ENTRY>
	<ENTRY>'((0,0),(1,1))'::box * '(2.0,0)'::point</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> / </ENTRY>
	<ENTRY>Scaling/rotation</ENTRY>
	<ENTRY>'((0,0),(2,2))'::box / '(2.0,0)'::point</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> # </ENTRY>
	<ENTRY>Intersection</ENTRY>
	<ENTRY>'((1,-1),(-1,1))' # '((1,1),(-1,-1))'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> # </ENTRY>
	<ENTRY>Number of points in polygon</ENTRY>
	<ENTRY># '((1,0),(0,1),(-1,0))'</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ## </ENTRY>
	<ENTRY>Point of closest proximity</ENTRY>
	<ENTRY>'(0,0)'::point ## '((2,0),(0,2))'::lseg</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &amp;&amp; </ENTRY>
	<ENTRY>Overlaps?</ENTRY>
	<ENTRY>'((0,0),(1,1))'::box &amp;&amp; '((0,0),(2,2))'::box</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &amp;&lt; </ENTRY>
	<ENTRY>Overlaps to left?</ENTRY>
	<ENTRY>'((0,0),(1,1))'::box &amp;&lt; '((0,0),(2,2))'::box</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &amp;&gt; </ENTRY>
	<ENTRY>Overlaps to right?</ENTRY>
	<ENTRY>'((0,0),(3,3))'::box &amp;&gt; '((0,0),(2,2))'::box</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;-&gt; </ENTRY>
	<ENTRY>Distance between</ENTRY>
	<ENTRY>'((0,0),1)'::circle &lt;-&gt; '((5,0),1)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt; </ENTRY>
	<ENTRY>Left of?</ENTRY>
	<ENTRY>'((0,0),1)'::circle &lt;&lt; '((5,0),1)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;^ </ENTRY>
	<ENTRY>Is below?</ENTRY>
	<ENTRY>'((0,0),1)'::circle &lt;^ '((0,5),1)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;&gt; </ENTRY>
	<ENTRY>Is right of?</ENTRY>
	<ENTRY>'((5,0),1)'::circle &gt;&gt; '((0,0),1)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;^ </ENTRY>
	<ENTRY>Is above?</ENTRY>
	<ENTRY>'((0,5),1)'::circle >^ '((0,0),1)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ?# </ENTRY>
	<ENTRY>Intersects or overlaps</ENTRY>
	<ENTRY>'((-1,0),(1,0))'::lseg ?# '((-2,-2),(2,2))'::box;</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ?- </ENTRY>
	<ENTRY>Is horizontal?</ENTRY>
	<ENTRY>'(1,0)'::point ?- '(0,0)'::point</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ?-| </ENTRY>
	<ENTRY>Is perpendicular?</ENTRY>
	<ENTRY>'((0,0),(0,1))'::lseg ?-| '((0,0),(1,0))'::lseg</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> @@-@@  </ENTRY>
	<ENTRY>Length or circumference</ENTRY>
	<ENTRY>@@-@@ '((0,0),(1,0))'::path</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ?| </ENTRY>
	<ENTRY>Is vertical?</ENTRY>
	<ENTRY>'(0,1)'::point ?| '(0,0)'::point</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ?|| </ENTRY>
	<ENTRY>Is parallel?</ENTRY>
	<ENTRY>'((-1,0),(1,0))'::lseg ?|| '((-1,2),(1,2))'::lseg</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> @@ </ENTRY>
	<ENTRY>Contained or on</ENTRY>
	<ENTRY>'(1,1)'::point @@ '((0,0),2)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> @@@@ </ENTRY>
	<ENTRY>Center of</ENTRY>
	<ENTRY>@@@@ '((0,0),10)'::circle</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~= </ENTRY>
	<ENTRY>Same as</ENTRY>
	<ENTRY>'((0,0),(1,1))'::polygon ~= '((1,1),(0,0))'::polygon</ENTRY>
       </ROW>
      </TBODY>
     </TGROUP>
    </TABLE>
   </Para>
  </sect1>
  
  <sect1 id="interval-operators">
   <title>Time Interval Operators</title>
   
   <Para>
    The time interval data type <Type>tinterval</Type> is a legacy from the original
    date/time types and is not as well supported as the more modern types. There
    are several operators for this type.
    
    <TABLE TOCENTRY="1">
     <TITLE><ProductName>Postgres</ProductName> Time Interval Operators</TITLE>
     <TITLEABBREV>Operators</TITLEABBREV>
     <TGROUP COLS="3">
      <THEAD>
       <ROW>
	<ENTRY>Operator</ENTRY>
	<ENTRY>Description</ENTRY>
	<ENTRY>Usage</ENTRY>
       </ROW>
      </THEAD>
      <TBODY>
       <ROW>
	<ENTRY> #&lt; </ENTRY>
	<ENTRY>Interval less than?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> #&lt;= </ENTRY>
	<ENTRY>Interval less than or equal to?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> #&lt;&gt; </ENTRY>
	<ENTRY>Interval not equal?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> #= </ENTRY>
	<ENTRY>Interval equal?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> #&gt; </ENTRY>
	<ENTRY>Interval greater than?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> #&gt;= </ENTRY>
	<ENTRY>Interval greater than or equal to?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;#&gt; </ENTRY>
	<ENTRY>Convert to time interval</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt; </ENTRY>
	<ENTRY>Interval less than?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> | </ENTRY>
	<ENTRY>Start of interval</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> ~= </ENTRY>
	<ENTRY>Same as</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;?&gt; </ENTRY>
	<ENTRY>Time inside interval?</ENTRY>
	<ENTRY></ENTRY>
       </ROW>
      </TBODY>
     </TGROUP>
    </TABLE>
   </Para>
  </sect1>


  <sect1 id="net-operators">
   <title>Network Address Type Operators</title>

   <sect2 id="cidr-inet-operators">
    <title><type>cidr</> and <type>inet</> Operators</title>

    <table tocentry="1" id="cidr-inet-operators-table">
     <title><type>cidr</> and <type>inet</> Operators</title>
     <TGROUP COLS="3">
      <THEAD>
       <ROW>
	<ENTRY>Operator</ENTRY>
	<ENTRY>Description</ENTRY>
	<ENTRY>Usage</ENTRY>
       </ROW>
      </THEAD>
      <TBODY>
       <ROW>
	<ENTRY> &lt; </ENTRY>
	<ENTRY>Less than</ENTRY>
	<ENTRY>'192.168.1.5'::inet &lt; '192.168.1.6'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;= </ENTRY>
	<ENTRY>Less than or equal</ENTRY>
	<ENTRY>'192.168.1.5'::inet &lt;= '192.168.1.5'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> = </ENTRY>
	<ENTRY>Equals</ENTRY>
	<ENTRY>'192.168.1.5'::inet = '192.168.1.5'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;= </ENTRY>
	<ENTRY>Greater or equal</ENTRY>
	<ENTRY>'192.168.1.5'::inet &gt;= '192.168.1.5'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt; </ENTRY>
	<ENTRY>Greater</ENTRY>
	<ENTRY>'192.168.1.5'::inet &gt; '192.168.1.4'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&gt; </ENTRY>
	<ENTRY>Not equal</ENTRY>
	<ENTRY>'192.168.1.5'::inet &lt;&gt; '192.168.1.4'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt; </ENTRY>
	<ENTRY>is contained within</ENTRY>
	<ENTRY>'192.168.1.5'::inet &lt;&lt; '192.168.1/24'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt;= </ENTRY>
	<ENTRY>is contained within or equals</ENTRY>
	<ENTRY>'192.168.1/24'::inet &lt;&lt;= '192.168.1/24'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;&gt; </ENTRY>
	<ENTRY>contains</ENTRY>
	<ENTRY>'192.168.1/24'::inet &gt;&gt; '192.168.1.5'::inet</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;&gt;= </ENTRY>
	<ENTRY>contains or equals</ENTRY>
	<ENTRY>'192.168.1/24'::inet &gt;&gt;= '192.168.1/24'::inet</ENTRY>
       </ROW>
      </TBODY>
     </TGROUP>
    </TABLE>

    <para>
     All of the operators for <type>inet</type> can be applied to
     <type>cidr</type> values as well.  The operators
     <literal>&lt;&lt;</> <literal>&lt;&lt;=</>
     <literal>&gt;&gt;</> <literal>&gt;&gt;=</>
     test for subnet inclusion: they consider only the network parts
     of the two addresses, ignoring any host part, and determine whether
     one network part is identical to or a subnet of the other.
    </para>
   </sect2>

   <sect2 id="macaddr-operators">
    <title><type>macaddr</> Operators</>

    <para>
     The <type>macaddr</> type supports the standard relational
     operators (<literal>&gt;</>, <literal>&lt;=</>, etc.) for
     lexicographical ordering.
    </para>
   </sect2>

  </sect1>

 </Chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode:sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:("/usr/lib/sgml/catalog")
sgml-local-ecat-files:nil
End:
-->
@


1.22
log
@Adjust INET/CIDR display conventions and reimplement some INET/CIDR
functions, per recent discussions on pghackers.  For now, I have called
the verbose-display formatting function text(), but will reconsider if
enough people object.
initdb forced.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.21 2000/10/24 20:13:31 petere Exp $
@


1.21
log
@Integer binary operators, from Marko Kreen <marko@@l-t.ee>.  Renamed bitxor
operator to '#' for consistency.  Parser still needs work.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.20 2000/10/04 15:47:45 petere Exp $
d759 2
a760 2
   <sect2 id="cidr-operators">
    <title><type>cidr</> Operators</title>
d762 2
a763 71
    <table tocentry="1" id="cidr-operators-table">
     <title><type>cidr</> Operators</title>
     <TGROUP COLS="3">
      <THEAD>
       <ROW>
	<ENTRY>Operator</ENTRY>
	<ENTRY>Description</ENTRY>
	<ENTRY>Usage</ENTRY>
       </ROW>
      </THEAD>
      <TBODY>
       <ROW>
	<ENTRY> &lt; </ENTRY>
	<ENTRY>Less than</ENTRY>
	<ENTRY>'192.168.1.5'::cidr &lt; '192.168.1.6'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;= </ENTRY>
	<ENTRY>Less than or equal</ENTRY>
	<ENTRY>'192.168.1.5'::cidr &lt;= '192.168.1.5'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> = </ENTRY>
	<ENTRY>Equals</ENTRY>
	<ENTRY>'192.168.1.5'::cidr = '192.168.1.5'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;= </ENTRY>
	<ENTRY>Greater or equal</ENTRY>
	<ENTRY>'192.168.1.5'::cidr &gt;= '192.168.1.5'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt; </ENTRY>
	<ENTRY>Greater</ENTRY>
	<ENTRY>'192.168.1.5'::cidr &gt; '192.168.1.4'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&gt; </ENTRY>
	<ENTRY>Not equal</ENTRY>
	<ENTRY>'192.168.1.5'::cidr &lt;&gt; '192.168.1.4'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt; </ENTRY>
	<ENTRY>is contained within</ENTRY>
	<ENTRY>'192.168.1.5'::cidr &lt;&lt; '192.168.1/24'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &lt;&lt;= </ENTRY>
	<ENTRY>is contained within or equals</ENTRY>
	<ENTRY>'192.168.1/24'::cidr &lt;&lt;= '192.168.1/24'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;&gt; </ENTRY>
	<ENTRY>contains</ENTRY>
	<ENTRY>'192.168.1/24'::cidr &gt;&gt; '192.168.1.5'::cidr</ENTRY>
       </ROW>
       <ROW>
	<ENTRY> &gt;&gt;= </ENTRY>
	<ENTRY>contains or equals</ENTRY>
	<ENTRY>'192.168.1/24'::cidr &gt;&gt;= '192.168.1/24'::cidr</ENTRY>
       </ROW>
      </TBODY>
     </TGROUP>
    </TABLE>
   </sect2>

   <sect2 id="inet-operators">
   <title><type>inet</> Operators</title>
   
    <table tocentry="1" id="inet-operators-table">
     <title><type>inet</> Operators</title>
d826 10
@


1.20
log
@Convert macaddr documentation to DocBook, update outdated information.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.19 2000/09/29 20:21:34 petere Exp $
d495 30
@


1.19
log
@Add `id' attributes to all `chapter' and `sect1' tags, to generate useful
names for the HTML files (e.g., not x4856.htm).
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.18 2000/09/15 20:20:11 tgl Exp $
a724 2
  <sect1 id="cidr-operators">
   <title>IP V4 CIDR Operators</title>
d726 8
a733 4
   <Para>
    <TABLE TOCENTRY="1">
     <TITLE><ProductName>Postgres</ProductName>IP V4 CIDR Operators</TITLE>
     <TITLEABBREV>Operators</TITLEABBREV>
d796 1
a796 2
   </Para>
  </sect1>
d798 2
a799 2
  <sect1 id="inet-operators">
   <title>IP V4 INET Operators</title>
d801 2
a802 4
   <Para>
    <TABLE TOCENTRY="1">
     <TITLE><ProductName>Postgres</ProductName>IP V4 INET Operators</TITLE>
     <TITLEABBREV>Operators</TITLEABBREV>
d865 12
a876 1
   </Para>
@


1.18
log
@Add ILIKE operators ~~*, !~~* to documentation.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.17 2000/08/12 05:15:24 tgl Exp $
d60 1
a60 1
  <sect1>
d313 1
a313 1
  <sect1>
d420 2
a421 2
  <sect1>
   <title id="math-opers">Numerical Operators</title>
d502 1
a502 1
  <sect1>
d644 1
a644 1
  <sect1>
d725 2
a726 2
  <Sect1>
   <title id="cidr-opers">IP V4 CIDR Operators</title>
d795 1
a795 1
  </Sect1>
d797 2
a798 2
  <Sect1>
   <title id="inet-opers">IP V4 INET Operators</title>
d867 1
a867 1
  </Sect1>
@


1.17
log
@Mop-up for removal of ':' and ';' operators ... like, say, actually
take 'em out of pg_operator.  Also remove from scan.l's set of legal
operator characters.  Update documentation.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.16 2000/05/02 20:01:52 thomas Exp $
d383 10
@


1.16
log
@Fixups in content and markup for 7.0 release.
@
text
@d2 1
a2 1
$Header: /usr/local/cvsroot/pgsql/doc/src/sgml/oper.sgml,v 1.15 2000/03/31 03:27:41 thomas Exp $
d86 1
a86 1
UNION
a91 10
SQL select construct
</entry>
</row>
<row>
<entry>
::
</entry>
<entry>
</entry>
<entry>
a127 2
<!--
Deprecated as of v7.0
d130 1
a130 1
;
d136 1
a136 13
statement termination, logarithm
</entry>
</row>
-->
<row>
<entry>
:
</entry>
<entry>
right
</entry>
<entry>
exponentiation
d141 1
a141 1
|
d147 1
a147 1
start of interval
d207 1
d245 1
a245 1
LIKE
a466 13
	<ENTRY> : </ENTRY>
	<ENTRY>Natural Exponentiation</ENTRY>
	<ENTRY>: 3.0</ENTRY>
       </ROW>
<!--
Deprecated in v7.0, esp. since ln() is available as a generic function.
       <ROW>
	<ENTRY> ; </ENTRY>
	<ENTRY>Natural Logarithm</ENTRY>
	<ENTRY>(; 5.0)</ENTRY>
       </ROW>
-->
       <ROW>
a489 11

   <para>
    <note>
     <para>
      Two operators, ":" and ";", are now deprecated and will be removed in
      the next release.  Use the equivalent functions exp() and ln()
      instead.
     </para>
    </note>
   </para>

@


1.15
log
@Minor markup changes. Refer to (".../catalog") in the emacs hints.
@
text
@d2 1
a2 1
$Header$
d25 1
a25 1
   To view all variations of the <Quote>||</Quote> string concatenation operator, 
d77 3
a79 9
<entry>
Element
</entry>
<entry>
Precedence
</entry>
<entry>
Description
</entry>
d138 2
d151 1
d283 1
a283 1
boolean inequality
d305 1
a305 1
negation
d494 2
d501 1
d530 2
a531 2
      The operators ":" and ";" are deprecated, and will be removed in
      the near future.  Use the equivalent functions exp() and ln()
@


1.14
log
@Add note that ':' and ';' operators are deprecated.
@
text
@d1 4
d910 1
a910 1
mode: sgml
d920 1
a920 1
sgml-local-catalogs:"/usr/lib/sgml/CATALOG"
@


1.13
log
@Remove Ops parameter from STATRELID cache lookup, for Tom Lane and
optimizer.
@
text
@d63 1
a63 1
    have a different precedence that the boolean operators "&lt;=" and "&gt;=".
d181 1
a181 1
multiplication, division
d257 10
d522 11
@


1.12
log
@Complete merge of all old man page information.
lisp.sgml is a placeholder for Eric Marsden's upcoming contribution.
catalogs.sgml is not yet marked up or integrated.
 It should perhaps become an appendix.
@
text
@d414 1
a414 1
	<ENTRY>'thomas' !~ '.*vadim.*'</ENTRY>
@


1.11
log
@Include mention of CASE, COALESCE, and IFNULL.
Add date/time parsing procedure (perhaps should be in appendix).
Add time zone information (ditto).
Update keyword list.
@
text
@d15 1
a15 1
   pg_operator.  Every entry in pg_operator includes
@


1.10
log
@Fix &g.
@
text
@d1 2
a2 2
<Chapter Id="operators">
<Title>Operators</Title>
d4 20
a23 20
<Abstract>
<Para>
Describes the built-in operators available in 
<ProductName>Postgres</ProductName>.
</Para>
</Abstract>

<Para>
<ProductName>Postgres</ProductName> provides a large number of 
built-in operators on system types.
These operators are declared in the system catalog
pg_operator.  Every entry in pg_operator includes
the name of the procedure that implements the operator and the
class <Acronym>OIDs</Acronym> of the input and output types.
</Para>

<Para>
To view all variations of the <Quote>||</Quote> string concatenation operator, 
try
<ProgramListing>
d33 2
a34 2
</ProgramListing>
</Para>
d36 2
a37 2
<Para>
Users may invoke operators using the operator name, as in:
d39 1
a39 1
<ProgramListing>
d41 1
a41 1
</ProgramListing>
d43 4
a46 4
Alternatively, users may call the functions that implement the
operators directly.  In this case, the query above would be expressed
as:
<ProgramListing>
d48 2
a49 2
</ProgramListing>
</Para>
d51 13
a63 13
<Para>
<Application>psql</Application>
has a command (<Command>\dd</Command>) to show these operators.
</Para>

<sect1>
<title>Lexical Precedence</title>

<para>
Operators have a precedence which is currently hardcoded into the parser.
Most operators have the same precedence and are left-associative. This may lead
to non-intuitive behavior; for example the boolean operators "&lt;" and "&gt;"
have a different precedence that the boolean operators "&lt;=" and "&gt;=".
d325 2
a326 556
<sect1>
<title>General Operators</title>

<para>
The operators listed here are defined for a number of native data types, 
ranging from numeric types to data/time types.
</para>
<Para>
<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName> Operators</TITLE>
<TITLEABBREV>Operators</TITLEABBREV>
<TGROUP COLS="3">
<THEAD>
  <ROW>
    <ENTRY>Operator</ENTRY>
    <ENTRY>Description</ENTRY>
    <ENTRY>Usage</ENTRY>
  </ROW>
</THEAD>
<TBODY>
  <ROW>
    <ENTRY> &lt; </ENTRY>
    <ENTRY>Less than?</ENTRY>
    <ENTRY>1 &lt; 2</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;= </ENTRY>
    <ENTRY>Less than or equal to?</ENTRY>
    <ENTRY>1 &lt;= 2</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&gt; </ENTRY>
    <ENTRY>Not equal?</ENTRY>
    <ENTRY>1 &lt;&gt; 2</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> = </ENTRY>
    <ENTRY>Equal?</ENTRY>
    <ENTRY>1 = 1</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt; </ENTRY>
    <ENTRY>Greater than?</ENTRY>
    <ENTRY>2 &gt; 1</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;= </ENTRY>
    <ENTRY>Greater than or equal to?</ENTRY>
    <ENTRY>2 &gt;= 1</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> || </ENTRY>
    <ENTRY>Concatenate strings</ENTRY>
    <ENTRY>'Postgre' || 'SQL'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> !!= </ENTRY>
    <ENTRY>NOT IN</ENTRY>
    <ENTRY>3 !!= i</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ~~ </ENTRY>
    <ENTRY>LIKE</ENTRY>
    <ENTRY>'scrappy,marc,hermit' ~~ '%scrappy%'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> !~~ </ENTRY>
    <ENTRY>NOT LIKE</ENTRY>
    <ENTRY>'bruce' !~~ '%al%'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ~ </ENTRY>
    <ENTRY>Match (regex), case sensitive</ENTRY>
    <ENTRY>'thomas' ~ '.*thomas.*'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ~* </ENTRY>
    <ENTRY>Match (regex), case insensitive</ENTRY>
    <ENTRY>'thomas' ~* '.*Thomas.*'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> !~ </ENTRY>
    <ENTRY>Does not match (regex), case sensitive</ENTRY>
    <ENTRY>'thomas' !~ '.*Thomas.*'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> !~* </ENTRY>
    <ENTRY>Does not match (regex), case insensitive</ENTRY>
    <ENTRY>'thomas' !~ '.*vadim.*'</ENTRY>
  </ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
</sect1>

<sect1>
<title id="math-opers">Numerical Operators</title>

<Para>
<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName> Numerical Operators</TITLE>
<TITLEABBREV>Operators</TITLEABBREV>
<TGROUP COLS="3">
<THEAD>
  <ROW>
    <ENTRY>Operator</ENTRY>
    <ENTRY>Description</ENTRY>
    <ENTRY>Usage</ENTRY>
  </ROW>
</THEAD>
<TBODY>
  <ROW>
    <ENTRY> !  </ENTRY>
    <ENTRY>Factorial</ENTRY>
    <ENTRY>3 !</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> !!  </ENTRY>
    <ENTRY>Factorial (left operator)</ENTRY>
    <ENTRY>!! 3</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> % </ENTRY>
    <ENTRY>Modulo</ENTRY>
    <ENTRY>5 % 4</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> % </ENTRY>
    <ENTRY>Truncate</ENTRY>
    <ENTRY>% 4.5</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> * </ENTRY>
    <ENTRY>Multiplication</ENTRY>
    <ENTRY>2 * 3</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> + </ENTRY>
    <ENTRY>Addition</ENTRY>
    <ENTRY>2 + 3</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> - </ENTRY>
    <ENTRY>Subtraction</ENTRY>
    <ENTRY>2 - 3</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> / </ENTRY>
    <ENTRY>Division</ENTRY>
    <ENTRY>4 / 2</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> : </ENTRY>
    <ENTRY>Natural Exponentiation</ENTRY>
    <ENTRY>: 3.0</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ; </ENTRY>
    <ENTRY>Natural Logarithm</ENTRY>
    <ENTRY>(; 5.0)</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> @@ </ENTRY>
    <ENTRY>Absolute value</ENTRY>
    <ENTRY>@@ -5.0</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ^ </ENTRY>
    <ENTRY>Exponentiation</ENTRY>
    <ENTRY>2.0 ^ 3.0</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> |/ </ENTRY>
    <ENTRY>Square root</ENTRY>
    <ENTRY>|/ 25.0</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ||/ </ENTRY>
    <ENTRY>Cube root</ENTRY>
    <ENTRY>||/ 27.0</ENTRY>
  </ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
</sect1>

<sect1>
<title>Geometric Operators</title>

<Para>
<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName> Geometric Operators</TITLE>
<TITLEABBREV>Operators</TITLEABBREV>
<TGROUP COLS="3">
<THEAD>
  <ROW>
    <ENTRY>Operator</ENTRY>
    <ENTRY>Description</ENTRY>
    <ENTRY>Usage</ENTRY>
  </ROW>
</THEAD>
<TBODY>
  <ROW>
    <ENTRY> + </ENTRY>
    <ENTRY>Translation</ENTRY>
    <ENTRY>'((0,0),(1,1))'::box + '(2.0,0)'::point</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> - </ENTRY>
    <ENTRY>Translation</ENTRY>
    <ENTRY>'((0,0),(1,1))'::box - '(2.0,0)'::point</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> * </ENTRY>
    <ENTRY>Scaling/rotation</ENTRY>
    <ENTRY>'((0,0),(1,1))'::box * '(2.0,0)'::point</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> / </ENTRY>
    <ENTRY>Scaling/rotation</ENTRY>
    <ENTRY>'((0,0),(2,2))'::box / '(2.0,0)'::point</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> # </ENTRY>
    <ENTRY>Intersection</ENTRY>
    <ENTRY>'((1,-1),(-1,1))' # '((1,1),(-1,-1))'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> # </ENTRY>
    <ENTRY>Number of points in polygon</ENTRY>
    <ENTRY># '((1,0),(0,1),(-1,0))'</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ## </ENTRY>
    <ENTRY>Point of closest proximity</ENTRY>
    <ENTRY>'(0,0)'::point ## '((2,0),(0,2))'::lseg</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &amp;&amp; </ENTRY>
    <ENTRY>Overlaps?</ENTRY>
    <ENTRY>'((0,0),(1,1))'::box &amp;&amp; '((0,0),(2,2))'::box</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &amp;&lt; </ENTRY>
    <ENTRY>Overlaps to left?</ENTRY>
    <ENTRY>'((0,0),(1,1))'::box &amp;&lt; '((0,0),(2,2))'::box</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &amp;&gt; </ENTRY>
    <ENTRY>Overlaps to right?</ENTRY>
    <ENTRY>'((0,0),(3,3))'::box &amp;&gt; '((0,0),(2,2))'::box</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;-&gt; </ENTRY>
    <ENTRY>Distance between</ENTRY>
    <ENTRY>'((0,0),1)'::circle &lt;-&gt; '((5,0),1)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&lt; </ENTRY>
    <ENTRY>Left of?</ENTRY>
    <ENTRY>'((0,0),1)'::circle &lt;&lt; '((5,0),1)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;^ </ENTRY>
    <ENTRY>Is below?</ENTRY>
    <ENTRY>'((0,0),1)'::circle &lt;^ '((0,5),1)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;&gt; </ENTRY>
    <ENTRY>Is right of?</ENTRY>
    <ENTRY>'((5,0),1)'::circle &gt;&gt; '((0,0),1)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;^ </ENTRY>
    <ENTRY>Is above?</ENTRY>
    <ENTRY>'((0,5),1)'::circle >^ '((0,0),1)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ?# </ENTRY>
    <ENTRY>Intersects or overlaps</ENTRY>
    <ENTRY>'((-1,0),(1,0))'::lseg ?# '((-2,-2),(2,2))'::box;</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ?- </ENTRY>
    <ENTRY>Is horizontal?</ENTRY>
    <ENTRY>'(1,0)'::point ?- '(0,0)'::point</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ?-| </ENTRY>
    <ENTRY>Is perpendicular?</ENTRY>
    <ENTRY>'((0,0),(0,1))'::lseg ?-| '((0,0),(1,0))'::lseg</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> @@-@@  </ENTRY>
    <ENTRY>Length or circumference</ENTRY>
    <ENTRY>@@-@@ '((0,0),(1,0))'::path</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ?| </ENTRY>
    <ENTRY>Is vertical?</ENTRY>
    <ENTRY>'(0,1)'::point ?| '(0,0)'::point</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ?|| </ENTRY>
    <ENTRY>Is parallel?</ENTRY>
    <ENTRY>'((-1,0),(1,0))'::lseg ?|| '((-1,2),(1,2))'::lseg</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> @@ </ENTRY>
    <ENTRY>Contained or on</ENTRY>
    <ENTRY>'(1,1)'::point @@ '((0,0),2)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> @@@@ </ENTRY>
    <ENTRY>Center of</ENTRY>
    <ENTRY>@@@@ '((0,0),10)'::circle</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ~= </ENTRY>
    <ENTRY>Same as</ENTRY>
    <ENTRY>'((0,0),(1,1))'::polygon ~= '((1,1),(0,0))'::polygon</ENTRY>
  </ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
</sect1>

<sect1>
<title>Time Interval Operators</title>

<Para>
The time interval data type <Type>tinterval</Type> is a legacy from the original
date/time types and is not as well supported as the more modern types. There
are several operators for this type.

<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName> Time Interval Operators</TITLE>
<TITLEABBREV>Operators</TITLEABBREV>
<TGROUP COLS="3">
<THEAD>
  <ROW>
    <ENTRY>Operator</ENTRY>
    <ENTRY>Description</ENTRY>
    <ENTRY>Usage</ENTRY>
  </ROW>
</THEAD>
<TBODY>
  <ROW>
    <ENTRY> #&lt; </ENTRY>
    <ENTRY>Interval less than?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> #&lt;= </ENTRY>
    <ENTRY>Interval less than or equal to?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> #&lt;&gt; </ENTRY>
    <ENTRY>Interval not equal?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> #= </ENTRY>
    <ENTRY>Interval equal?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> #&gt; </ENTRY>
    <ENTRY>Interval greater than?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> #&gt;= </ENTRY>
    <ENTRY>Interval greater than or equal to?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;#&gt; </ENTRY>
    <ENTRY>Convert to time interval</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&lt; </ENTRY>
    <ENTRY>Interval less than?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> | </ENTRY>
    <ENTRY>Start of interval</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> ~= </ENTRY>
    <ENTRY>Same as</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;?&gt; </ENTRY>
    <ENTRY>Time inside interval?</ENTRY>
    <ENTRY></ENTRY>
  </ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
</sect1>

<Sect1>
<title id="cidr-opers">IP V4 CIDR Operators</title>

<Para>
<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName>IP V4 CIDR Operators</TITLE>
<TITLEABBREV>Operators</TITLEABBREV>
<TGROUP COLS="3">
<THEAD>
  <ROW>
    <ENTRY>Operator</ENTRY>
    <ENTRY>Description</ENTRY>
    <ENTRY>Usage</ENTRY>
  </ROW>
</THEAD>
<TBODY>
  <ROW>
    <ENTRY> &lt; </ENTRY>
    <ENTRY>Less than</ENTRY>
    <ENTRY>'192.168.1.5'::cidr &lt; '192.168.1.6'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;= </ENTRY>
    <ENTRY>Less than or equal</ENTRY>
    <ENTRY>'192.168.1.5'::cidr &lt;= '192.168.1.5'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> = </ENTRY>
    <ENTRY>Equals</ENTRY>
    <ENTRY>'192.168.1.5'::cidr = '192.168.1.5'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;= </ENTRY>
    <ENTRY>Greater or equal</ENTRY>
    <ENTRY>'192.168.1.5'::cidr &gt;= '192.168.1.5'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt; </ENTRY>
    <ENTRY>Greater</ENTRY>
    <ENTRY>'192.168.1.5'::cidr &gt; '192.168.1.4'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&gt; </ENTRY>
    <ENTRY>Not equal</ENTRY>
    <ENTRY>'192.168.1.5'::cidr &lt;&gt; '192.168.1.4'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&lt; </ENTRY>
    <ENTRY>is contained within</ENTRY>
    <ENTRY>'192.168.1.5'::cidr &lt;&lt; '192.168.1/24'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&lt;= </ENTRY>
    <ENTRY>is contained within or equals</ENTRY>
    <ENTRY>'192.168.1/24'::cidr &lt;&lt;= '192.168.1/24'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;&gt; </ENTRY>
    <ENTRY>contains</ENTRY>
    <ENTRY>'192.168.1/24'::cidr &gt;&gt; '192.168.1.5'::cidr</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;&gt;= </ENTRY>
    <ENTRY>contains or equals</ENTRY>
    <ENTRY>'192.168.1/24'::cidr &gt;&gt;= '192.168.1/24'::cidr</ENTRY>
  </ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
</Sect1>

<Sect1>
<title id="inet-opers">IP V4 INET Operators</title>

<Para>
<TABLE TOCENTRY="1">
<TITLE><ProductName>Postgres</ProductName>IP V4 INET Operators</TITLE>
<TITLEABBREV>Operators</TITLEABBREV>
<TGROUP COLS="3">
<THEAD>
  <ROW>
    <ENTRY>Operator</ENTRY>
    <ENTRY>Description</ENTRY>
    <ENTRY>Usage</ENTRY>
  </ROW>
</THEAD>
<TBODY>
  <ROW>
    <ENTRY> &lt; </ENTRY>
    <ENTRY>Less than</ENTRY>
    <ENTRY>'192.168.1.5'::inet &lt; '192.168.1.6'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;= </ENTRY>
    <ENTRY>Less than or equal</ENTRY>
    <ENTRY>'192.168.1.5'::inet &lt;= '192.168.1.5'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> = </ENTRY>
    <ENTRY>Equals</ENTRY>
    <ENTRY>'192.168.1.5'::inet = '192.168.1.5'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;= </ENTRY>
    <ENTRY>Greater or equal</ENTRY>
    <ENTRY>'192.168.1.5'::inet &gt;= '192.168.1.5'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt; </ENTRY>
    <ENTRY>Greater</ENTRY>
    <ENTRY>'192.168.1.5'::inet &gt; '192.168.1.4'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&gt; </ENTRY>
    <ENTRY>Not equal</ENTRY>
    <ENTRY>'192.168.1.5'::inet &lt;&gt; '192.168.1.4'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&lt; </ENTRY>
    <ENTRY>is contained within</ENTRY>
    <ENTRY>'192.168.1.5'::inet &lt;&lt; '192.168.1/24'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &lt;&lt;= </ENTRY>
    <ENTRY>is contained within or equals</ENTRY>
    <ENTRY>'192.168.1/24'::inet &lt;&lt;= '192.168.1/24'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;&gt; </ENTRY>
    <ENTRY>contains</ENTRY>
    <ENTRY>'192.168.1/24'::inet &gt;&gt; '192.168.1.5'::inet</ENTRY>
  </ROW>
  <ROW>
    <ENTRY> &gt;&gt;= </ENTRY>
    <ENTRY>contains or equals</ENTRY>
    <ENTRY>'192.168.1/24'::inet &gt;&gt;= '192.168.1/24'::inet</ENTRY>
  </ROW>
</TBODY>
</TGROUP>
</TABLE>
</Para>
</Sect1>

</Chapter>
d328 571
@


1.9
log
@INET/CIDR doc cleanup
@
text
@d768 1
a768 1
    <ENTRY> %gt;= </ENTRY>
d773 1
a773 1
    <ENTRY> %gt; </ENTRY>
d775 1
a775 1
    <ENTRY>'192.168.1.5'::cidr %gt; '192.168.1.4'::cidr</ENTRY>
d840 1
a840 1
    <ENTRY> %gt;= </ENTRY>
d845 1
a845 1
    <ENTRY> %gt; </ENTRY>
d847 1
a847 1
    <ENTRY>'192.168.1.5'::inet %gt; '192.168.1.4'::inet</ENTRY>
@


1.8
log
@Add docs about left-associativity of operators.
@
text
@d737 1
a737 1
<title id="cidr-opers">IP V4 Operators</title>
d741 1
a741 1
<TITLE><ProductName>Postgres</ProductName>IP V4 Operators</TITLE>
d809 1
a809 1
<title id="inet-opers">IP V4 Operators</title>
d813 1
a813 1
<TITLE><ProductName>Postgres</ProductName>IP V4 Operators</TITLE>
@


1.7
log
@Add documentation change for %'s precidence.
@
text
@d61 1
a61 1
Most operators have the same precedence and are non-associative. This may lead
@


1.6
log
@Clean up to ensure tag completion as required by the newest versions
 of Norm's Modular Style Sheets and jade/docbook.
From Vince Vielhaber <vev@@michvhf.com>.
@
text
@d175 1
a175 1
* /
@


1.5
log
@Include new cidr and inet data types.
@
text
@d18 1
d49 1
d54 1
a54 1

d75 1
d78 1
d81 2
d89 1
d92 1
d95 2
d100 1
d102 1
d105 2
a106 1

d110 1
d113 1
d116 2
a117 1

d121 1
d124 1
d127 2
a128 1

d132 1
d135 1
d138 2
a139 1

d143 1
d146 1
d149 2
a150 1

d154 1
d157 1
d160 2
a161 1

d165 1
d168 1
d171 2
a172 1

d176 1
d179 1
d182 2
a183 1

d187 1
d190 1
d193 2
a194 1

d198 1
d200 1
d203 2
d208 1
d210 1
d213 2
a214 1

d218 1
d220 1
d223 2
a224 1

d228 1
d230 1
d233 2
a234 1

d238 1
d240 1
d243 2
a244 1

d248 1
d250 1
d253 2
a254 1

d258 1
d260 1
d263 2
a264 1

d268 1
d270 1
d273 2
a274 1

d278 1
d281 1
d284 2
a285 1

d289 1
d292 1
d295 2
a296 1

d300 1
d303 1
d306 2
a307 1

d311 1
d314 1
d317 2
a318 1

d320 1
d322 2
d331 1
a331 1

d419 1
d511 1
d653 1
d734 1
@


1.4
log
@Add some id tags to allow cross-references from the datatype chapter.
@
text
@d35 19
d655 2
d659 67
a725 1
Users may invoke operators using the operator name, as in:
d727 2
a728 3
<ProgramListing>
select * from emp where salary < 40000;
</ProgramListing>
d730 68
a797 6
Alternatively, users may call the functions that implement the
operators directly.  In this case, the query above would be expressed
as:
<ProgramListing>
select * from emp where int4lt(salary, 40000);
</ProgramListing>
a798 3
<Para>
<Application>psql</Application>
has a command (<Command>\dd</Command>) to show these operators.
@


1.3
log
@Clean up pages. Add information for operator precedence.
Split introduction sections into separate files to allow the legal notice
 and notation sections appear in all documents without having the history
 show up everplace too.
Add full list of reserved and non-reserved key words in syntax.sgml.
Add a separate chapter to the admin guide on security.
@
text
@d6 2
a7 1
Describes the built-in operators available in <ProductName>Postgres</ProductName>.
d12 2
a13 1
<ProductName>Postgres</ProductName> provides a large number of built-in operators on system types.
d20 2
a21 1
To view all variations of the <Quote>||</Quote> string concatenation operator, try
d233 2
a234 2
The operators listed here are defined for a number of native data types, ranging
from numeric types to data/time types.
d325 1
a325 1
<title>Numerical Operators</title>
@


1.2
log
@Add missing information.
Fix examples for regex operators.
@
text
@d33 194
@


1.1
log
@Split function and operator User Guide info
 from datatype.sgml into separate files.
Add type conversion information.
Format historical release notes.
@
text
@d1 1
a1 1
<Chapter>
d105 1
a105 1
    <ENTRY>'thomas' ~ '*.thomas*.'</ENTRY>
d110 1
a110 1
    <ENTRY>'thomas' ~* '*.Thomas*.'</ENTRY>
d115 1
a115 1
    <ENTRY>'thomas' !~ '*.Thomas*.'</ENTRY>
d120 1
a120 1
    <ENTRY>'thomas' !~ '*.vadim*.'</ENTRY>
@

