Обсуждение: timestamp goober

Поиск
Список
Период
Сортировка

timestamp goober

От
Culley Harrelson
Дата:
columns with default timestamp('now') see to be
defaulting to the time I started posgresql!

What am I doing wrong here?  Is it an os problem?
Need these columns to capture the current date and
time.

Culley

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year!  http://personal.mail.yahoo.com/

Re: timestamp goober

От
"Gregory Wood"
Дата:
> columns with default timestamp('now') see to be
> defaulting to the time I started posgresql!

I noticed that timestamps (in my case CURRENT_TIMESTAMP) are taken from the
beginning of a transaction. You didn't mention how you were accessing the
database, but if you were updating everything inside the same transaction,
everything would be timestamped with the time that transaction began.

Greg



Re: timestamp goober

От
Manuel Sugawara
Дата:
Culley Harrelson <culleyharrelson@yahoo.com> writes:

> columns with default timestamp('now') see to be
> defaulting to the time I started posgresql!

try using: default 'now' instead of: default timestamp('now') in your
table definitions. The latter is evaluated by postgres just once, when
the table is installed, instead of each time a tuple is inserted.

HTH,
Manuel.

Re: Re: timestamp goober

От
Alex Pilosov
Дата:
Yes, and that's a feature :)

If you want a wall clock time, use timenow()

-alex

On Thu, 8 Feb 2001, Gregory Wood wrote:

> > columns with default timestamp('now') see to be
> > defaulting to the time I started posgresql!
>
> I noticed that timestamps (in my case CURRENT_TIMESTAMP) are taken from the
> beginning of a transaction. You didn't mention how you were accessing the
> database, but if you were updating everything inside the same transaction,
> everything would be timestamped with the time that transaction began.
>
> Greg
>
>
>



Re: Re: timestamp goober

От
"Gregory Wood"
Дата:
Oh, I just made sure that I started a new transaction :)

I actually prefer that timestamps are handled that way... once I realized
*why* I had triggered INSERTs that were stamped 45 minutes earlier than I
thought they should have been.

Greg

> Yes, and that's a feature :)
>
> If you want a wall clock time, use timenow()

> > I noticed that timestamps (in my case CURRENT_TIMESTAMP) are taken from
the
> > beginning of a transaction. You didn't mention how you were accessing
the
> > database, but if you were updating everything inside the same
transaction,
> > everything would be timestamped with the time that transaction began.