Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 37A301337BD0 for ; Wed, 11 May 2011 16:55:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 33816-09 for ; Wed, 11 May 2011 19:55:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f174.google.com (mail-yx0-f174.google.com [209.85.213.174]) by mail.postgresql.org (Postfix) with ESMTP id 77BCF1337BE1 for ; Wed, 11 May 2011 16:55:04 -0300 (ADT) Received: by yxs7 with SMTP id 7so294438yxs.19 for ; Wed, 11 May 2011 12:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=iMp1n4Mj6ZxsXdiG8jN5SLfqf9eXb1d4LaFaSqnV6UI=; b=n4t+wTO0dC0KBUDncbIF9EMZULDIpoxpCVjyfj2ZPPt0TLqeRXT5GhbBxxAZ2wYud8 cWq0My0xyGaEUTx0vknOOZWUYNXxXV8cAIw1CQnt6Sz37Fa7TGcm7US+ksE1WhYTS1yf VylcwDzswtWQeB6ifgq66YE/frSZKo3Db2owg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=fv7s2JVe6SZyAlM7ZY2nIrbS7zNVxoY1eeyH5ihwj5gMc0M9XsAL4HbQisxVmD5LeI gzZmRcI2+kJA4Re3X6GkBcrsER1khA+Qa33tc/xM2gJ+0uGbMWGVENdltRP0Q7/97r26 wChtUtrtCD6R1GaSwLNWB8mNQzJm8J9aBYbCc= MIME-Version: 1.0 Received: by 10.236.189.198 with SMTP id c46mr11415742yhn.416.1305143702140; Wed, 11 May 2011 12:55:02 -0700 (PDT) Received: by 10.236.103.10 with HTTP; Wed, 11 May 2011 12:55:02 -0700 (PDT) In-Reply-To: <201104281933.p3SJXD1V044515@wwwmaster.postgresql.org> References: <201104281933.p3SJXD1V044515@wwwmaster.postgresql.org> Date: Wed, 11 May 2011 15:55:02 -0400 Message-ID: Subject: Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP From: Robert Haas To: "Brian S. Krug" Cc: pgsql-bugs@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/102 X-Sequence-Number: 30241 On Thu, Apr 28, 2011 at 3:33 PM, Brian S. Krug wrote: > > The following bug has been logged online: > > Bug reference: =A0 =A0 =A05996 > Logged by: =A0 =A0 =A0 =A0 =A0Brian S. Krug > Email address: =A0 =A0 =A0bkrug@usatech.com > PostgreSQL version: 9.0.3 > Operating system: =A0 Solaris > Description: =A0 =A0 =A0 =A0CURRENT_TIMESTAMP uses often undesired > TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP > Details: > > CURRENT_TIMESTAMP (and CURRENT_DATE, CURRENT_TIME) return the time of the > start of the transcaction - which seems to be right after the end of the > last transaction. Thus, if you use pooled connections, CURRENT_TIMESTAMP > will return the time of the last COMMIT. This is often unintended behavio= r. > This tripped me up significant and I would anticipate that many have fall= en > into the same trap. I recommend that CURRENT_TIMESTAMP functions as > STATEMENT_TIMESTAMP instead of as TRANSACTION_TIMESTAMP. I've been bitten by this too, but I doubt we're likely to want to change it at this point for reasons of backward compatibility. The SQL standard may have something to say about it, too. But as for pooled connections, it would seem unwise to multiplex a server connection across different sessions while leaving a transaction open. Presumably each client should commit after it finishes its own work. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company