Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b8bca3

Browse files
committed
Fix memory arrangement of tsquery after removing stop words. It causes
a unused memory holes in tsquery.Per report by Richard Huxton <dev@archonet.com>.It was working well because in fact tsquery->size is not used for anykind of operation except comparing tsqueries. So, in HEAD it's enough tofix to_tsquery function, but for previous version it's needed toremove optimization in CompareTSQ to prevent requirement of renew allstored tsquery.
1 parent588d213 commit3b8bca3

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎src/backend/tsearch/to_tsany.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.9 2008/03/05 15:50:37 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.10 2008/03/07 14:30:20 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -350,6 +350,18 @@ to_tsquery_byid(PG_FUNCTION_ARGS)
350350
PG_RETURN_POINTER(query);
351351
}
352352
memcpy((void*)GETQUERY(query), (void*)res,len*sizeof(QueryItem));
353+
354+
if (len!=query->size ) {
355+
char*oldoperand=GETOPERAND(query);
356+
int4lenoperand=VARSIZE(query)- (oldoperand- (char*)query);
357+
358+
Assert(len<query->size );
359+
360+
query->size=len;
361+
memcpy((void*)GETOPERAND(query),oldoperand,VARSIZE(query)- (oldoperand- (char*)query) );
362+
SET_VARSIZE(query,COMPUTESIZE(len,lenoperand ));
363+
}
364+
353365
pfree(res);
354366
PG_RETURN_TSQUERY(query);
355367
}
@@ -388,6 +400,18 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
388400
PG_RETURN_POINTER(query);
389401
}
390402
memcpy((void*)GETQUERY(query), (void*)res,len*sizeof(QueryItem));
403+
404+
if (len!=query->size ) {
405+
char*oldoperand=GETOPERAND(query);
406+
int4lenoperand=VARSIZE(query)- (oldoperand- (char*)query);
407+
408+
Assert(len<query->size );
409+
410+
query->size=len;
411+
memcpy((void*)GETOPERAND(query),oldoperand,lenoperand );
412+
SET_VARSIZE(query,COMPUTESIZE(len,lenoperand ));
413+
}
414+
391415
pfree(res);
392416
PG_RETURN_POINTER(query);
393417
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp