aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/timestamp.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-11-21 18:29:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-11-21 18:29:48 +0000
commitdcdf9119a8e4a75cc5a0ad4db79ac2a1b5c42d95 (patch)
tree4d938dacb3e0a42d9d9a9719616c85b6bc95d60b /src/backend/utils/adt/timestamp.c
parent52ca149b362202828b271b9294676fa193cd57c5 (diff)
downloadpostgresql-dcdf9119a8e4a75cc5a0ad4db79ac2a1b5c42d95.tar.gz
postgresql-dcdf9119a8e4a75cc5a0ad4db79ac2a1b5c42d95.zip
Tweak interval_avg support to avoid coredump with Alpha/Tru64 compiler.
Per report from Bernd Tegge.
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r--src/backend/utils/adt/timestamp.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index 7bb5bcab882..490e7beb1d0 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.59 2001/10/25 05:49:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.60 2001/11/21 18:29:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1570,9 +1570,12 @@ interval_accum(PG_FUNCTION_ARGS)
* buggy array code: it won't ensure proper alignment of Interval
* objects on machines where double requires 8-byte alignment. That
* should be fixed, but in the meantime...
+ *
+ * Note: must use DatumGetPointer here, not DatumGetIntervalP,
+ * else some compilers optimize into double-aligned load/store anyway.
*/
- memcpy(&sumX, DatumGetIntervalP(transdatums[0]), sizeof(Interval));
- memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval));
+ memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval));
+ memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval));
newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
IntervalPGetDatum(&sumX),
@@ -1609,9 +1612,12 @@ interval_avg(PG_FUNCTION_ARGS)
* buggy array code: it won't ensure proper alignment of Interval
* objects on machines where double requires 8-byte alignment. That
* should be fixed, but in the meantime...
+ *
+ * Note: must use DatumGetPointer here, not DatumGetIntervalP,
+ * else some compilers optimize into double-aligned load/store anyway.
*/
- memcpy(&sumX, DatumGetIntervalP(transdatums[0]), sizeof(Interval));
- memcpy(&N, DatumGetIntervalP(transdatums[1]), sizeof(Interval));
+ memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval));
+ memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval));
/* SQL92 defines AVG of no values to be NULL */
if (N.time == 0)