File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
342
342
if (query -> size == 0 )
343
343
PG_RETURN_TSQUERY (query );
344
344
345
+ /* clean out any stopword placeholders from the tree */
345
346
res = clean_fakeval (GETQUERY (query ), & len );
346
347
if (!res )
347
348
{
@@ -351,6 +352,10 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
351
352
}
352
353
memcpy ((void * ) GETQUERY (query ), (void * ) res , len * sizeof (QueryItem ));
353
354
355
+ /*
356
+ * Removing the stopword placeholders might've resulted in fewer
357
+ * QueryItems. If so, move the operands up accordingly.
358
+ */
354
359
if (len != query -> size )
355
360
{
356
361
char * oldoperand = GETOPERAND (query );
@@ -359,7 +364,7 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
359
364
Assert (len < query -> size );
360
365
361
366
query -> size = len ;
362
- memcpy ((void * ) GETOPERAND (query ), oldoperand , VARSIZE (query ) - (oldoperand - (char * ) query ));
367
+ memmove ((void * ) GETOPERAND (query ), oldoperand , VARSIZE (query ) - (oldoperand - (char * ) query ));
363
368
SET_VARSIZE (query , COMPUTESIZE (len , lenoperand ));
364
369
}
365
370
You can’t perform that action at this time.
0 commit comments