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{
3957TS_NO ,/* definitely no match */
4058TS_YES ,/* definitely does match */
4159TS_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{
186208RumChkVal * 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 */
194216j = 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 ] );
220+ #else
197221return gcv -> check [j ];
222+ #endif
198223}
199224
200225Datum
@@ -219,10 +244,17 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
219244gcv .map_item_operand = (int * ) (extra_data [0 ]);
220245gcv .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
222253res = TS_execute (GETQUERY (query ),
223254& gcv ,
224255TS_EXEC_PHRASE_NO_POS ,
225256pre_checkcondition_rum );
257+ #endif
226258}
227259
228260PG_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
14701505if (TS_execute (GETQUERY (qr -> query ), (void * )qr ,TS_EXEC_EMPTY ,
14711506checkcondition_QueryOperand ))
1507+ #endif
14721508{
14731509if (ptr -> pos > ext -> q )
14741510{
@@ -1508,8 +1544,13 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
15081544WEP_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
15111551if (TS_execute (GETQUERY (qr -> query ), (void * )qr ,TS_EXEC_CALC_NOT ,
15121552checkcondition_QueryOperand ))
1553+ #endif
15131554{
15141555if (ptr -> pos < ext -> p )
15151556{