summaryrefslogtreecommitdiff
path: root/doc/src/sgml/btree-gist.sgml
diff options
context:
space:
mode:
authorRobert Haas2010-08-02 16:26:48 +0000
committerRobert Haas2010-08-02 16:26:48 +0000
commitad17ff95cf0d3df41aa2a7bbc03960d42b8da9f3 (patch)
tree265667cb7c15c3cbaba41ebba25fd6dd02ece14a /doc/src/sgml/btree-gist.sgml
parent98c2383ba5b51ebd0e79d0bab8a7dc5de47983c0 (diff)
Add btree_gist support for searching on "not equals".
Jeff Davis, with slight editorialization by me.
Diffstat (limited to 'doc/src/sgml/btree-gist.sgml')
-rw-r--r--doc/src/sgml/btree-gist.sgml38
1 files changed, 37 insertions, 1 deletions
diff --git a/doc/src/sgml/btree-gist.sgml b/doc/src/sgml/btree-gist.sgml
index 8264d5a219c..d477f23a2e4 100644
--- a/doc/src/sgml/btree-gist.sgml
+++ b/doc/src/sgml/btree-gist.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/btree-gist.sgml,v 1.5 2010/03/17 17:12:31 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/btree-gist.sgml,v 1.6 2010/08/02 16:26:48 rhaas Exp $ -->
<sect1 id="btree-gist">
<title>btree_gist</title>
@@ -27,9 +27,21 @@
GiST operator classes.
</para>
+ <para>
+ In addition to the typical btree search operators, btree_gist also
+ provides search operators for <literal>&lt;&gt;</literal> ("not
+ equals"). This may be useful in combination with an
+ <link linkend="SQL-CREATETABLE-EXCLUDE">Exclusion Constraint</link>,
+ as descibed below.
+ </para>
+
<sect2>
<title>Example usage</title>
+ <para>
+ Simple example using btree_gist instead of btree:
+ </para>
+
<programlisting>
CREATE TABLE test (a int4);
-- create index
@@ -38,6 +50,30 @@ CREATE INDEX testidx ON test USING gist (a);
SELECT * FROM test WHERE a &lt; 10;
</programlisting>
+ <para>
+ Example using an <link linkend="SQL-CREATETABLE-EXCLUDE">Exclusion
+ Constraint</link> to enforce the constraint that a cage at a zoo
+ can contain only one kind of animal:
+ </para>
+
+<programlisting>
+=> CREATE TABLE zoo (
+ cage INTEGER,
+ animal TEXT,
+ EXCLUDE USING gist (cage WITH =, animal WITH <>)
+);
+
+=> INSERT INTO zoo VALUES(123, 'zebra');
+INSERT 0 1
+=> INSERT INTO zoo VALUES(123, 'zebra');
+INSERT 0 1
+=> INSERT INTO zoo VALUES(123, 'lion');
+ERROR: conflicting key value violates exclusion constraint "zoo_cage_animal_excl"
+DETAIL: Key (cage, animal)=(123, lion) conflicts with existing key (cage, animal)=(123, zebra).
+=> INSERT INTO zoo VALUES(124, 'lion');
+INSERT 0 1
+</programlisting>
+
</sect2>
<sect2>