From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Vince Vielhaber <vev(at)michvhf(dot)com> |
Cc: | hackers(at)postgreSQL(dot)org |
Subject: | Re: [HACKERS] current_time? |
Date: | 1999-10-20 04:52:32 |
Message-ID: | 11687.940395152@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Vince Vielhaber <vev(at)michvhf(dot)com> writes:
> Now I thought this was discussed recently and this:
> create table foo(
> x int,
> y datetime default current_time);
> would put the current date and time into y whenever a new record was
> inserted. It appears to give the date and time the stupid table was
> created. Is it me or is something broke?
The behavior for this was changed very recently. Since current sources
refuse the above:
regression=> create table foo(
regression-> x int,
regression-> y datetime default current_time);
ERROR: Attribute 'y' is of type 'datetime' but default expression is of type 'time'
You will need to rewrite or cast the expression
I am guessing you are trying it with 6.5.*, where indeed you will likely
get the time of table creation. Recommended approach is
y datetime default now()
which works the way you want in all Postgres versions AFAIK.
Next question is whether current sources are broken to refuse the above.
Since I get
regression=> create table zz (x datetime);
CREATE
regression=> insert into zz values(current_time);
ERROR: Attribute 'x' is of type 'datetime' but expression is of type 'time'
You will need to rewrite or cast the expression
it seems I managed to make default-expression handling consistent
with the rest of the system, but that doesn't necessarily mean this
behavior is desirable... Thomas, what say you?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-10-20 05:11:53 | Re: [HACKERS] book status |
Previous Message | Vadim Mikheev | 1999-10-20 04:30:38 | Re: [HACKERS] mdnblocks is an amazing time sink in huge relations |