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 3BDD23A3F21 for ; Tue, 4 Jan 2005 17:52:09 +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 76934-10 for ; Tue, 4 Jan 2005 17:51:42 +0000 (GMT) Received: from tabuba.dnscenter.com.br (tabuba.dnscenter.com.br [67.15.80.46]) by svr1.postgresql.org (Postfix) with ESMTP id 4E3DF3A3F06 for ; Tue, 4 Jan 2005 17:51:28 +0000 (GMT) Received: from [200.223.172.34] (helo=hermes) by tabuba.dnscenter.com.br with esmtpa (Exim 4.43) id 1Clsq0-0008Ao-GH for pgsql-docs@postgresql.org; Tue, 04 Jan 2005 15:51:21 -0200 Message-ID: <009401c4f286$01cc6b50$fc00a8c0@hermes> From: "Lourival Oliveira" To: Subject: Default Values Section Date: Tue, 4 Jan 2005 14:51:19 -0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - tabuba.dnscenter.com.br X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - lourival.eti.br X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200501/7 X-Sequence-Number: 2766 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.