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 1tYeTp-00Cm6l-Hd for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jan 2025 05:01:14 +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 1tYeTm-007xTg-Qw for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Jan 2025 05:01:11 +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 1tYeTl-007xPb-I1 for pgsql-hackers@lists.postgresql.org; Fri, 17 Jan 2025 05:01:10 +0000 Received: from fhigh-a8-smtp.messagingengine.com ([103.168.172.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tYeTh-000pCJ-22 for pgsql-hackers@lists.postgresql.org; Fri, 17 Jan 2025 05:01:09 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id C08AD11401A0 for ; Fri, 17 Jan 2025 00:01:03 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Fri, 17 Jan 2025 00:01:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm2; t=1737090063; x=1737176463; bh=Acz/8FrgWpphypUbGo98pIg5jdzHmyax BFJ0m85LZpo=; b=c35cktid1OGa+4L5HeWVfNHnDB7Z2sxML2xvKMEP7TXvyzQZ DncYbUlWYHSdYSl6lr6JQo3UPt0VFQLFMMwGUwAsvzdmuuswNex/xT2H8F94RNsp MFf/3kpOxOsBP6Sp8CR2sPo/pnBH5U89VMz8IUUMBzNlxmG6wzDJ4Tnj/Eo1Wys2 RUKYE5G9XyQxzK6o7VHmg6nA/NyrM00/WCNY8wb4DbCXExrPnP7/PAWGX/qQdmHN Yus/O7ztR01Ucz0cyjZZFZTZ97cx89bz5/Mjvkgj6XDxoCDLxszfX4cV2UImdzdv 82ytcfsWlTH7mxG9RnKBDW03z9kSdbHXqzEj7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1737090063; x= 1737176463; bh=Acz/8FrgWpphypUbGo98pIg5jdzHmyaxBFJ0m85LZpo=; b=b NX/p61QtumfOpzhYNYRb5Wh8k39yPzL6tX7NsERLmJrve4tn/NCcYB0KtH4jTxBk Jd95RiJC3nBbY0hZ3PjPoulwBgHOGK9PhfPjlfjmTedoaydZ5SA7XKYIBnW/OE6+ J1J0jAr2gE3JdVETKfB57JIiRfx29J1iRLB8+WZH+wYXthfP2GiZ3GEqFJnX9yXP hL4IMzaGli7Sc8BU+m/sFNm8R132HJYHyH+yDRPaWbRO+SKZeooexKljMUKr5rBH cajUF5yrtvG2LU5DXqmWq7HeohArHuGqlF/BvKPqGdj9DMu2X0PG7FiVBV3sIU+w jqpub8Frif1l29ya/ySHg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeivddgjeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvuffkgggt ugesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmih gthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeeihedvveek jeejudduheegjeeivdfhhfefgeeftdejieelgedtgeffhfetvdevtdenucffohhmrghinh epphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlhdq hhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 17 Jan 2025 00:01:01 -0500 (EST) Date: Fri, 17 Jan 2025 14:00:49 +0900 From: Michael Paquier To: Postgres hackers Subject: Remove XLogRecGetFullXid() in xlogreader.c? Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bprFPq7MP7Et3G/w" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --bprFPq7MP7Et3G/w Content-Type: multipart/mixed; boundary="HFly0Z25TtFftSr2" Content-Disposition: inline --HFly0Z25TtFftSr2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, XLogRecGetFullXid() has been introduced in 67b9b3ca3283 back in 2019, but as far as I can see this has never been used in the code and this is used nowhere in the core code. I have looked at Debian's codesearch and also looked at traces of it on github without seeing it being used anywhere. Knowing that this was originally intended for a hypothetical undo log patch back then, for which no work has been done for years, is there any point in keeping this function in core? This issue has been raised on a separate thread, where Noah has sent a patch to consolidate a bit some epoch calculations for FullTransactionIds, around here: https://www.postgresql.org/message-id/Z4i6MbUlZxjK1rRh@paquier.xyz Removing it would have the benefit to do a bit less refactoring for some of the work of the other thread, and this removes all traces of -DFRONTEND in xlogreader.h. ;) Thoughts or comments? -- Michael --HFly0Z25TtFftSr2 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Remove-XLogRecGetFullXid.patch" Content-Transfer-Encoding: quoted-printable =46rom 101b8469dff3f35c9c3bcd24f1bcfff740f3a622 Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Fri, 17 Jan 2025 13:56:40 +0900 Subject: [PATCH] Remove XLogRecGetFullXid() --- src/include/access/xlogreader.h | 8 ------ src/include/storage/standby.h | 1 + src/backend/access/transam/xlogreader.c | 34 ------------------------- 3 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreade= r.h index 9738462d3c..18a67acf42 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -34,10 +34,6 @@ #ifndef XLOGREADER_H #define XLOGREADER_H =20 -#ifndef FRONTEND -#include "access/transam.h" -#endif - #include "access/xlogrecord.h" #include "storage/buf.h" =20 @@ -427,10 +423,6 @@ extern bool DecodeXLogRecord(XLogReaderState *state, #define XLogRecHasBlockData(decoder, block_id) \ ((decoder)->record->blocks[block_id].has_data) =20 -#ifndef FRONTEND -extern FullTransactionId XLogRecGetFullXid(XLogReaderState *record); -#endif - extern bool RestoreBlockImage(XLogReaderState *record, uint8 block_id, cha= r *page); extern char *XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, = Size *len); extern void XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id, diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h index 24e2f5082b..995d3c365d 100644 --- a/src/include/storage/standby.h +++ b/src/include/storage/standby.h @@ -14,6 +14,7 @@ #ifndef STANDBY_H #define STANDBY_H =20 +#include "access/transam.h" #include "datatype/timestamp.h" #include "storage/lock.h" #include "storage/procsignal.h" diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/t= ransam/xlogreader.c index 3596af0617..12d5175dc3 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -2157,37 +2157,3 @@ RestoreBlockImage(XLogReaderState *record, uint8 blo= ck_id, char *page) =20 return true; } - -#ifndef FRONTEND - -/* - * Extract the FullTransactionId from a WAL record. - */ -FullTransactionId -XLogRecGetFullXid(XLogReaderState *record) -{ - TransactionId xid, - next_xid; - uint32 epoch; - - /* - * This function is only safe during replay, because it depends on the - * replay state. See AdvanceNextFullTransactionIdPastXid() for more. - */ - Assert(AmStartupProcess() || !IsUnderPostmaster); - - xid =3D XLogRecGetXid(record); - next_xid =3D XidFromFullTransactionId(TransamVariables->nextXid); - epoch =3D EpochFromFullTransactionId(TransamVariables->nextXid); - - /* - * If xid is numerically greater than next_xid, it has to be from the last - * epoch. - */ - if (unlikely(xid > next_xid)) - --epoch; - - return FullTransactionIdFromEpochAndXid(epoch, xid); -} - -#endif --=20 2.47.1 --HFly0Z25TtFftSr2-- --bprFPq7MP7Et3G/w Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmeJ5AEACgkQnvQgOdby QH2/1w/+I0CZcUQ3AQrfPJ//N2ZdiDyFmMAr25qsx29Lx+PuRhnokt37Wrdov9m6 dI8WBa6lFdCdU62niulYPPWFrnvzAnE974PfSW3AAjWYnFuwJVgLQE5vfwT2dBz4 2jnhOdHGHzt7V22W9mp5f4V8hxLozovnUA7Dq0eyre4V3l099m3gUctHdQurE7sv HwI4hHXUhsgEz7K5YI9HhVT2x69XqgbSUrHwyLQ30yE+iu26yFeX60vX/8MII8n2 10Vr+urrj44a9NwNfZoLXkZafUjSGO/U2RGB/org8cVeuW1rDBr1RP2NyEEHBY3m TDvwXUQ90seGZZl4w4EM482aQtA0nYrcpbQGyKCuxAfLhB5h6m00qdS0mnYDlcu/ xBovB8N0ZPIsq6QuUGcTlC5dk6nkW6dGUcxtclzdYOZ7hHHXtjMdCFk97Fr6C0Uq bMVFhuzqcaJufVaJjBXDx7HOvFpQDIZiXxncxIC/yMdKFMZsVxcNT6eS0lZATf/U FbnkVVzPKieZf+q6fW/QxLMK6TtL1fEMKkflBMDnr5APWzVOMOCo6g7MDv3AhjOu cWKIGJF4XVBXI6MaBo2Fmi6xAHbdDLnK8zgVzb6INV2t2Q8Z5U5dMkJDlMMSxSAn 7wqur1ifp/pJF8yEUQxqMOjS4ksXAm9RpAeLMqGqiWhcCZUEIDs= =0Rrl -----END PGP SIGNATURE----- --bprFPq7MP7Et3G/w--