Skip to content

Commit 0ed7445

Browse files
committed
Allow spgist's text_ops to handle pattern-matching operators.
This was presumably intended to work this way all along, but a few key bits of indxpath.c didn't get the memo. Robert Haas and Tom Lane
1 parent b4e0741 commit 0ed7445

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2847,7 +2847,7 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
28472847
/*
28482848
* Must also check that index's opfamily supports the operators we will
28492849
* want to apply. (A hash index, for example, will not support ">=".)
2850-
* Currently, only btree supports the operators we need.
2850+
* Currently, only btree and spgist support the operators we need.
28512851
*
28522852
* Note: actually, in the Pattern_Prefix_Exact case, we only need "=" so a
28532853
* hash index would work. Currently it doesn't seem worth checking for
@@ -2871,6 +2871,7 @@ match_special_index_operator(Expr *clause, Oid opfamily, Oid idxcollation,
28712871
case OID_TEXT_ICREGEXEQ_OP:
28722872
isIndexable =
28732873
(opfamily == TEXT_PATTERN_BTREE_FAM_OID) ||
2874+
(opfamily == TEXT_SPGIST_FAM_OID) ||
28742875
(opfamily == TEXT_BTREE_FAM_OID &&
28752876
(pstatus == Pattern_Prefix_Exact ||
28762877
lc_collate_is_c(idxcollation)));
@@ -3454,6 +3455,7 @@ prefix_quals(Node *leftop, Oid opfamily, Oid collation,
34543455
{
34553456
case TEXT_BTREE_FAM_OID:
34563457
case TEXT_PATTERN_BTREE_FAM_OID:
3458+
case TEXT_SPGIST_FAM_OID:
34573459
datatype = TEXTOID;
34583460
break;
34593461

src/include/catalog/pg_opfamily.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,6 @@ DATA(insert OID = 3919 ( 783 range_ops PGNSP PGUID ));
145145
DATA(insert OID = 4015 ( 4000 quad_point_ops PGNSP PGUID ));
146146
DATA(insert OID = 4016 ( 4000 kd_point_ops PGNSP PGUID ));
147147
DATA(insert OID = 4017 ( 4000 text_ops PGNSP PGUID ));
148+
#define TEXT_SPGIST_FAM_OID 4017
148149

149150
#endif /* PG_OPFAMILY_H */

0 commit comments

Comments
 (0)