AlterSubscription_refresh "wrconn" wrong variable?
Peter Smith <smithpb2250@gmail.com>
From: Peter Smith <smithpb2250@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-05-03T23:29:42Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-wrconn.-Use-stack-variable.patch (application/octet-stream) patch v1-0001
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
Commits
-
Rename the logical replication global "wrconn"
- e5c071bc0f93 13.4 landed
- db16c656478b 14.0 landed
- b5b7cba7643c 10.18 landed
- b0e6e08b1981 11.13 landed
- 6e9723cde5c6 12.8 landed
-
AlterSubscription_refresh: avoid stomping on global variable
- ef70b6f8e28d 13.3 landed
- cfebc7080c99 12.7 landed
- b40865ebd41a 11.12 landed
- 4e8c0f1a0d0d 14.0 landed
- 1803c7626000 10.17 landed
-
Logical replication support for initial data copy
- 7c4f52409a8c 10.0 cited