timestamp datatyp problem

Started by Mathias Palmover 18 years ago2 messages
#1Mathias Palm
m.palm@geoinsoft.de

Hi,

I have found a problem by using timestamp datatyp in postgresql. The
minimum value should be '4713-11-24 00:00:00 BC' but it's possible to
use '4714-11-24 00:00:00 BC'. I have found the problem by using a binary
cursor where I get the value as double. Is this the right list for
posting this problem?

Mathias Palm

#2Richard Huxton
dev@archonet.com
In reply to: Mathias Palm (#1)
Re: timestamp datatyp problem

Mathias Palm wrote:

Hi,

I have found a problem by using timestamp datatyp in postgresql. The
minimum value should be '4713-11-24 00:00:00 BC' but it's possible to
use '4714-11-24 00:00:00 BC'. I have found the problem by using a binary
cursor where I get the value as double. Is this the right list for
posting this problem?

I don't know if it's a problem or not, but I'd guess the relevant bit is
in src/include/utils/datetime.h

#define JULIAN_MINYEAR (-4713)
#define JULIAN_MINMONTH (11)
#define JULIAN_MINDAY (24)
#define JULIAN_MAXYEAR (5874898)

#define IS_VALID_JULIAN(y,m,d) ((((y) > JULIAN_MINYEAR) \
|| (((y) == JULIAN_MINYEAR) && (((m) > JULIAN_MINMONTH) \
|| (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY))))) \
&& ((y) < JULIAN_MAXYEAR))

I'm guessing -4713 == 4714BC (no year 0 between 1BC and 1AD).

Presumably this can only happen if using floating-point datetimes and
not 64-bit integers?

--
Richard Huxton
Archonet Ltd