Skip site navigation (1) Skip section navigation (2)

Re: Use of 'now'

From: Vince Vielhaber <vev(at)michvhf(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-documentation <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Use of 'now'
Date: 2001-11-14 10:59:46
Message-ID: Pine.BSF.4.40.0111140553380.84965-100000@paprika.michvhf.com (view raw or flat)
Thread:
Lists: pgsql-docspgsql-hackers
On Tue, 13 Nov 2001, Bruce Momjian wrote:

> > > Seems it is still in there somewhere:
> > >
> > > 	test=> create table bb (x timestamp default 'current', y int);
> > > 	CREATE
> > > 	test=> insert into bb (y) values (1);
> > > 	INSERT 16591 1
> > > 	test=> select * from bb;
> > > 	               x               | y
> > > 	-------------------------------+---
> > > 	 2001-11-13 21:45:22.473896-05 | 1
> > > 	(1 row)
> > >
> > > Do you mean that 'current' is now the same as 'now'?  :-)
> >
> > ISTM that 'current' when used as a default meant the time the table
> > was created but now() would (as one woule expect) return the current
> > datetime.
>
> You would think so, but in fact 'current' does change for each insert:
>
> 	test=> create table dd (x timestamp default 'current', y int);
> 	CREATE
> 	test=> insert into dd (y) values (1);
> 	INSERT 16596 1
> 	test=> insert into dd (y) values (1);
> 	INSERT 16597 1
> 	test=> select * from dd;
> 	               x               | y
> 	-------------------------------+---
> 	 2001-11-13 22:39:18.283834-05 | 1
> 	 2001-11-13 22:39:19.196797-05 | 1
> 	(2 rows)
>
>

Or this:

 PostgreSQL 7.0.3 on i386-unknown-freebsdelf4.2, compiled by gcc 2.95.2
(1 row)

template1=# create table dd (x timestamp default 'current', y int);
CREATE
template1=# insert into dd (y) values (1);
INSERT 1407083 1
template1=# insert into dd (y) values (1);
INSERT 1407084 1
template1=# select * from dd;
    x    | y
---------+---
 current | 1
 current | 1
(2 rows)


Must be since 7.0.3?

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev(at)michvhf(dot)com    http://www.pop4.net
         56K Nationwide Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================




In response to

Responses

pgsql-docs by date

Next:From: Thomas LockhartDate: 2001-11-14 14:11:05
Subject: Re: Use of 'now'
Previous:From: Thomas LockhartDate: 2001-11-14 07:23:30
Subject: Re: Use of 'now'

pgsql-hackers by date

Next:From: Giuseppe Tanzilli - CSFDate: 2001-11-14 11:26:17
Subject: 7.2b2 problem using like 'XXX%' sequential scan
Previous:From: Thomas LockhartDate: 2001-11-14 07:23:30
Subject: Re: Use of 'now'

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group