File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -107,8 +107,13 @@ pick_suitable_index(Oid relation, AttrNumber column)
107
107
HeapTuple htup ;
108
108
SysScanDesc scan ;
109
109
Relation pg_index ;
110
+ List * spoint2_opclass_name ;
111
+ Oid spoint2_opclass ;
110
112
ScanKeyData key [3 ];
111
113
114
+ spoint2_opclass_name = stringToQualifiedNameList ("public.spoint2" );
115
+ spoint2_opclass = get_opclass_oid (GIST_AM_OID , spoint2_opclass_name , false);
116
+
112
117
ScanKeyInit (& key [0 ],
113
118
Anum_pg_index_indrelid ,
114
119
BTEqualStrategyNumber ,
@@ -146,9 +151,18 @@ pick_suitable_index(Oid relation, AttrNumber column)
146
151
PointerGetDatum (cstring_to_text ("main" ))));
147
152
148
153
if (found_index == InvalidOid || cur_index_size < found_index_size )
149
- found_index = pg_ind -> indexrelid ;
150
-
151
- break ; /* no need to go further */
154
+ {
155
+ bool is_null ;
156
+ Datum indclass = heap_getattr (htup , Anum_pg_index_indclass ,
157
+ pg_index -> rd_att , & is_null );
158
+ oidvector * indclasses = (oidvector * ) DatumGetPointer (indclass );
159
+
160
+ /* column must use 'spoint2' opclass */
161
+ if (!is_null && indclasses -> values [i ] == spoint2_opclass )
162
+ found_index = pg_ind -> indexrelid ;
163
+ }
164
+
165
+ break ; /* no need to scan 'indkey' further */
152
166
}
153
167
}
154
168
}
You can’t perform that action at this time.
0 commit comments