X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 75AA38BA04D for ; Fri, 11 Feb 2005 04:33:25 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35571-08 for ; Fri, 11 Feb 2005 04:33:08 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id E3C2A8BA123 for ; Fri, 11 Feb 2005 04:32:14 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j1B4W5M02420; Thu, 10 Feb 2005 23:32:05 -0500 (EST) From: Bruce Momjian Message-Id: <200502110432.j1B4W5M02420@candle.pha.pa.us> Subject: Re: Default Values Section In-Reply-To: <009401c4f286$01cc6b50$fc00a8c0@hermes> To: Lourival Oliveira Date: Thu, 10 Feb 2005 23:32:05 -0500 (EST) Cc: pgsql-docs@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.023 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/29 X-Sequence-Number: 2862 OK, I updated the documentation to add a comment on that line: SELECT CURRENT_TIMESTAMP; SELECT now(); SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT --------------------------------------------------------------------------- Lourival Oliveira wrote: > I have a problem reading the "5.3 Default Values" Section of > Postgresql8.0.0-rc1 documentation. In this section there are nothing about > using 'now' constant. I think which there are a conflict with a note about > 'now' in section "9.9. Date/Time Functions and Operators" which show the way > to achieve the desired behavior. See: > > 5.3. Default Values > > ... > > The default value may be a scalar expression, which will be evaluated > whenever the default value is inserted (not when the table is created). > > > 9.9. Date/Time Functions and Operators > > ... > > SELECT CURRENT_TIMESTAMP; > SELECT now(); > SELECT TIMESTAMP 'now'; > Note: You do not want to use the third form when specifying a DEFAULT clause > while creating a table. The system will convert now to a timestamp as soon > as the constant is parsed, so that when the default value is needed, the > time of the table creation would be used! The first two forms will not be > evaluated until the default value is used, because they are function calls. > Thus they will give the desired behavior of defaulting to the time of row > insertion. > > I think which a simple reference to any unpredictable behavior must be > placed here to avoid confusion when anybody don't reach the desired behavior > when use default values. > > What think you about my suggestion? > > Wait replies, Tanks. > > Lourival Oliveira da Silva > > PS: Sorry by my poor English. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073