1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00
Files
config
contrib
adminpack
amcheck
auth_delay
auto_explain
bloom
btree_gin
btree_gist
data
expected
bit.out
bytea.out
cash.out
char.out
char_1.out
cidr.out
date.out
enum.out
float4.out
float8.out
inet.out
init.out
int2.out
int4.out
int8.out
interval.out
macaddr.out
macaddr8.out
not_equal.out
numeric.out
oid.out
text.out
text_1.out
time.out
timestamp.out
timestamptz.out
timetz.out
uuid.out
varbit.out
varchar.out
varchar_1.out
sql
.gitignore
Makefile
btree_bit.c
btree_bytea.c
btree_cash.c
btree_date.c
btree_enum.c
btree_float4.c
btree_float8.c
btree_gist--1.0--1.1.sql
btree_gist--1.1--1.2.sql
btree_gist--1.2--1.3.sql
btree_gist--1.2.sql
btree_gist--1.3--1.4.sql
btree_gist--1.4--1.5.sql
btree_gist--unpackaged--1.0.sql
btree_gist.c
btree_gist.control
btree_gist.h
btree_inet.c
btree_int2.c
btree_int4.c
btree_int8.c
btree_interval.c
btree_macaddr.c
btree_macaddr8.c
btree_numeric.c
btree_oid.c
btree_text.c
btree_time.c
btree_ts.c
btree_utils_num.c
btree_utils_num.h
btree_utils_var.c
btree_utils_var.h
btree_uuid.c
citext
cube
dblink
dict_int
dict_xsyn
earthdistance
file_fdw
fuzzystrmatch
hstore
hstore_plperl
hstore_plpython
intagg
intarray
isn
jsonb_plperl
jsonb_plpython
lo
ltree
ltree_plpython
oid2name
pageinspect
passwordcheck
pg_buffercache
pg_freespacemap
pg_prewarm
pg_standby
pg_stat_statements
pg_trgm
pg_visibility
pgcrypto
pgrowlocks
pgstattuple
postgres_fdw
seg
sepgsql
spi
sslinfo
start-scripts
tablefunc
tcn
test_decoding
tsm_system_rows
tsm_system_time
unaccent
uuid-ossp
vacuumlo
xml2
Makefile
README
contrib-global.mk
doc
src
.dir-locals.el
.gitattributes
.gitignore
COPYRIGHT
GNUmakefile.in
HISTORY
Makefile
README
README.git
aclocal.m4
configure
configure.in
postgres/contrib/btree_gist/expected/enum.out
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

92 lines
1.6 KiB
Plaintext

-- 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;
a | count
---+-------
r | 76
o | 78
y | 73
g | 75
b | 77
i | 78
v | 75
| 63
(8 rows)
SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
count
-------
227
(1 row)
SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
count
-------
302
(1 row)
SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
count
-------
75
(1 row)
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
count
-------
305
(1 row)
SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
count
-------
230
(1 row)
CREATE INDEX enumidx ON enumtmp USING gist ( a );
SET enable_seqscan=off;
SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
count
-------
227
(1 row)
SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
count
-------
302
(1 row)
SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
count
-------
75
(1 row)
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
count
-------
305
(1 row)
SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
count
-------
230
(1 row)
EXPLAIN (COSTS OFF)
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
QUERY PLAN
-----------------------------------------------
Aggregate
-> Bitmap Heap Scan on enumtmp
Recheck Cond: (a >= 'g'::rainbow)
-> Bitmap Index Scan on enumidx
Index Cond: (a >= 'g'::rainbow)
(5 rows)