34
34
#define TS_EXEC_PHRASE_NO_POS TS_EXEC_PHRASE_AS_AND
35
35
#endif
36
36
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
37
55
typedef enum
38
56
{
39
57
TS_NO , /* definitely no match */
40
58
TS_YES , /* definitely does match */
41
59
TS_MAYBE /* can't verify match for lack of pos data */
42
60
} RumTernaryValue ;
61
+ #endif
43
62
typedef RumTernaryValue (* RumExecuteCallbackTernary ) (void * arg , QueryOperand * val , ExecPhraseData * data );
44
63
45
-
46
64
PG_FUNCTION_INFO_V1 (rum_extract_tsvector );
47
65
PG_FUNCTION_INFO_V1 (rum_extract_tsvector_hash );
48
66
PG_FUNCTION_INFO_V1 (rum_extract_tsquery );
@@ -180,7 +198,11 @@ static WordEntryPosVector POSNULL = {
180
198
#define QR_GET_OPERAND (q , v ) \
181
199
(&((q)->operandData[ ((QueryItem*)(v)) - GETQUERY((q)->query) ]))
182
200
201
+ #if PG_VERSION_NUM >= 130000
202
+ static TSTernaryValue
203
+ #else
183
204
static bool
205
+ #endif
184
206
pre_checkcondition_rum (void * checkval , QueryOperand * val , ExecPhraseData * data )
185
207
{
186
208
RumChkVal * gcv = (RumChkVal * ) checkval ;
@@ -192,9 +214,12 @@ pre_checkcondition_rum(void *checkval, QueryOperand *val, ExecPhraseData *data)
192
214
193
215
/* convert item's number to corresponding entry's (operand's) number */
194
216
j = gcv -> map_item_operand [((QueryItem * ) val ) - gcv -> first_item ];
195
-
196
217
/* 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
197
221
return gcv -> check [j ];
222
+ #endif
198
223
}
199
224
200
225
Datum
@@ -203,7 +228,7 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
203
228
bool * check = (bool * ) PG_GETARG_POINTER (0 );
204
229
TSQuery query = PG_GETARG_TSQUERY (2 );
205
230
Pointer * extra_data = (Pointer * ) PG_GETARG_POINTER (4 );
206
- bool recheck ;
231
+ bool recheck = false ;
207
232
bool res = false;
208
233
209
234
if (query -> size > 0 )
@@ -219,10 +244,17 @@ rum_tsquery_pre_consistent(PG_FUNCTION_ARGS)
219
244
gcv .map_item_operand = (int * ) (extra_data [0 ]);
220
245
gcv .need_recheck = & recheck ;
221
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
222
253
res = TS_execute (GETQUERY (query ),
223
254
& gcv ,
224
255
TS_EXEC_PHRASE_NO_POS ,
225
256
pre_checkcondition_rum );
257
+ #endif
226
258
}
227
259
228
260
PG_RETURN_BOOL (res );
@@ -1466,9 +1498,13 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
1466
1498
}
1467
1499
}
1468
1500
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
1470
1505
if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_EMPTY ,
1471
1506
checkcondition_QueryOperand ))
1507
+ #endif
1472
1508
{
1473
1509
if (ptr -> pos > ext -> q )
1474
1510
{
@@ -1508,8 +1544,13 @@ Cover(DocRepresentation *doc, uint32 len, QueryRepresentation *qr,
1508
1544
WEP_SETWEIGHT (qro -> pos , ptr -> wclass );
1509
1545
}
1510
1546
}
1547
+ #if PG_VERSION_NUM >= 130000
1548
+ if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_EMPTY ,
1549
+ (TSExecuteCallback ) checkcondition_QueryOperand ))
1550
+ #else
1511
1551
if (TS_execute (GETQUERY (qr -> query ), (void * ) qr , TS_EXEC_CALC_NOT ,
1512
1552
checkcondition_QueryOperand ))
1553
+ #endif
1513
1554
{
1514
1555
if (ptr -> pos < ext -> p )
1515
1556
{
0 commit comments