Skip to content

Commit d11d8d0

Browse files
committed
Fix time_larger, time_smaller, timetz_larger, timetz_smaller to meet
nodeAgg.c's expectation that aggregate transition functions never return pointers to their input values. This is fixed in a much better way in current sources, but in 7.0.* it's gotta be done like this.
1 parent 4093838 commit d11d8d0

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/backend/utils/adt/date.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.44 2000/04/12 17:15:48 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.44.2.1 2000/10/19 20:52:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -495,13 +495,23 @@ time_cmp(TimeADT *time1, TimeADT *time2)
495495
TimeADT *
496496
time_larger(TimeADT *time1, TimeADT *time2)
497497
{
498-
return time_gt(time1, time2) ? time1 : time2;
498+
TimeADT *result;
499+
500+
/* nodeAgg.c expects me to return a copied datum! */
501+
result = palloc(sizeof(*result));
502+
*result = time_gt(time1, time2) ? *time1 : *time2;
503+
return result;
499504
} /* time_larger() */
500505

501506
TimeADT *
502507
time_smaller(TimeADT *time1, TimeADT *time2)
503508
{
504-
return time_lt(time1, time2) ? time1 : time2;
509+
TimeADT *result;
510+
511+
/* nodeAgg.c expects me to return a copied datum! */
512+
result = palloc(sizeof(*result));
513+
*result = time_lt(time1, time2) ? *time1 : *time2;
514+
return result;
505515
} /* time_smaller() */
506516

507517
/* overlaps_time()
@@ -742,13 +752,23 @@ timetz_cmp(TimeTzADT *time1, TimeTzADT *time2)
742752
TimeTzADT *
743753
timetz_larger(TimeTzADT *time1, TimeTzADT *time2)
744754
{
745-
return timetz_gt(time1, time2) ? time1 : time2;
755+
TimeTzADT *result;
756+
757+
/* nodeAgg.c expects me to return a copied datum! */
758+
result = palloc(sizeof(*result));
759+
*result = timetz_gt(time1, time2) ? *time1 : *time2;
760+
return result;
746761
} /* timetz_larger() */
747762

748763
TimeTzADT *
749764
timetz_smaller(TimeTzADT *time1, TimeTzADT *time2)
750765
{
751-
return timetz_lt(time1, time2) ? time1 : time2;
766+
TimeTzADT *result;
767+
768+
/* nodeAgg.c expects me to return a copied datum! */
769+
result = palloc(sizeof(*result));
770+
*result = timetz_lt(time1, time2) ? *time1 : *time2;
771+
return result;
752772
} /* timetz_smaller() */
753773

754774
/* overlaps_timetz()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy