AlterSubscription_refresh "wrconn" wrong variable? - Mailing list pgsql-hackers

From Peter Smith
Subject AlterSubscription_refresh "wrconn" wrong variable?
Date
Msg-id CAHut+Pu7Jv9L2BOEx_Z0UtJxfDevQSAUW2mJqWU+CtmDrEZVAg@mail.gmail.com
Whole thread Raw
Responses Re: AlterSubscription_refresh "wrconn" wrong variable?
Re: AlterSubscription_refresh "wrconn" wrong variable?
List pgsql-hackers
While reviewing some logical replication code I stumbled across a
variable usage that looks suspicious to me.

Note that the AlterSubscription_refresh function (unlike other
functions in the subscriptioncmds.c) is using the global variable
"wrconn" instead of a local stack variable of the same name. I was
unable to think of any good reason why it would be deliberately doing
this, so my guess is that it is simply an accidental mistake that has
gone unnoticed because the compiler was silently equally happy just
using the global var.

Apparently, this is not causing any reported problems because it seems
like the code has been this way for ~4 years [1].

Even so, it doesn't look intentional to me and I felt that there may
be unknown consequences (e.g. resource leakage?) of just blatting over
the global var. So, PSA a small patch to make this
AlterSubscription_refresh function use a stack variable consistent
with the other nearby functions.

Thoughts?

------
[1] https://github.com/postgres/postgres/commit/7c4f52409a8c7d85ed169bbbc1f6092274d03920#

Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Performance Evaluation of Result Cache by using TPC-DS
Next
From: Jeff Davis
Date:
Subject: Re: MaxOffsetNumber for Table AMs