@@ -244,19 +244,15 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
244
244
gcv .map_item_operand = (int * ) (extra_data [0 ]);
245
245
gcv .need_recheck = & recheck ;
246
246
247
- #if PG_VERSION_NUM >= 130000
248
- res = TS_execute (GETQUERY (query ),
249
- & gcv ,
250
- TS_EXEC_PHRASE_NO_POS | TS_EXEC_SKIP_NOT ,
251
- pre_checkcondition_rum );
252
- #else
253
247
res = TS_execute (GETQUERY (query ),
254
248
& gcv ,
255
- TS_EXEC_PHRASE_NO_POS ,
256
- pre_checkcondition_rum );
249
+ TS_EXEC_PHRASE_NO_POS
250
+ #if PG_VERSION_NUM >= 130000
251
+ | TS_EXEC_SKIP_NOT
257
252
#endif
253
+ ,
254
+ pre_checkcondition_rum );
258
255
}
259
-
260
256
PG_RETURN_BOOL (res );
261
257
}
262
258
@@ -604,6 +600,14 @@ rum_phrase_execute(QueryItem *curitem, void *arg, uint32 flags,
604
600
605
601
if (curitem -> qoperator .oper == OP_PHRASE )
606
602
{
603
+ /* In case of index where position is not available
604
+ * (e.g. addon_ops) output TS_MAYBE even in case both
605
+ * lmatch and rmatch are TS_YES. Otherwise we can lose
606
+ * results of phrase queries.
607
+ */
608
+ if (flags & TS_EXEC_PHRASE_NO_POS )
609
+ return TS_MAYBE ;
610
+
607
611
/*
608
612
* Compute Loffset and Roffset suitable for phrase match, and
609
613
* compute overall width of whole phrase match.
@@ -840,6 +844,11 @@ rum_TS_execute(QueryItem *curitem, void *arg, uint32 flags,
840
844
* converting at the topmost phrase operator gives results that
841
845
* are bug-compatible with the old implementation, so do it like
842
846
* this for now.
847
+ *
848
+ * Checking for TS_EXEC_PHRASE_NO_POS has been moved inside
849
+ * rum_phrase_execute, otherwise we can lose results of phrase
850
+ * operator when position information is not available in index
851
+ * (e.g. index built with addon_ops)
843
852
*/
844
853
switch (rum_phrase_execute (curitem , arg , flags , chkcond , NULL ))
845
854
{
0 commit comments