int64/double for time/timestamp - Mailing list pgsql-hackers

From Teodor Sigaev
Subject int64/double for time/timestamp
Date
Msg-id 421B0A29.40004@sigaev.ru
Whole thread Raw
Responses Re: int64/double for time/timestamp
List pgsql-hackers
Hi!

I work on memory leaks during creation index on time/timestamp column using GiST 
and found follow problem (?):

For timestamp storage and defines are defined as (from utils/timestamp.h):
#ifdef HAVE_INT64_TIMESTAMP

typedef int64 Timestamp;
#define TimestampGetDatum(X) Int64GetDatum(X)
#define DatumGetTimestamp(X)  ((Timestamp) DatumGetInt64(X))

#else

typedef double Timestamp;
#define TimestampGetDatum(X) Float8GetDatum(X)
#define DatumGetTimestamp(X)  ((Timestamp) DatumGetFloat8(X))

#endif

It looks consistently, but for time (from utils/date.h):

ifdef HAVE_INT64_TIMESTAMP
typedef int64 TimeADT;

#else
typedef float8 TimeADT;
#endif

#define TimeADTGetDatum(X)        Float8GetDatum(X)
#define DatumGetTimeADT(X)        ((TimeADT) DatumGetFloat8(X))

So, in case HAVE_INT64_TIMESTAMP int64 may use as float8.  Is it correct?


It seems to me, that my last changes in btree_gist produce a error for 
btree_time on some architectures for this reason, but the same changes for 
timestamp doesn't produce ones.


-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql: recall previous command?
Next
From: Robert Treat
Date:
Subject: Re: Get rid of system attributes in pg_attribute?