Negative result with (now()-previously_inserted_timestamp) - Mailing list pgsql-bugs

From Gurjeet Singh
Subject Negative result with (now()-previously_inserted_timestamp)
Date
Msg-id AANLkTilzZ7oxzF_uUDecIDDLkInz6v4X8K5K_pRzsh3k@mail.gmail.com
Whole thread Raw
Responses Re: Negative result with (now()-previously_inserted_timestamp)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
I have an IRC logger storing its data in a Postgres 8.3.3. The table in
question has the interesting column declared as:

time  timestamp with time zone default now()

The logger uses a prepared statement to insert data, and does not mention
this column in the INSERT statement, hence the assumption that default
clause is being used.

I ran the following query, and got an unexpected negative value. Does this
imply that SELECT-transaction was able to see a row created by
INSERT-transaction which started after the SELECT-transaction?

postgres=> select channel, min( now()-time ) from irclog group by channel
order by 2 asc;
   channel    |           min
--------------+-------------------------
 #archlinux   | -00:00:00.11686
 ##C          | 00:00:00.09718
 #debian      | 00:00:00.482193
 ##linux      | 00:00:01.172365
...
 #            | 36 days 14:01:17.395093
(21 rows)

(Note: the '#' row can serve as a diagnosis starting point since that
channel group has never been inserted into since the incident)

I scoured the release notes 8.3.4 to 8.3.11 for any relevant fixes and found
only this one:

http://www.postgresql.org/docs/8.3/static/release-8-3-5.html
Fix improper display of fractional seconds in interval values when using a
non-ISO datestyle in an --enable-integer-datetimes build (Ron Mayer)

But I don't think this applies to this bug report as I am using ISO
datestyle.

postgres=> show DateStyle;
 DateStyle
-----------
 ISO, MDY
(1 row)

Regards,
--
gurjeet.singh
@ EnterpriseDB - The Enterprise Postgres Company
http://www.EnterpriseDB.com

singh.gurjeet@{ gmail | yahoo }.com
Twitter/Skype: singh_gurjeet

Mail sent from my BlackLaptop device

pgsql-bugs by date:

Previous
From: Craig Ringer
Date:
Subject: Re: BUG #5542: Query optimization problem
Next
From: Tom Lane
Date:
Subject: Re: Negative result with (now()-previously_inserted_timestamp)