|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.59 2001/10/25 05:49:45 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.60 2001/11/21 18:29:48 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -1570,9 +1570,12 @@ interval_accum(PG_FUNCTION_ARGS) |
1570 | 1570 | * buggy array code: it won't ensure proper alignment of Interval |
1571 | 1571 | * objects on machines where double requires 8-byte alignment. That |
1572 | 1572 | * should be fixed, but in the meantime... |
| 1573 | + * |
| 1574 | + * Note: must use DatumGetPointer here, not DatumGetIntervalP, |
| 1575 | + * else some compilers optimize into double-aligned load/store anyway. |
1573 | 1576 | */ |
1574 | | - memcpy(&sumX, DatumGetIntervalP(transdatums[0]), sizeof(Interval)); |
1575 | | - memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval)); |
| 1577 | + memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval)); |
| 1578 | + memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval)); |
1576 | 1579 |
|
1577 | 1580 | newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl, |
1578 | 1581 | IntervalPGetDatum(&sumX), |
@@ -1609,9 +1612,12 @@ interval_avg(PG_FUNCTION_ARGS) |
1609 | 1612 | * buggy array code: it won't ensure proper alignment of Interval |
1610 | 1613 | * objects on machines where double requires 8-byte alignment. That |
1611 | 1614 | * should be fixed, but in the meantime... |
| 1615 | + * |
| 1616 | + * Note: must use DatumGetPointer here, not DatumGetIntervalP, |
| 1617 | + * else some compilers optimize into double-aligned load/store anyway. |
1612 | 1618 | */ |
1613 | | - memcpy(&sumX, DatumGetIntervalP(transdatums[0]), sizeof(Interval)); |
1614 | | - memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval)); |
| 1619 | + memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval)); |
| 1620 | + memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval)); |
1615 | 1621 |
|
1616 | 1622 | /* SQL92 defines AVG of no values to be NULL */ |
1617 | 1623 | if (N.time == 0) |
|
0 commit comments