2 -- Test index AM property-reporting functions
5 pg_indexam_has_property(a.oid, prop) as "AM",
6 pg_index_has_property('onek_hundred'::regclass, prop) as "Index",
7 pg_index_column_has_property('onek_hundred'::regclass, 1, prop) as "Column"
9 unnest(array['asc', 'desc', 'nulls_first', 'nulls_last',
10 'orderable', 'distance_orderable', 'returnable',
11 'search_array', 'search_nulls',
12 'clusterable', 'index_scan', 'bitmap_scan',
14 'can_order', 'can_unique', 'can_multi_col',
15 'can_exclude', 'can_include',
17 with ordinality as u(prop,ord)
18 where a.amname = 'btree'
20 prop | AM | Index | Column
21 --------------------+----+-------+--------
27 distance_orderable | | | f
44 pg_indexam_has_property(a.oid, prop) as "AM",
45 pg_index_has_property('gcircleind'::regclass, prop) as "Index",
46 pg_index_column_has_property('gcircleind'::regclass, 1, prop) as "Column"
48 unnest(array['asc', 'desc', 'nulls_first', 'nulls_last',
49 'orderable', 'distance_orderable', 'returnable',
50 'search_array', 'search_nulls',
51 'clusterable', 'index_scan', 'bitmap_scan',
53 'can_order', 'can_unique', 'can_multi_col',
54 'can_exclude', 'can_include',
56 with ordinality as u(prop,ord)
57 where a.amname = 'gist'
59 prop | AM | Index | Column
60 --------------------+----+-------+--------
66 distance_orderable | | | t
83 pg_index_column_has_property('onek_hundred'::regclass, 1, prop) as btree,
84 pg_index_column_has_property('hash_i4_index'::regclass, 1, prop) as hash,
85 pg_index_column_has_property('gcircleind'::regclass, 1, prop) as gist,
86 pg_index_column_has_property('sp_radix_ind'::regclass, 1, prop) as spgist_radix,
87 pg_index_column_has_property('sp_quad_ind'::regclass, 1, prop) as spgist_quad,
88 pg_index_column_has_property('botharrayidx'::regclass, 1, prop) as gin,
89 pg_index_column_has_property('brinidx'::regclass, 1, prop) as brin
90 from unnest(array['asc', 'desc', 'nulls_first', 'nulls_last',
91 'orderable', 'distance_orderable', 'returnable',
92 'search_array', 'search_nulls',
94 with ordinality as u(prop,ord)
96 prop | btree | hash | gist | spgist_radix | spgist_quad | gin | brin
97 --------------------+-------+------+------+--------------+-------------+-----+------
98 asc | t | f | f | f | f | f | f
99 desc | f | f | f | f | f | f | f
100 nulls_first | f | f | f | f | f | f | f
101 nulls_last | t | f | f | f | f | f | f
102 orderable | t | f | f | f | f | f | f
103 distance_orderable | f | f | t | f | t | f | f
104 returnable | t | f | f | t | t | f | f
105 search_array | t | f | f | f | f | f | f
106 search_nulls | t | f | t | t | t | f | t
111 pg_index_has_property('onek_hundred'::regclass, prop) as btree,
112 pg_index_has_property('hash_i4_index'::regclass, prop) as hash,
113 pg_index_has_property('gcircleind'::regclass, prop) as gist,
114 pg_index_has_property('sp_radix_ind'::regclass, prop) as spgist,
115 pg_index_has_property('botharrayidx'::regclass, prop) as gin,
116 pg_index_has_property('brinidx'::regclass, prop) as brin
117 from unnest(array['clusterable', 'index_scan', 'bitmap_scan',
120 with ordinality as u(prop,ord)
122 prop | btree | hash | gist | spgist | gin | brin
123 ---------------+-------+------+------+--------+-----+------
124 clusterable | t | f | t | f | f | f
125 index_scan | t | t | t | t | f | f
126 bitmap_scan | t | t | t | t | t | t
127 backward_scan | t | t | f | f | f | f
131 select amname, prop, pg_indexam_has_property(a.oid, prop) as p
133 unnest(array['can_order', 'can_unique', 'can_multi_col',
134 'can_exclude', 'can_include', 'bogus']::text[])
135 with ordinality as u(prop,ord)
137 order by amname, ord;
139 --------+---------------+---
141 brin | can_unique | f
142 brin | can_multi_col | t
143 brin | can_exclude | f
144 brin | can_include | f
146 btree | can_order | t
147 btree | can_unique | t
148 btree | can_multi_col | t
149 btree | can_exclude | t
150 btree | can_include | t
154 gin | can_multi_col | t
155 gin | can_exclude | f
156 gin | can_include | f
159 gist | can_unique | f
160 gist | can_multi_col | t
161 gist | can_exclude | t
162 gist | can_include | t
165 hash | can_unique | f
166 hash | can_multi_col | f
167 hash | can_exclude | t
168 hash | can_include | f
170 spgist | can_order | f
171 spgist | can_unique | f
172 spgist | can_multi_col | f
173 spgist | can_exclude | t
174 spgist | can_include | t
179 -- additional checks for pg_index_column_has_property
181 CREATE TEMP TABLE foo (f1 int, f2 int, f3 int, f4 int);
182 CREATE INDEX fooindex ON foo (f1 desc, f2 asc, f3 nulls first, f4 nulls last);
183 select col, prop, pg_index_column_has_property(o, col, prop)
184 from (values ('fooindex'::regclass)) v1(o),
185 (values (1,'orderable'),(2,'asc'),(3,'desc'),
186 (4,'nulls_first'),(5,'nulls_last'),
187 (6, 'bogus')) v2(idx,prop),
188 generate_series(1,4) col
190 col | prop | pg_index_column_has_property
191 -----+-------------+------------------------------
218 CREATE INDEX foocover ON foo (f1) INCLUDE (f2,f3);
219 select col, prop, pg_index_column_has_property(o, col, prop)
220 from (values ('foocover'::regclass)) v1(o),
221 (values (1,'orderable'),(2,'asc'),(3,'desc'),
222 (4,'nulls_first'),(5,'nulls_last'),
223 (6,'distance_orderable'),(7,'returnable'),
224 (8, 'bogus')) v2(idx,prop),
225 generate_series(1,3) col
227 col | prop | pg_index_column_has_property
228 -----+--------------------+------------------------------
234 1 | distance_orderable | f
242 2 | distance_orderable | f
250 3 | distance_orderable | f