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 1nRFDA-0007ev-4W for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Mar 2022 15:23:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nRFD9-0006wj-06 for pgsql-bugs@arkaria.postgresql.org; Mon, 07 Mar 2022 15:23:47 +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 1nRFD8-0006wa-Ne for pgsql-bugs@lists.postgresql.org; Mon, 07 Mar 2022 15:23:46 +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 1nRFD7-00029p-CI for pgsql-bugs@lists.postgresql.org; Mon, 07 Mar 2022 15:23:46 +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 227FNgbJ192172; Mon, 7 Mar 2022 10:23:42 -0500 From: Tom Lane To: Glen Edmonds cc: "David G. Johnston" , PostgreSQL mailing lists Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence In-reply-to: References: <17428-848dee31a3b899ab@postgresql.org> <189261.1646664485@sss.pgh.pa.us> Comments: In-reply-to Glen Edmonds message dated "Tue, 08 Mar 2022 02:14:44 +1100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <192170.1646666622.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 07 Mar 2022 10:23:42 -0500 Message-ID: <192171.1646666622@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Glen Edmonds writes: > The problem really is that the two states of not initialized and post first > usage are indistinguishable (both return 1), but the sequence next value is > different. They're not indistinguishable: if you look at the is_called flag you'll see that it changes. > ie it’s a reasonable expectation that the next value is > last_value + 1. IMHO violating this makes it a bug. You can call it that if you like, but it's operating as designed and documented. I fear it's about twenty years too late to propose a redesign. regards, tom lane