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

Commit60555bd

Browse files
committed
Please, apply attached patch of contrib/btree_gist to 7.2.1 and currentcvs.The patch fixes memory leak during creation GiST index on timestampcolumn.Thank you.--Teodor Sigaevteodor@stack.net
1 parent4633ee2 commit60555bd

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

‎contrib/btree_gist/btree_gist.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Datumgts_same(PG_FUNCTION_ARGS);
8686
staticvoidgts_binary_union(Datum*r1,char*r2);
8787
staticinttskey_cmp(constvoid*a,constvoid*b);
8888

89+
#defineTimestampGetDatumFast(X) Float8GetDatumFast(X)
90+
8991
/* define for comparison */
9092
#defineTSGE(ts1,ts2 ) (DatumGetBool(DirectFunctionCall2( \
9193
timestamp_ge, \
@@ -297,23 +299,11 @@ gts_compress(PG_FUNCTION_ARGS)
297299
if (entry->leafkey)
298300
{
299301
TSKEY*r= (TSKEY*)palloc(sizeof(TSKEY));
300-
301302
retval=palloc(sizeof(GISTENTRY));
302-
if (entry->key)
303-
{
304-
r->lower=r->upper=*(Timestamp*) (entry->key);
305-
306-
gistentryinit(*retval,PointerGetDatum(r),
307-
entry->rel,entry->page,
308-
entry->offset,sizeof(TSKEY), FALSE);
309-
310-
}
311-
else
312-
{
313-
gistentryinit(*retval,PointerGetDatum(NULL),
314-
entry->rel,entry->page,
315-
entry->offset,0, FALSE);
316-
}
303+
r->lower=r->upper=*(Timestamp*) (entry->key);
304+
gistentryinit(*retval,PointerGetDatum(r),
305+
entry->rel,entry->page,
306+
entry->offset,sizeof(TSKEY), FALSE);
317307
}
318308
else
319309
retval=entry;
@@ -408,17 +398,17 @@ gts_penalty(PG_FUNCTION_ARGS)
408398

409399
intr=DatumGetIntervalP(DirectFunctionCall2(
410400
timestamp_mi,
411-
TimestampGetDatum(newentry->upper),
412-
TimestampGetDatum(origentry->upper)));
401+
TimestampGetDatumFast(newentry->upper),
402+
TimestampGetDatumFast(origentry->upper)));
413403

414404
/* see interval_larger */
415405
*result=Max(intr->time+intr->month* (30.0*86400),0);
416406
pfree(intr);
417407

418408
intr=DatumGetIntervalP(DirectFunctionCall2(
419409
timestamp_mi,
420-
TimestampGetDatum(origentry->lower),
421-
TimestampGetDatum(newentry->lower)));
410+
TimestampGetDatumFast(origentry->lower),
411+
TimestampGetDatumFast(newentry->lower)));
422412

423413
/* see interval_larger */
424414
*result+=Max(intr->time+intr->month* (30.0*86400),0);
@@ -483,8 +473,8 @@ tskey_cmp(const void *a, const void *b)
483473
returnDatumGetInt32(
484474
DirectFunctionCall2(
485475
timestamp_cmp,
486-
TimestampGetDatum(((TSKEY*) (((RIX*)a)->r))->lower),
487-
TimestampGetDatum(((TSKEY*) (((RIX*)b)->r))->lower)
476+
TimestampGetDatumFast(((TSKEY*) (((RIX*)a)->r))->lower),
477+
TimestampGetDatumFast(((TSKEY*) (((RIX*)b)->r))->lower)
488478
)
489479
);
490480
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp