Hi, On Fri, Nov 07, 2025 at 02:37:32PM +0100, Álvaro Herrera wrote: > On 2025-Nov-07, Bertrand Drouvot wrote: > > > Agree, will modify the .cocci scripts that way. > > I just noticed that we missed this ... maybe you want to include it also? > > - MyProc->waitLSN = 0; > + MyProc->waitLSN = InvalidXLogRecPtr; > > - lastLSN = 0; > + lastLSN = InvalidXLogRecPtr; > > - MyProc->waitLSN = 0; > + MyProc->waitLSN = InvalidXLogRecPtr;
Yeah, that's another story here that is worth to look at too. Will do. I'm currently working on the RegProcedureIsValid() and OidIsValid() cases, will share once done. > > > Now that XLogRecPtrIsValid() is available in back branches, I agree that we > > can be less conservative and not wait until v24. v21 looks like good timing > > to > > me. > > Cool, please resubmit. Sure, done in the attached. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
>From 98ea01f97cf0970898edd7795605f766b15a470f Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot <[email protected]> Date: Fri, 7 Nov 2025 14:18:31 +0000 Subject: [PATCH v7] Introduce pg_attribute_deprecated() and deprecate XLogRecPtrIsInvalid() This commit creates a new macro pg_attribute_deprecated() to mark a declaration as deprecated with a custom message. The compiler will emit a warning when the deprecated entity is used. Then it makes use of this new macro to emit a deprecated message about XLogRecPtrIsInvalid() as of version 21 (no need to be more conservative and wait until version 24 as XLogRecPtrIsValid() has been added in back branches). --- src/include/access/xlogdefs.h | 17 +++++++++++++++++ src/include/c.h | 15 +++++++++++++++ 2 files changed, 32 insertions(+) 47.2% src/include/access/ 52.7% src/include/ diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h index 5f07e57c832..1ed8f1b413e 100644 --- a/src/include/access/xlogdefs.h +++ b/src/include/access/xlogdefs.h @@ -27,6 +27,23 @@ typedef uint64 XLogRecPtr; */ #define InvalidXLogRecPtr 0 #define XLogRecPtrIsValid(r) ((r) != InvalidXLogRecPtr) + +/* + * New code should use XLogRecPtrIsValid() instead of XLogRecPtrIsInvalid() + * for consistency with the affirmative form of macros used for other datatypes + * and to avoid awkward double negative. + * This function is retained for convenience of third-party code but is/will be + * deprecated as of version 21. + */ +#if PG_VERSION_NUM >= 210000 +pg_attribute_deprecated("use XLogRecPtrIsValid() instead") +#endif +static inline bool +XLogRecPtrIsInvalid(XLogRecPtr ptr) +{ + return ptr == InvalidXLogRecPtr; +} + #define XLogRecPtrIsInvalid(r) ((r) == InvalidXLogRecPtr) /* diff --git a/src/include/c.h b/src/include/c.h index 757dfff4782..6e7b2c47251 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -227,6 +227,21 @@ #define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused() #endif +/* + * Mark a declaration as deprecated with a custom message. The compiler will + * emit a warning when the deprecated entity is used. + */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L || \ +defined(__cplusplus) && __cplusplus >= 201402L +#define pg_attribute_deprecated(msg) [[deprecated(msg)]] +#elif defined(__GNUC__) || defined(__clang__) +#define pg_attribute_deprecated(msg) __attribute__((deprecated(msg))) +#elif defined(_MSC_VER) +#define pg_attribute_deprecated(msg) __declspec(deprecated(msg)) +#else +#define pg_attribute_deprecated(msg) +#endif + /* GCC supports format attributes */ #if defined(__GNUC__) #define pg_attribute_format_arg(a) __attribute__((format_arg(a))) -- 2.34.1
