From: lucas at mcsnw.com (Lucas Madar) Date: Fri, 25 Jan 2008 01:14:25 -0800 Subject: [Pljava-dev] R: select CURRENT_TIMESTAMP is wrong In-Reply-To: <227D74A0-C160-4036-ABBD-75D08B65C44A@mac.com> References: <014401c85dbc$477601d0$16b0a8c0@ASUSSTEFANO> <09DA7761-B2E9-4036-B2B1-84F97418F3D4@mac.com> <014901c85dbf$c92040d0$16b0a8c0@ASUSSTEFANO> <227D74A0-C160-4036-ABBD-75D08B65C44A@mac.com> Message-ID: I didn't post this to the list by mistake, but I found a solution. It appears that some precision is being lost with certain compilers. The culprit is this: mSecs += EPOCH_DIFF * 1000; /* Adjust for diff between Postgres and Java (Unix) */ EPOCH_DIFF is cast as an int32; multiplying it by 1000 yields some 949 billion. Here's a fix: --- src/C/pljava/type/Timestamp.c 12 Sep 2007 17:59:43 -0000 1.19 +++ src/C/pljava/type/Timestamp.c 25 Jan 2008 09:04:44 -0000 @@ -14,7 +14,7 @@ #include "pljava/type/Type_priv.h" #include "pljava/type/Timestamp.h" -#define EPOCH_DIFF (((uint32)86400) * (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE)) +#define EPOCH_DIFF (((uint64)86400) * (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE)) /* * Timestamp type. Postgres will pass (and expect in return) a local timestamp. - Lucas Madar -------------- next part -------------- An HTML attachment was scrubbed... URL: