Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjpK5-0088vy-DD for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2024 23:44:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rjpK3-002l0i-Uq for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Mar 2024 23:44:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjpK3-002l0a-Lh for pgsql-hackers@lists.postgresql.org; Mon, 11 Mar 2024 23:44:48 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rjpK0-0041ua-Hm for pgsql-hackers@lists.postgresql.org; Mon, 11 Mar 2024 23:44:46 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id E6F195C0087; Mon, 11 Mar 2024 19:44:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 11 Mar 2024 19:44:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1710200684; x=1710287084; bh=W95k9D8ko1 cPsKQWKfasyi7tC+vXlc3WqmYg0/jAOBE=; b=PPjidShuONdqVqv5Dsks6gV5G0 E+bP81FVm0Gde2MbdFWt0IApeXiSptY8PmclRQtycz8MsN7qTdSeDTIpm+y4QA4V V/8QVygfQ1ca7dnJaoFyW/lhfQTgYR8mq6Npoi1WGfK/aQZiOsnekcbkLoKlaE0w zjo/MW3Fx1HLhkwP3NS1yATAdxVGBAnhFoU7joAoKnjBCSrQcCL4v0QI0u76r5d6 20d3R4Tsg/v66vIlm+F0Ix75k1fSvbNWna56XNd/IzExOwQC7X/sIiZRGz/gQSlL 24vPFANeMqFYh8HUPMHJANvzvDuaJQOgwsL+1X6CTXMs8wYxisNHzVY0hPOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1710200684; x=1710287084; bh=W95k9D8ko1cPsKQWKfasyi7tC+vX lc3WqmYg0/jAOBE=; b=M/nKeiJIVDaeVAD4DkMmk8P+H/6Ata6p0OAbWTRhclyg hp/AuXn2NlMtyYauR6T270OwYzXmcR4C1Wzw3nhpnCWxJSU02MZpzzCa4VjYTjBm WMIxVN31AMrwMelI3z/GbR/XaxGtUY1NfncN/6bjCA/zZpZUIDVYL1yOv/SuvyOZ kRLlCUHyPudEo+aeV9zuyugd/69sfFnlLnQ8ZI55OagToKdqo7H4UkvG4MgheCGS 3HYrr3lyeFhhCzfdNKU5dfYAUWSD/0ty2yWZRX9rfaLHS+RdPb2VMMbsME5Dp9An dP608grl4dyto6OfhBQ5Louh17kstQAPMMyQ4wJV8A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedvgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 19:44:43 -0400 (EDT) Date: Tue, 12 Mar 2024 08:44:34 +0900 From: Michael Paquier To: Tomas Vondra Cc: Peter Smith , Postgres hackers Subject: Re: Sequence Access Methods, round two Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="WaX2JM8tk/3HeI39" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --WaX2JM8tk/3HeI39 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 10:27:13AM +0900, Michael Paquier wrote: > On Thu, Feb 22, 2024 at 05:36:00PM +0100, Tomas Vondra wrote: >> 0001 >> ------ >>=20 >> I think this bit in pg_proc.dat is not quite right: >>=20 >> proallargtypes =3D> '{regclass,bool,int8}', proargmodes =3D> '{i,o,o}', >> proargnames =3D> '{seqname,is_called,last_value}', >>=20 >> the first argument should not be "seqname" but rather "seqid". >=20 > Ah, right. There are not many system functions that use regclass as > arguments, but the existing ones refer more to IDs, not names. This patch set is not going to be merged for this release, so I am going to move it to the next commit fest to continue the discussion in v18~. Anyway, there is one piece of this patch set that I think has a lot of value outside of the discussion with access methods, which is to redesign pg_sequence_last_value so as it returns a (last_value, is_called) tuple rather than a (last_value). This has the benefit of switching pg_dump to use this function rather than relying on a scan of the heap table used by a sequence to retrieve the state of a sequence dumped. This is the main diff: - appendPQExpBuffer(query, - "SELECT last_value, is_called FROM %s", - fmtQualifiedDumpable(tbinfo)); + /* + * In versions 17 and up, pg_sequence_last_value() has been switched to + * return a tuple with last_value and is_called. + */ + if (fout->remoteVersion >=3D 170000) + appendPQExpBuffer(query, + "SELECT last_value, is_called " + "FROM pg_sequence_last_value('%s')", + fmtQualifiedDumpable(tbinfo)); + else + appendPQExpBuffer(query, + "SELECT last_value, is_called FROM %s", + fmtQualifiedDumpable(tbinfo)); Are there any objections to that? pg_sequence_last_value() is something that we've only been relying on internally for the catalog=20 pg_sequences. -- Michael --WaX2JM8tk/3HeI39 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmXvl2IACgkQnvQgOdby QH2SrRAAg7cnkVe13IZky0rwdO7yHwXQ/WNefOxnny5aHO7bwit1nklw24nZeyCD dGfMhVG0uTbcIwGLCGWx1HDmRy+ubJxfWwe5Iq6tiHciY9W0TEe3R5WCkBV6yBnt sgX13i0pB75eklfTdyqieYuDXhEZK9NjRKTG7R115Vzj/1rOMz0fCqc7XzuwXHe5 r71tM/dtbFg3wzJ+wdkdtfl67Y3xwcgEt3JbANKpx2TBLGJfS0SmXvmvA6U1O+2p 5WQuI78sA1QFdS7eTspNn1UaD9anwZvLqIjm6Gi8qvk0ImGvNoEpauGGf2u3+xR6 R3G0Reo5ozT7WU67aWHuechm3cHs0bp6nVGEq5UK4bHXH6gLGW/QqH46GuNVgws8 QGew1PADYc24exYqieqdbGU9PzYxtU0bFId4K10nGL09NfO8mqU3G2BjkpJV/knS EjvAKWN3jOE3YLOAoUzBW4DkPO1/T4jw4flTR/WHS1kwsRF7wg5NfTfNLh9WTULb IFRwju9sxUHdtDkGx2lcHedLVtphbNdyZ+eocLutVzKogMSqDquklgv8pObWTuWc 4lfauhMcHV4WPA3Gbht8xj3omifXZKf+tg/1SbgHSZkrnuZ/CFvSdyuWxKkxpgzv 0k4YC8Qv+0t3I6N528yMXlZEwpOneVd0+fO7Wm0T00djTX4HBFg= =h/hH -----END PGP SIGNATURE----- --WaX2JM8tk/3HeI39--