Unnecessary global variable declared in xlog.c

Started by Amul Sulabout 4 years ago5 messages
#1Amul Sul
sulamul@gmail.com
1 attachment(s)

Hi,

The attached patch moves the "LastRec" variable declaration inside
StartupXLOG() where it is supposed to be.

--
Regards,
Amul Sul
EDB: http://www.enterprisedb.com

Attachments:

remove_global_declaration.patchapplication/octet-stream; name=remove_global_declaration.patchDownload
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e073121a7e7..f838abe9622 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -191,8 +191,6 @@ const struct config_enum_entry recovery_target_action_options[] = {
  */
 CheckpointStatsData CheckpointStats;
 
-static XLogRecPtr LastRec;
-
 /* Local copy of WalRcv->flushedUpto */
 static XLogRecPtr flushedUpto = 0;
 static TimeLineID receiveTLI = 0;
@@ -6679,6 +6677,7 @@ StartupXLOG(void)
 	bool		haveBackupLabel = false;
 	bool		haveTblspcMap = false;
 	XLogRecPtr	RecPtr,
+				LastRec,
 				checkPointLoc,
 				EndOfLog;
 	TimeLineID	EndOfLogTLI;
#2Michael Paquier
michael@paquier.xyz
In reply to: Amul Sul (#1)
Re: Unnecessary global variable declared in xlog.c

On Tue, Nov 16, 2021 at 11:17:27AM +0530, Amul Sul wrote:

The attached patch moves the "LastRec" variable declaration inside
StartupXLOG() where it is supposed to be.

Yes, reading through the code, your suggestion makes sense. I'll
double-check and apply if there are no objections.
--
Michael

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Paquier (#2)
Re: Unnecessary global variable declared in xlog.c

Michael Paquier <michael@paquier.xyz> writes:

On Tue, Nov 16, 2021 at 11:17:27AM +0530, Amul Sul wrote:

The attached patch moves the "LastRec" variable declaration inside
StartupXLOG() where it is supposed to be.

Yes, reading through the code, your suggestion makes sense. I'll
double-check and apply if there are no objections.

I think LastRec was originally referenced by multiple functions
in xlog.c. But it does look like it could be a local now.

regards, tom lane

#4Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#3)
Re: Unnecessary global variable declared in xlog.c

On Tue, Nov 16, 2021 at 02:08:54AM -0500, Tom Lane wrote:

I think LastRec was originally referenced by multiple functions
in xlog.c. But it does look like it could be a local now.

Thanks for double-checking, applied this one as of f975fc3.
--
Michael

#5Amul Sul
sulamul@gmail.com
In reply to: Michael Paquier (#4)
Re: Unnecessary global variable declared in xlog.c

On Wed, Nov 17, 2021 at 7:36 AM Michael Paquier <michael@paquier.xyz> wrote:

On Tue, Nov 16, 2021 at 02:08:54AM -0500, Tom Lane wrote:

I think LastRec was originally referenced by multiple functions
in xlog.c. But it does look like it could be a local now.

Thanks for double-checking, applied this one as of f975fc3.

Thank you, Michael.

Regards,
Amul