3434#define TS_EXEC_PHRASE_NO_POS TS_EXEC_PHRASE_AS_AND
3535#endif
3636
37+ #if PG_VERSION_NUM >= 130000
38+ /* Since v13 TS_execute flag naming and defaults have reverted:
39+ * - before v13 - - since v13 -
40+ * TS_EXEC_CALC_NOT (0x01) TS_EXEC_SKIP_NOT (0x01)
41+ */
42+ #define TS_EXEC_CALC_NOT (0x01) /* Defined here for use with rum_TS_execute for
43+ * compatibility with version < 13 where this
44+ * flag was defined globally.
45+ * XXX Since v13 current global flag
46+ * TS_EXEC_SKIP_NOT has reverted meaning for
47+ * TS_execute but TS_EXEC_CALC_NOT should still
48+ * be passed to rum_TS_execute in unchanged (previous)
49+ * meaning but should not be passed into TS_execute:
50+ * (TS_execute will do 'calc not' by default, and
51+ * if you need skip it, use new TS_EXEC_SKIP_NOT)
52+ */
53+ typedef TSTernaryValue RumTernaryValue ;
54+ #else
3755typedef enum
3856{
3957 TS_NO , /* definitely no match */
4058 TS_YES , /* definitely does match */
4159 TS_MAYBE /* can't verify match for lack of pos data */
4260} RumTernaryValue ;
61+ #endif
4362typedef RumTernaryValue (* RumExecuteCallbackTernary ) (void * arg , QueryOperand * val , ExecPhraseData * data );
4463
45-
4664PG_FUNCTION_INFO_V1 (rum_extract_tsvector );
4765PG_FUNCTION_INFO_V1 (rum_extract_tsvector_hash );
4866PG_FUNCTION_INFO_V1 (rum_extract_tsquery );
@@ -180,7 +198,11 @@ static WordEntryPosVector POSNULL = {
180198#define QR_GET_OPERAND (q , v ) \
181199 (&((q)->operandData[ ((QueryItem*)(v)) - GETQUERY((q)->query) ]))
182200
201+ #if PG_VERSION_NUM >= 130000
202+ static TSTernaryValue
203+ #else
183204static bool
205+ #endif
184206pre_checkcondition_rum (void * checkval , QueryOperand * val , ExecPhraseData * data )
185207{
186208 RumChkVal * gcv = (RumChkVal * ) checkval ;
@@ -192,9 +214,12 @@ pre_checkcondition_rum(void *checkval, QueryOperand *val, ExecPhraseData *data)
192214
193215 /* convert item's number to corresponding entry's (operand's) number */
194216 j = gcv -> map_item_operand [((QueryItem * ) val ) - gcv -> first_item ];
195-
196217 /* return presence of current entry in indexed value */
218+ #if PG_VERSION_NUM >= 130000
219+ return ( * (gcv -> need_recheck ) ? TS_MAYBE : (gcv -> check [j ] ? TS_YES : TS_NO ) );
220+ #else
197221 return gcv -> check [j ];
222+ #endif
198223}
199224
200225Datum
@@ -203,7 +228,7 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
203228 bool * check = (bool * ) PG_GETARG_POINTER (0 );
204229 TSQuery query = PG_GETARG_TSQUERY (2 );
205230 Pointer * extra_data = (Pointer * ) PG_GETARG_POINTER (4 );
206- bool recheck ;
231+ bool recheck = false ;
207232 bool res = false;
208233
209234 if (query -> size > 0 )
@@ -219,10 +244,17 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
219244 gcv .map_item_operand = (int * ) (extra_data [0 ]);
220245 gcv .need_recheck = & recheck ;
221246
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
222253 res = TS_execute (GETQUERY (query ),
223254 & gcv ,
224255 TS_EXEC_PHRASE_NO_POS ,
225256 pre_checkcondition_rum );
257+ #endif
226258 }
227259
228260 PG_RETURN_BOOL (res );
@@ -1466,9 +1498,13 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
14661498 }
14671499 }
14681500
1469-
1501+ #if PG_VERSION_NUM >= 130000
1502+ if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_SKIP_NOT ,
1503+ (TSExecuteCallback ) checkcondition_QueryOperand ))
1504+ #else
14701505 if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_EMPTY ,
14711506 checkcondition_QueryOperand ))
1507+ #endif
14721508 {
14731509 if (ptr -> pos > ext -> q )
14741510 {
@@ -1508,8 +1544,13 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
15081544 WEP_SETWEIGHT (qro -> pos , ptr -> wclass );
15091545 }
15101546 }
1547+ #if PG_VERSION_NUM >= 130000
1548+ if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_EMPTY ,
1549+ (TSExecuteCallback ) checkcondition_QueryOperand ))
1550+ #else
15111551 if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_CALC_NOT ,
15121552 checkcondition_QueryOperand ))
1553+ #endif
15131554 {
15141555 if (ptr -> pos < ext -> p )
15151556 {
0 commit comments