Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19da69a

Browse files
committed
check whether index column opclass is spoint2
1 parent 65145e6 commit 19da69a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

init.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ pick_suitable_index(Oid relation, AttrNumber column)
107107
HeapTuple htup;
108108
SysScanDesc scan;
109109
Relation pg_index;
110+
List *spoint2_opclass_name;
111+
Oid spoint2_opclass;
110112
ScanKeyData key[3];
111113

114+
spoint2_opclass_name = stringToQualifiedNameList("public.spoint2");
115+
spoint2_opclass = get_opclass_oid(GIST_AM_OID, spoint2_opclass_name, false);
116+
112117
ScanKeyInit(&key[0],
113118
Anum_pg_index_indrelid,
114119
BTEqualStrategyNumber,
@@ -146,9 +151,18 @@ pick_suitable_index(Oid relation, AttrNumber column)
146151
PointerGetDatum(cstring_to_text("main"))));
147152

148153
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 */
152166
}
153167
}
154168
}

0 commit comments

Comments
 (0)