8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.148 2005/08/12 18:23:54 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.149 2005/08/25 01:30:06 momjian Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1892,7 +1892,7 @@ timestamp_mi(PG_FUNCTION_ARGS)
1892
1892
{
1893
1893
Timestamp dt1 = PG_GETARG_TIMESTAMP (0 );
1894
1894
Timestamp dt2 = PG_GETARG_TIMESTAMP (1 );
1895
- Interval * result ;
1895
+ Interval * result , * result2 ;
1896
1896
1897
1897
result = (Interval * )palloc (sizeof (Interval ));
1898
1898
@@ -1914,9 +1914,10 @@ timestamp_mi(PG_FUNCTION_ARGS)
1914
1914
result -> month = 0 ;
1915
1915
result -> day = 0 ;
1916
1916
1917
- result = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
1917
+ result2 = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
1918
1918
IntervalPGetDatum (result )));
1919
- PG_RETURN_INTERVAL_P (result );
1919
+ pfree (result );
1920
+ PG_RETURN_INTERVAL_P (result2 );
1920
1921
}
1921
1922
1922
1923
/*interval_justify_hours()
@@ -2263,7 +2264,7 @@ interval_mul(PG_FUNCTION_ARGS)
2263
2264
Interval * span = PG_GETARG_INTERVAL_P (0 );
2264
2265
float8 factor = PG_GETARG_FLOAT8 (1 );
2265
2266
double month_remainder ,day_remainder ;
2266
- Interval * result ;
2267
+ Interval * result , * result2 ;
2267
2268
2268
2269
result = (Interval * )palloc (sizeof (Interval ));
2269
2270
@@ -2289,9 +2290,10 @@ interval_mul(PG_FUNCTION_ARGS)
2289
2290
day_remainder * SECS_PER_DAY );
2290
2291
#endif
2291
2292
2292
- result = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
2293
+ result2 = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
2293
2294
IntervalPGetDatum (result )));
2294
- PG_RETURN_INTERVAL_P (result );
2295
+ pfree (result );
2296
+ PG_RETURN_INTERVAL_P (result2 );
2295
2297
}
2296
2298
2297
2299
Datum
@@ -2310,7 +2312,7 @@ interval_div(PG_FUNCTION_ARGS)
2310
2312
Interval * span = PG_GETARG_INTERVAL_P (0 );
2311
2313
float8 factor = PG_GETARG_FLOAT8 (1 );
2312
2314
double month_remainder ,day_remainder ;
2313
- Interval * result ;
2315
+ Interval * result , * result2 ;
2314
2316
2315
2317
result = (Interval * )palloc (sizeof (Interval ));
2316
2318
@@ -2341,9 +2343,10 @@ interval_div(PG_FUNCTION_ARGS)
2341
2343
result -> time = JROUND (result -> time );
2342
2344
#endif
2343
2345
2344
- result = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
2346
+ result2 = DatumGetIntervalP (DirectFunctionCall1 (interval_justify_hours ,
2345
2347
IntervalPGetDatum (result )));
2346
- PG_RETURN_INTERVAL_P (result );
2348
+ pfree (result );
2349
+ PG_RETURN_INTERVAL_P (result2 );
2347
2350
}
2348
2351
2349
2352
/*