aboutsummaryrefslogtreecommitdiff
path: root/contrib/btree_gist/sql/enum.sql
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2017-03-21 10:19:03 -0400
committerAndrew Dunstan <andrew@dunslane.net>2017-03-21 10:43:27 -0400
commitf7946a92b689199cba64e7406a1c12d12637168a (patch)
tree2f41255ef1200e06a7a707e8a57e5841af6daa36 /contrib/btree_gist/sql/enum.sql
parent65a9138b9b66b2c915619344ca56f4f0d531ada7 (diff)
downloadpostgresql-f7946a92b689199cba64e7406a1c12d12637168a.tar.gz
postgresql-f7946a92b689199cba64e7406a1c12d12637168a.zip
Add btree_gist support for enum types.
This will allow enums to be used in exclusion constraints. The code uses the new CallerFInfoFunctionCall infrastructure in fmgr, and the support for it added to btree_gist in commit 393bb504d7. Reviewed by Tom Lane and Anastasia Lubennikova Discussion: http://postgr.es/m/56EA8A71.8060107@dunslane.net
Diffstat (limited to 'contrib/btree_gist/sql/enum.sql')
-rw-r--r--contrib/btree_gist/sql/enum.sql38
1 files changed, 38 insertions, 0 deletions
diff --git a/contrib/btree_gist/sql/enum.sql b/contrib/btree_gist/sql/enum.sql
new file mode 100644
index 00000000000..476211e9795
--- /dev/null
+++ b/contrib/btree_gist/sql/enum.sql
@@ -0,0 +1,38 @@
+-- enum check
+
+create type rainbow as enum ('r','o','y','g','b','i','v');
+
+CREATE TABLE enumtmp (a rainbow);
+
+\copy enumtmp from 'data/enum.data'
+
+SET enable_seqscan=on;
+
+select a, count(*) from enumtmp group by a order by 1;
+
+SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
+
+CREATE INDEX enumidx ON enumtmp USING gist ( a );
+
+SET enable_seqscan=off;
+
+SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
+
+SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
+
+EXPLAIN (COSTS OFF)
+SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;