Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Álvaro Herrera
On 2025-Nov-19, Robert Haas wrote: > I do not know how to make the phrase "older minor releases" any more > clear. It's perfectly clear. I just don't believe this claim. > You and Álvaro seem to be under the impression that nobody will > ever try to compile code written after this change from a

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Robert Haas
On Wed, Nov 19, 2025 at 12:47 PM Bertrand Drouvot wrote: > > True, but if they write any new code, and care about it compiling with > > older minor releases, this is a potential pitfall. > > Why given that 06edbed4786 has been back patched through 13? I do not know how to make the phrase "older m

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Andres Freund
On 2025-11-19 12:27:30 -0500, Robert Haas wrote: > It's possible, but fundamentally I think it's about replacing > XLogRecPtrIsInvalid with XLogRecPtrIsValid, and what I'm saying is I > wouldn't have chosen to do that. I agree that it would have been > better to do it that way originally, but I dis

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Bertrand Drouvot
Hi, On Wed, Nov 19, 2025 at 12:27:30PM -0500, Robert Haas wrote: > On Wed, Nov 19, 2025 at 11:49 AM Álvaro Herrera wrote: > > > I'm rather late to the party here, but for what it's worth, I don't > > > really think this was a good idea. Anyone who wants to write > > > out-of-core code that works

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Robert Haas
On Wed, Nov 19, 2025 at 11:49 AM Álvaro Herrera wrote: > > I'm rather late to the party here, but for what it's worth, I don't > > really think this was a good idea. Anyone who wants to write > > out-of-core code that works in the back-branches must still write it > > the old way, or it will poten

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Álvaro Herrera
On 2025-Nov-19, Robert Haas wrote: > On Thu, Nov 6, 2025 at 2:48 PM Álvaro Herrera wrote: > > Okay, thanks, I have applied that one to all stable branches, except > > I didn't add the judgemental comment about XLogRecPtrIsInvalid(). > > I'm rather late to the party here, but for what it's worth,

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-19 Thread Robert Haas
On Thu, Nov 6, 2025 at 2:48 PM Álvaro Herrera wrote: > Okay, thanks, I have applied that one to all stable branches, except I > didn't add the judgemental comment about XLogRecPtrIsInvalid(). I'm rather late to the party here, but for what it's worth, I don't really think this was a good idea. An

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-18 Thread Bertrand Drouvot
Hi, On Tue, Nov 18, 2025 at 06:57:33PM +0100, Álvaro Herrera wrote: > On 2025-Nov-18, Bertrand Drouvot wrote: > > The patch makes use of it because it exists. I agree that we could > > also remove it (for the reasons you mentioned above), I'll do that. > > RegProcedure actually predates all of ou

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-18 Thread Álvaro Herrera
On 2025-Nov-18, Bertrand Drouvot wrote: > Hi, > > On Tue, Nov 18, 2025 at 04:54:32PM +0100, Peter Eisentraut wrote: > > RegProcedureIsValid() doesn't add any value over OidIsValid, and we > > don't have any RegXXXIsValid() for any of the other regxxx types. > > So if we were to do anything about

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-18 Thread Bertrand Drouvot
Hi, On Tue, Nov 18, 2025 at 04:54:32PM +0100, Peter Eisentraut wrote: > RegProcedureIsValid() doesn't add any value over OidIsValid, and we don't > have any RegXXXIsValid() for any of the other regxxx types. So if we were > to do anything about this, I would just remove it. The patch makes use o

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-18 Thread Peter Eisentraut
On 18.11.25 10:06, Bertrand Drouvot wrote: Hi, On Fri, Nov 07, 2025 at 03:03:03PM +, Bertrand Drouvot wrote: I'm currently working on the RegProcedureIsValid() and OidIsValid() cases, will share once done. here they are, I'm not creating a new thread for those as this is the same kind of

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-17 Thread Bertrand Drouvot
Hi, On Mon, Nov 17, 2025 at 01:12:24PM +, Bertrand Drouvot wrote: > The script has been updated and the patch too (finding a new replacement in > gist.c). Finally, adding GistNSN to the game (as a typedef XLogRecPtr) gives the attached. Regards, -- Bertrand Drouvot PostgreSQL Contributors

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-17 Thread Bertrand Drouvot
Hi, On Thu, Nov 13, 2025 at 02:11:08PM +, Bertrand Drouvot wrote: > On Fri, Nov 07, 2025 at 02:37:32PM +0100, Álvaro Herrera wrote: > > I guess/hope you'll get the same results if you use run_parallel.sh as > mentioned > above. The .cocci script had an issue (not always detecting correctly

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-13 Thread Bertrand Drouvot
On Fri, Nov 07, 2025 at 02:37:32PM +0100, Álvaro Herrera wrote: > Hmm, I tried to recreate your patch using this .cocci file, and in my > run, there's a few changes in your patch that my spatch run didn't > detect. I wonder if that's because my spatch version is buggy, or > because you hacked the

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-13 Thread Álvaro Herrera
On 2025-Nov-07, Bertrand Drouvot wrote: > What do you think of the attached? It contains the ones you mentioned and some > others. The patch attached has been generated by the .cocci script [1]. > > [1]: > https://github.com/bdrouvot/coccinelle_on_pg/blob/main/replace_literal_0_assignement_with_

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-09 Thread Bertrand Drouvot
Hi, On Fri, Nov 07, 2025 at 05:18:41PM +, Dagfinn Ilmari Mannsåker wrote: > Peter Eisentraut writes: > > > On 07.11.25 16:03, Bertrand Drouvot wrote: > > > >> +#define pg_attribute_deprecated(msg) [[deprecated(msg)]] > >> +#elif defined(__GNUC__) || defined(__clang__) > > > > The __clang__ p

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-07 Thread Bertrand Drouvot
Hi, On Fri, Nov 07, 2025 at 03:03:03PM +, Bertrand Drouvot wrote: > 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 ... ma

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-07 Thread Dagfinn Ilmari Mannsåker
Peter Eisentraut writes: > On 07.11.25 16:03, Bertrand Drouvot wrote: > >> +#define pg_attribute_deprecated(msg) [[deprecated(msg)]] >> +#elif defined(__GNUC__) || defined(__clang__) > > The __clang__ part is not needed, because clang defines __GNUC__ also. Or, to avoid having to know this, how

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-07 Thread Bertrand Drouvot
Hi, On Fri, Nov 07, 2025 at 05:05:11PM +0100, Peter Eisentraut wrote: > On 07.11.25 16:03, Bertrand Drouvot wrote: > > +/* > > + * Mark a declaration as deprecated with a custom message. The compiler > > will > > + * emit a warning when the deprecated entity is used. > > + */ > > +#if defined(__S

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-07 Thread Peter Eisentraut
On 07.11.25 16:03, Bertrand Drouvot wrote: +/* + * 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 >= 20140

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-07 Thread Bertrand Drouvot
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->waitLS

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-07 Thread Álvaro Herrera
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? diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index a0c79958fd5..1f11c8646f5 100644 --- a/src/

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-06 Thread Bertrand Drouvot
Hi, On Thu, Nov 06, 2025 at 08:48:11PM +0100, Álvaro Herrera wrote: > On 2025-Nov-06, Bertrand Drouvot wrote: > > > I see, I would have introduced XLogRecPtrIsInvalid() on the back branches > > only > > if there is a need to (a bugfix that would make use of it). But yeah, I > > agree > > that w

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-06 Thread Álvaro Herrera
On 2025-Nov-06, Bertrand Drouvot wrote: > I see, I would have introduced XLogRecPtrIsInvalid() on the back branches only > if there is a need to (a bugfix that would make use of it). But yeah, I agree > that would add extra "unnecessary" work, so done as you suggested in the > attached. I checked

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-06 Thread Bertrand Drouvot
Hi, On Thu, Nov 06, 2025 at 10:06:13AM +0100, Álvaro Herrera wrote: > On 2025-Nov-06, Bertrand Drouvot wrote: > > > Subject: [PATCH v5 1/4] Introduce XLogRecPtrIsValid() and replace > > XLogRecPtrIsInvalid() calls > > > XLogRecPtrIsInvalid() is inconsistent with the affirmative form of other >

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-06 Thread Álvaro Herrera
On 2025-Nov-06, Bertrand Drouvot wrote: > Subject: [PATCH v5 1/4] Introduce XLogRecPtrIsValid() and replace > XLogRecPtrIsInvalid() calls > XLogRecPtrIsInvalid() is inconsistent with the affirmative form of other > *IsValid() macros and leads to awkward double negative. > > This commit introduc

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-05 Thread Bertrand Drouvot
Hi, On Mon, Nov 03, 2025 at 07:47:28AM +, Bertrand Drouvot wrote: > I think the way it is done in the attached makes sense, it: > > - introduces PG_DEPRECATED() > - provides a use case on how to use it (i.e using a version that is currently > in the future) > - ensures that XLogRecPtrIsInvali

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-11-02 Thread Bertrand Drouvot
Hi, On Fri, Oct 31, 2025 at 01:19:50PM +0100, Álvaro Herrera wrote: > On 2025-Oct-31, Bertrand Drouvot wrote: > > > After giving it more thought, I'm inclined to postpone the compiler warning > > until XLogRecPtrIsValid() has been available for some time. The question is > > for > > how long? >

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-31 Thread Álvaro Herrera
On 2025-Oct-31, Bertrand Drouvot wrote: > After giving it more thought, I'm inclined to postpone the compiler warning > until XLogRecPtrIsValid() has been available for some time. The question is > for > how long? Maybe we can mark it so that it becomes obsolete in a future version, #if PG_VERS

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-31 Thread Bertrand Drouvot
Hi, On Fri, Oct 31, 2025 at 08:41:46AM +0100, Peter Eisentraut wrote: > On 31.10.25 05:31, Bertrand Drouvot wrote: > > For PG19, we could: > > > > Add a comment in the code documenting that XLogRecPtrIsInvalid() is > > deprecated > > and that we will enforce a "deprecated" attribute on it in PG2

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-31 Thread Peter Eisentraut
On 31.10.25 05:31, Bertrand Drouvot wrote: For PG19, we could: Add a comment in the code documenting that XLogRecPtrIsInvalid() is deprecated and that we will enforce a "deprecated" attribute on it in PG24. Just a code comment for now seems reasonable. I wouldn't make any predictions about t

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-30 Thread Bertrand Drouvot
Hi, On Thu, Oct 30, 2025 at 02:55:51PM +0100, Peter Eisentraut wrote: > On 30.10.25 10:17, Bertrand Drouvot wrote: > > - 0002 deprecates XLogRecPtrIsInvalid(): it emits a warning message at > > compilation > > time if XLogRecPtrIsInvalid() is in use in the code base. > > Surely this could be fac

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-30 Thread Peter Eisentraut
On 30.10.25 10:17, Bertrand Drouvot wrote: - 0002 deprecates XLogRecPtrIsInvalid(): it emits a warning message at compilation time if XLogRecPtrIsInvalid() is in use in the code base. Surely this could be factored out in macro in such a way that the warning message is a macro argument and we

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-30 Thread Bertrand Drouvot
Hi, On Wed, Oct 29, 2025 at 05:50:13PM +0100, Peter Eisentraut wrote: > On 28.10.25 13:33, Bertrand Drouvot wrote: > > I do prefer to introduce XLogRecPtrIsValid(x) and switch to that. Then, do > > the > > same kind of work on OidIsValid() and TransactionIdIsValid() and add an > > annual > > che

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-30 Thread Bertrand Drouvot
Hi, On Tue, Oct 28, 2025 at 05:57:54PM +, Bertrand Drouvot wrote: > Hi, > > On Tue, Oct 28, 2025 at 04:05:34PM +0200, Álvaro Herrera wrote: > > > > BTW we could use Coccinelle to replace all the XLogRecPtrIsInvalid() > > calls with !XLogRecPtrIsValid(), as well as all places comparing an LSN

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-29 Thread Peter Eisentraut
On 28.10.25 13:33, Bertrand Drouvot wrote: I do prefer to introduce XLogRecPtrIsValid(x) and switch to that. Then, do the same kind of work on OidIsValid() and TransactionIdIsValid() and add an annual check. Idea is to get some code consistency while keeping macros which are valuable for readabi

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Bertrand Drouvot
Hi, On Tue, Oct 28, 2025 at 04:05:34PM +0200, Álvaro Herrera wrote: > > BTW we could use Coccinelle to replace all the XLogRecPtrIsInvalid() > calls with !XLogRecPtrIsValid(), as well as all places comparing an LSN > to InvalidXLogRecPtr or literal zero. I did v1 the old way (shell script) and d

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Álvaro Herrera
On 2025-Oct-28, Michael Paquier wrote: > The annoying part with eliminating XLogRecPtrIsInvalid() or replacing > it is that a bunch of external code would be broken, particularly > backup tools. I'd rather leave the beast alone. Well, we don't have to remove it right away. We can simply not use

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Michael Paquier
On Tue, Oct 28, 2025 at 01:40:24PM +0200, Heikki Linnakangas wrote: > It's also a bit cumbersome that we have XLogRecPtrIsInvalid() rather than > XLogRecPtrIsValid(). That's inconsistent with OidIsValid and > TransactionIdInValid, and it leads to an awkward double negative 'if > (!XLogRecPtrIsInval

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Bertrand Drouvot
Hi, On Tue, Oct 28, 2025 at 01:40:24PM +0200, Heikki Linnakangas wrote: > On 28/10/2025 10:53, Quan Zongliang wrote: > > On 10/28/25 4:13 PM, Bertrand Drouvot wrote: > > > While working on refactoring some code in [1], one of the changes was: > > > > > > -   if (initial_restart_lsn != Invalid

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Heikki Linnakangas
On 28/10/2025 10:53, Quan Zongliang wrote: On 10/28/25 4:13 PM, Bertrand Drouvot wrote: While working on refactoring some code in [1], one of the changes was: -   if (initial_restart_lsn != InvalidXLogRecPtr && -   initial_restart_lsn < oldestLSN) +   XLogRecPtr  restart_lsn = s

Re: Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Quan Zongliang
On 10/28/25 4:13 PM, Bertrand Drouvot wrote: Hi hackers, While working on refactoring some code in [1], one of the changes was: - if (initial_restart_lsn != InvalidXLogRecPtr && - initial_restart_lsn < oldestLSN) + XLogRecPtr restart_lsn = s->data.restart_lsn; + +

Consistently use the XLogRecPtrIsInvalid() macro

2025-10-28 Thread Bertrand Drouvot
Hi hackers, While working on refactoring some code in [1], one of the changes was: - if (initial_restart_lsn != InvalidXLogRecPtr && - initial_restart_lsn < oldestLSN) + XLogRecPtr restart_lsn = s->data.restart_lsn; + + if (restart_lsn != InvalidXLogRecPtr && +