@@ -42,7 +42,7 @@ typedef struct
42
42
bool * need_recheck ;
43
43
Datum * addInfo ;
44
44
bool * addInfoIsNull ;
45
- bool notPhrase ;
45
+ bool recheckPhrase ;
46
46
} RumChkVal ;
47
47
48
48
typedef struct
@@ -176,29 +176,39 @@ checkcondition_rum(void *checkval, QueryOperand *val, ExecPhraseData *data)
176
176
/*
177
177
* Fill position list for phrase operator if it's needed end it exists
178
178
*/
179
- if (data && gcv -> addInfo && gcv -> addInfoIsNull [ j ] == false )
179
+ if (data )
180
180
{
181
- bytea * positions ;
182
- int32 i ;
183
- char * ptrt ;
184
- WordEntryPos post ;
181
+ /* caller wants an array of positions (phrase search) */
185
182
186
- if (gcv -> notPhrase )
187
- elog (ERROR , "phrase search isn't supported yet" );
183
+ if (gcv -> recheckPhrase )
184
+ {
185
+ /*
186
+ * we don't have a positions because we store a timestamp in
187
+ * addInfo
188
+ */
189
+ * (gcv -> need_recheck ) = true;
190
+ }
191
+ else if (gcv -> addInfo && gcv -> addInfoIsNull [j ] == false)
192
+ {
193
+ bytea * positions ;
194
+ int32 i ;
195
+ char * ptrt ;
196
+ WordEntryPos post ;
188
197
189
- positions = DatumGetByteaP (gcv -> addInfo [j ]);
190
- data -> npos = count_pos (VARDATA_ANY (positions ),
191
- VARSIZE_ANY_EXHDR (positions ));
192
- data -> pos = palloc (sizeof (* data -> pos ) * data -> npos );
193
- data -> allocated = true;
198
+ positions = DatumGetByteaP (gcv -> addInfo [j ]);
199
+ data -> npos = count_pos (VARDATA_ANY (positions ),
200
+ VARSIZE_ANY_EXHDR (positions ));
201
+ data -> pos = palloc (sizeof (* data -> pos ) * data -> npos );
202
+ data -> allocated = true;
194
203
195
- ptrt = (char * ) VARDATA_ANY (positions );
196
- post = 0 ;
204
+ ptrt = (char * ) VARDATA_ANY (positions );
205
+ post = 0 ;
197
206
198
- for (i = 0 ; i < data -> npos ; i ++ )
199
- {
200
- ptrt = decompress_pos (ptrt , & post );
201
- data -> pos [i ] = post ;
207
+ for (i = 0 ; i < data -> npos ; i ++ )
208
+ {
209
+ ptrt = decompress_pos (ptrt , & post );
210
+ data -> pos [i ] = post ;
211
+ }
202
212
}
203
213
}
204
214
@@ -240,9 +250,9 @@ rum_tsquery_consistent(PG_FUNCTION_ARGS)
240
250
gcv .need_recheck = recheck ;
241
251
gcv .addInfo = addInfo ;
242
252
gcv .addInfoIsNull = addInfoIsNull ;
243
- gcv .notPhrase = false;
253
+ gcv .recheckPhrase = false;
244
254
245
- res = TS_execute (GETQUERY (query ), & gcv , true , checkcondition_rum );
255
+ res = TS_execute (GETQUERY (query ), & gcv , TS_EXEC_EMPTY , checkcondition_rum );
246
256
}
247
257
248
258
PG_RETURN_BOOL (res );
@@ -283,9 +293,9 @@ rum_tsquery_timestamp_consistent(PG_FUNCTION_ARGS)
283
293
gcv .need_recheck = recheck ;
284
294
gcv .addInfo = addInfo ;
285
295
gcv .addInfoIsNull = addInfoIsNull ;
286
- gcv .notPhrase = true;
296
+ gcv .recheckPhrase = true;
287
297
288
- res = TS_execute (GETQUERY (query ), & gcv , true , checkcondition_rum );
298
+ res = TS_execute (GETQUERY (query ), & gcv , TS_EXEC_PHRASE_AS_AND , checkcondition_rum );
289
299
}
290
300
291
301
PG_RETURN_BOOL (res );
0 commit comments