Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nREei-000634-Gu for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Mar 2022 14:48:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nREeh-0005mx-9s for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Mar 2022 14:48:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nREeh-0005mo-1c for pgsql-bugs@lists.postgresql.org; Mon, 07 Mar 2022 14:48:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nREee-0001t8-Pc for pgsql-bugs@lists.postgresql.org; Mon, 07 Mar 2022 14:48:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 227Em56S189262; Mon, 7 Mar 2022 09:48:05 -0500 From: Tom Lane To: "David G. Johnston" cc: glen.edmonds@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence In-reply-to: References: <17428-848dee31a3b899ab@postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Mon, 07 Mar 2022 06:35:24 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <189260.1646664485.1@sss.pgh.pa.us> Date: Mon, 07 Mar 2022 09:48:05 -0500 Message-ID: <189261.1646664485@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Mon, Mar 7, 2022 at 12:15 AM PG Bug reporting form < > noreply@postgresql.org> wrote: >> For a freshly defined sequence, the following: >> select last_value from mytable_id_seq >> should return 0, but returns 1. > One seems as good a choice as zero if a non-null value is to be returned. The larger point here is that any change is much more likely to break applications expecting the historical behavior than it is to make anyone's life better. In a green field I'd tend to agree that returning NULL (and dispensing with is_called) would be a better design, but that opportunity was missed decades ago. regards, tom lane