Skip to content

Commit 4429f6a

Browse files
committed
Support range data types.
Selectivity estimation functions are missing for some range type operators, which is a TODO. Jeff Davis
1 parent 4334289 commit 4429f6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6718
-103
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@
218218
<entry>functions and procedures</entry>
219219
</row>
220220

221+
<row>
222+
<entry><link linkend="catalog-pg-range"><structname>pg_range</structname></link></entry>
223+
<entry>information about range types</entry>
224+
</row>
225+
221226
<row>
222227
<entry><link linkend="catalog-pg-rewrite"><structname>pg_rewrite</structname></link></entry>
223228
<entry>query rewrite rules</entry>
@@ -4594,6 +4599,78 @@
45944599

45954600
</sect1>
45964601

4602+
<sect1 id="catalog-pg-range">
4603+
<title><structname>pg_range</structname></title>
4604+
4605+
<indexterm zone="catalog-pg-range">
4606+
<primary>pg_range</primary>
4607+
</indexterm>
4608+
4609+
<para>
4610+
The catalog <structname>pg_range</structname> stores information about range types.
4611+
</para>
4612+
4613+
<table>
4614+
<title><structname>pg_range</> Columns</title>
4615+
4616+
<tgroup cols="4">
4617+
<thead>
4618+
<row>
4619+
<entry>Name</entry>
4620+
<entry>Type</entry>
4621+
<entry>References</entry>
4622+
<entry>Description</entry>
4623+
</row>
4624+
</thead>
4625+
4626+
<tbody>
4627+
<row>
4628+
<entry><structfield>rngtypid</structfield></entry>
4629+
<entry><type>oid</type></entry>
4630+
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
4631+
<entry>The type that is a range type</entry>
4632+
</row>
4633+
4634+
<row>
4635+
<entry><structfield>rngsubtype</structfield></entry>
4636+
<entry><type>oid</type></entry>
4637+
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
4638+
<entry>Subtype of this range type, e.g. <type>integer</type> is the subtype of <type>int4range</type></entry>
4639+
</row>
4640+
4641+
<row>
4642+
<entry><structfield>rngcollation</structfield></entry>
4643+
<entry><type>oid</type></entry>
4644+
<entry><literal><link linkend="catalog-pg-collation"><structname>pg_collation</structname></link>.oid</literal></entry>
4645+
<entry>The collation used when comparing range boundaries</entry>
4646+
</row>
4647+
4648+
<row>
4649+
<entry><structfield>rngsubopc</structfield></entry>
4650+
<entry><type>oid</type></entry>
4651+
<entry><literal><link linkend="catalog-pg-opclass"><structname>pg_opclass</structname></link>.oid</literal></entry>
4652+
<entry>The operator class used when comparing range boundaries</entry>
4653+
</row>
4654+
4655+
<row>
4656+
<entry><structfield>rngcanonical</structfield></entry>
4657+
<entry><type>regproc</type></entry>
4658+
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4659+
<entry>A function to convert a range into its canonical form</entry>
4660+
</row>
4661+
4662+
<row>
4663+
<entry><structfield>rngsubdiff</structfield></entry>
4664+
<entry><type>regproc</type></entry>
4665+
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
4666+
<entry>A function to return the distance between two lower and upper bound, as a <type>double precision</type>. Used for GiST support</entry>
4667+
</row>
4668+
</tbody>
4669+
</tgroup>
4670+
</table>
4671+
4672+
</sect1>
4673+
45974674
<sect1 id="catalog-pg-rewrite">
45984675
<title><structname>pg_rewrite</structname></title>
45994676

doc/src/sgml/datatype.sgml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4173,6 +4173,8 @@ SET xmloption TO { DOCUMENT | CONTENT };
41734173

41744174
&rowtypes;
41754175

4176+
&rangetypes;
4177+
41764178
<sect1 id="datatype-oid">
41774179
<title>Object Identifier Types</title>
41784180

@@ -4443,6 +4445,10 @@ SELECT * FROM pg_attribute
44434445
<primary>anyenum</primary>
44444446
</indexterm>
44454447

4448+
<indexterm zone="datatype-pseudo">
4449+
<primary>anyrange</primary>
4450+
</indexterm>
4451+
44464452
<indexterm zone="datatype-pseudo">
44474453
<primary>void</primary>
44484454
</indexterm>
@@ -4519,6 +4525,13 @@ SELECT * FROM pg_attribute
45194525
<xref linkend="datatype-enum">).</entry>
45204526
</row>
45214527

4528+
<row>
4529+
<entry><type>anyrange</></entry>
4530+
<entry>Indicates that a function accepts any range data type
4531+
(see <xref linkend="extend-types-polymorphic"> and
4532+
<xref linkend="rangetypes">).</entry>
4533+
</row>
4534+
45224535
<row>
45234536
<entry><type>anynonarray</></entry>
45244537
<entry>Indicates that a function accepts any non-array data type
@@ -4583,7 +4596,8 @@ SELECT * FROM pg_attribute
45834596
only <type>void</> and <type>record</> as a result type (plus
45844597
<type>trigger</> when the function is used as a trigger). Some also
45854598
support polymorphic functions using the types <type>anyarray</>,
4586-
<type>anyelement</>, <type>anyenum</>, and <type>anynonarray</>.
4599+
<type>anyelement</>, <type>anyenum</>, <type>anyrange</>, and
4600+
<type>anynonarray</>.
45874601
</para>
45884602

45894603
<para>

doc/src/sgml/extend.sgml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,15 @@
198198
</indexterm>
199199

200200
<para>
201-
Four pseudo-types of special interest are <type>anyelement</>,
202-
<type>anyarray</>, <type>anynonarray</>, and <type>anyenum</>,
203-
which are collectively called <firstterm>polymorphic types</>.
204-
Any function declared using these types is said to be
205-
a <firstterm>polymorphic function</>. A polymorphic function can
206-
operate on many different data types, with the specific data type(s)
207-
being determined by the data types actually passed to it in a particular
208-
call.
201+
Five pseudo-types of special interest are <type>anyelement</>,
202+
<type>anyarray</>, <type>anynonarray</>, <type>anyenum</>,
203+
and <type>anyrange</>, which are collectively
204+
called <firstterm>polymorphic types</>. Any function declared
205+
using these types is said to be a <firstterm>polymorphic
206+
function</>. A polymorphic function can operate on many
207+
different data types, with the specific data type(s) being
208+
determined by the data types actually passed to it in a
209+
particular call.
209210
</para>
210211

211212
<para>
@@ -221,6 +222,11 @@
221222
<type>anyelement</type>, the actual array type in the
222223
<type>anyarray</type> positions must be an array whose elements are
223224
the same type appearing in the <type>anyelement</type> positions.
225+
Similarly, if there are positions declared <type>anyrange</type>
226+
and others declared
227+
<type>anyelement</type>, the actual range type in the
228+
<type>anyrange</type> positions must be a range whose subtype is
229+
the same type appearing in the <type>anyelement</type> positions.
224230
<type>anynonarray</> is treated exactly the same as <type>anyelement</>,
225231
but adds the additional constraint that the actual type must not be
226232
an array type.

doc/src/sgml/filelist.sgml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<!ENTITY mvcc SYSTEM "mvcc.sgml">
2626
<!ENTITY perform SYSTEM "perform.sgml">
2727
<!ENTITY queries SYSTEM "queries.sgml">
28+
<!entity rangetypes SYSTEM "rangetypes.sgml">
2829
<!ENTITY rowtypes SYSTEM "rowtypes.sgml">
2930
<!ENTITY syntax SYSTEM "syntax.sgml">
3031
<!ENTITY textsearch SYSTEM "textsearch.sgml">

0 commit comments

Comments
 (0)