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

Commit47979e6

Browse files
committed
Fix memory leak for timestamp(with and w/o tz) and indexes
1 parent70b64cf commit47979e6

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

‎contrib/btree_gist/btree_time.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,45 @@ Datumgbt_time_penalty(PG_FUNCTION_ARGS);
3030
Datumgbt_time_same(PG_FUNCTION_ARGS);
3131

3232

33+
#defineP_TimeADTGetDatum(x)PointerGetDatum( &(x) )
34+
3335
staticbool
3436
gbt_timegt(constvoid*a,constvoid*b)
3537
{
3638
returnDatumGetBool(
37-
DirectFunctionCall2(time_gt,TimeADTGetDatum(*((TimeADT*)a)),TimeADTGetDatum(*((TimeADT*)b)))
39+
DirectFunctionCall2(time_gt,P_TimeADTGetDatum(*((TimeADT*)a)),P_TimeADTGetDatum(*((TimeADT*)b)))
3840
);
3941
}
4042

4143
staticbool
4244
gbt_timege(constvoid*a,constvoid*b)
4345
{
4446
returnDatumGetBool(
45-
DirectFunctionCall2(time_ge,TimeADTGetDatum(*((TimeADT*)a)),TimeADTGetDatum(*((TimeADT*)b)))
47+
DirectFunctionCall2(time_ge,P_TimeADTGetDatum(*((TimeADT*)a)),P_TimeADTGetDatum(*((TimeADT*)b)))
4648
);
4749
}
4850

4951
staticbool
5052
gbt_timeeq(constvoid*a,constvoid*b)
5153
{
5254
returnDatumGetBool(
53-
DirectFunctionCall2(time_eq,TimeADTGetDatum(*((TimeADT*)a)),TimeADTGetDatum(*((TimeADT*)b)))
55+
DirectFunctionCall2(time_eq,P_TimeADTGetDatum(*((TimeADT*)a)),P_TimeADTGetDatum(*((TimeADT*)b)))
5456
);
5557
}
5658

5759
staticbool
5860
gbt_timele(constvoid*a,constvoid*b)
5961
{
6062
returnDatumGetBool(
61-
DirectFunctionCall2(time_le,TimeADTGetDatum(*((TimeADT*)a)),TimeADTGetDatum(*((TimeADT*)b)))
63+
DirectFunctionCall2(time_le,P_TimeADTGetDatum(*((TimeADT*)a)),P_TimeADTGetDatum(*((TimeADT*)b)))
6264
);
6365
}
6466

6567
staticbool
6668
gbt_timelt(constvoid*a,constvoid*b)
6769
{
6870
returnDatumGetBool(
69-
DirectFunctionCall2(time_lt,TimeADTGetDatum(*((TimeADT*)a)),TimeADTGetDatum(*((TimeADT*)b)))
71+
DirectFunctionCall2(time_lt,P_TimeADTGetDatum(*((TimeADT*)a)),P_TimeADTGetDatum(*((TimeADT*)b)))
7072
);
7173
}
7274

@@ -202,17 +204,17 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
202204

203205
intr=DatumGetIntervalP(DirectFunctionCall2(
204206
time_mi_time,
205-
TimeADTGetDatum(newentry->upper),
206-
TimeADTGetDatum(origentry->upper)));
207+
P_TimeADTGetDatum(newentry->upper),
208+
P_TimeADTGetDatum(origentry->upper)));
207209

208210
/* see interval_larger */
209211
res=Max(intr->time+intr->month* (30*86400),0);
210212
pfree(intr);
211213

212214
intr=DatumGetIntervalP(DirectFunctionCall2(
213215
time_mi_time,
214-
TimeADTGetDatum(origentry->lower),
215-
TimeADTGetDatum(newentry->lower)));
216+
P_TimeADTGetDatum(origentry->lower),
217+
P_TimeADTGetDatum(newentry->lower)));
216218

217219
/* see interval_larger */
218220
res+=Max(intr->time+intr->month* (30*86400),0);
@@ -224,8 +226,8 @@ gbt_time_penalty(PG_FUNCTION_ARGS)
224226
{
225227
intr=DatumGetIntervalP(DirectFunctionCall2(
226228
time_mi_time,
227-
TimeADTGetDatum(origentry->upper),
228-
TimeADTGetDatum(origentry->lower)));
229+
P_TimeADTGetDatum(origentry->upper),
230+
P_TimeADTGetDatum(origentry->lower)));
229231
*result+=FLT_MIN;
230232
*result+= (float) (res / ((double) (res+intr->time+intr->month* (30*86400))));
231233
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));

‎contrib/btree_gist/btree_ts.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Datumgbt_ts_penalty(PG_FUNCTION_ARGS);
2929
Datumgbt_ts_same(PG_FUNCTION_ARGS);
3030

3131

32+
#defineP_TimestampGetDatum(x) PointerGetDatum( &(x) )
33+
3234
staticbool
3335
gbt_tsgt(constvoid*a,constvoid*b)
3436
{
@@ -231,8 +233,8 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
231233

232234
intr=DatumGetIntervalP(DirectFunctionCall2(
233235
timestamp_mi,
234-
TimestampGetDatum(newentry->upper),
235-
TimestampGetDatum(origentry->upper)
236+
P_TimestampGetDatum(newentry->upper),
237+
P_TimestampGetDatum(origentry->upper)
236238
));
237239

238240
/* see interval_larger */
@@ -242,8 +244,8 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
242244

243245
intr=DatumGetIntervalP(DirectFunctionCall2(
244246
timestamp_mi,
245-
TimestampGetDatum(origentry->lower),
246-
TimestampGetDatum(newentry->lower)
247+
P_TimestampGetDatum(origentry->lower),
248+
P_TimestampGetDatum(newentry->lower)
247249
));
248250

249251
/* see interval_larger */
@@ -256,8 +258,8 @@ gbt_ts_penalty(PG_FUNCTION_ARGS)
256258
{
257259
intr=DatumGetIntervalP(DirectFunctionCall2(
258260
timestamp_mi,
259-
TimestampGetDatum(origentry->upper),
260-
TimestampGetDatum(origentry->lower)
261+
P_TimestampGetDatum(origentry->upper),
262+
P_TimestampGetDatum(origentry->lower)
261263
));
262264
*result+=FLT_MIN;
263265
*result+= (float) (res / ((double) (res+intr->time+intr->month* (30*86400))));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp