1-- varbit check
2CREATE TABLE varbittmp (a varbit);
3\copy varbittmp from 'data/varbit.data'
4SET enable_seqscan=on;
5SELECT count(*) FROM varbittmp WHERE a <   '1110100111010';
6 count
7-------
8   549
9(1 row)
10
11SELECT count(*) FROM varbittmp WHERE a <=  '1110100111010';
12 count
13-------
14   550
15(1 row)
16
17SELECT count(*) FROM varbittmp WHERE a  =  '1110100111010';
18 count
19-------
20     1
21(1 row)
22
23SELECT count(*) FROM varbittmp WHERE a >=  '1110100111010';
24 count
25-------
26    51
27(1 row)
28
29SELECT count(*) FROM varbittmp WHERE a >   '1110100111010';
30 count
31-------
32    50
33(1 row)
34
35CREATE INDEX varbitidx ON varbittmp USING GIST ( a );
36SET enable_seqscan=off;
37SELECT count(*) FROM varbittmp WHERE a <   '1110100111010'::varbit;
38 count
39-------
40   549
41(1 row)
42
43SELECT count(*) FROM varbittmp WHERE a <=  '1110100111010'::varbit;
44 count
45-------
46   550
47(1 row)
48
49SELECT count(*) FROM varbittmp WHERE a  =  '1110100111010'::varbit;
50 count
51-------
52     1
53(1 row)
54
55SELECT count(*) FROM varbittmp WHERE a >=  '1110100111010'::varbit;
56 count
57-------
58    51
59(1 row)
60
61SELECT count(*) FROM varbittmp WHERE a >   '1110100111010'::varbit;
62 count
63-------
64    50
65(1 row)
66
67-- Test index-only scans
68SET enable_bitmapscan=off;
69EXPLAIN (COSTS OFF)
70SELECT a FROM bittmp WHERE a BETWEEN '1000000' and '1000001';
71                             QUERY PLAN
72---------------------------------------------------------------------
73 Index Only Scan using bitidx on bittmp
74   Index Cond: ((a >= '1000000'::"bit") AND (a <= '1000001'::"bit"))
75(2 rows)
76
77