Re: [HACKERS] create table and default 'now' problem ?

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] create table and default 'now' problem ?
Date: 1999-09-21 12:24:31
Message-ID: Pine.GSO.3.96.SK.990921161931.8336C-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 21 Sep 1999, Thomas Lockhart wrote:

> Date: Tue, 21 Sep 1999 06:14:12 +0000
> From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
> To: Mike Mascari <mascarim(at)yahoo(dot)com>
> Cc: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>, pgsql-hackers(at)postgreSQL(dot)org
> Subject: Re: [HACKERS] create table and default 'now' problem ?
>
> > > how I could create table with datetime field default
> > > to 'now'::text in a way Jan did in his shoes rule example ?
> > > If I do:
> > > test=> create table test ( a datetime default 'now',
> > > b int4);
> > > CREATE
> > > I always get datetime of the moment I created the
> > > table, but I'd like to have datetime of moment I insert.
> > One way around this bug is to create a SQL function
> > which returns now() and use it as the default value:
>
> Not necessary, though this does work well. A simpler way is to
> actually do what Oleg asks about:
>
> create table test ( a datetime default text 'now',...)
>

This works ! Thanks

> or
>
> create table test ( a datetime default 'now'::text,...)

Parser complains:
ERROR: parser: parse error at or near "'"

Does this considered as a bug or feature ?

Oleg

>
> which should force the string to *stay* as a string, rather than
> getting converted to a date value when the table is created. Once it
> is forced to be a string, then it will be converted at insert time
> instead.
>
> - Thomas
>
> --
> Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
> South Pasadena, California
>

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-09-21 13:40:40 Re: [HACKERS] create table and default 'now' problem ?
Previous Message The Hermit Hacker 1999-09-21 12:17:57 Re: [HACKERS] Status on Jan Wieck