postgresql/contrib/btree_gist/sql/enum.sql
Andrew Dunstan f7946a92b6 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
2017-03-21 10:43:27 -04:00

39 lines
927 B
SQL

-- 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;