Thread: Re: Refactor backup related code (was: Is it correct to say, "invalid data in file \"%s\"", BACKUP_LABEL_FILE in do_pg_backup_stop?)

At Tue, 27 Sep 2022 14:03:24 +0530, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote in 
> On Tue, Sep 27, 2022 at 1:54 PM Kyotaro Horiguchi
> <horikyota.ntt@gmail.com> wrote:
> > What do you think about this?
> 
> -1 from me. We have the function context and the structure name there
> to represent that the parameter name 'state' is actually 'backup
> state'. I don't think we gain anything here. Whenever the BackupState
> is used away from any function, the variable name backup_state is
> used, static variable in xlogfuncs.c

There's no shadowing caused by the change. If we mind the same
variable names between files, we could rename backup_state in
xlogfuncs.c to process_backup_state or session_backup_state.

If this is still unacceptable, I propose to change the comment. (I
found that the previous patch forgets about do_pg_backup_stop())

- * It fills in backup_state with the information required for the backup,
+ * It fills in the parameter "state" with the information required for the backup,

(This is following the notation just above)

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



On Tue, Sep 27, 2022 at 2:20 PM Kyotaro Horiguchi
<horikyota.ntt@gmail.com> wrote:
>
> > -1 from me. We have the function context and the structure name there
> > to represent that the parameter name 'state' is actually 'backup
> > state'. I don't think we gain anything here. Whenever the BackupState
> > is used away from any function, the variable name backup_state is
> > used, static variable in xlogfuncs.c
>
> There's no shadowing caused by the change. If we mind the same
> variable names between files, we could rename backup_state in
> xlogfuncs.c to process_backup_state or session_backup_state.

-1.

> If this is still unacceptable, I propose to change the comment. (I
> found that the previous patch forgets about do_pg_backup_stop())
>
> - * It fills in backup_state with the information required for the backup,
> + * It fills in the parameter "state" with the information required for the backup,

+1. There's another place that uses backup_state in the comments. I
modified that as well. Please see the attached patch.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment
On Tue, Sep 27, 2022 at 03:11:54PM +0530, Bharath Rupireddy wrote:
> On Tue, Sep 27, 2022 at 2:20 PM Kyotaro Horiguchi
> <horikyota.ntt@gmail.com> wrote:
>> If this is still unacceptable, I propose to change the comment. (I
>> found that the previous patch forgets about do_pg_backup_stop())
>>
>> - * It fills in backup_state with the information required for the backup,
>> + * It fills in the parameter "state" with the information required for the backup,
>
> +1. There's another place that uses backup_state in the comments. I
> modified that as well. Please see the attached patch.

Thanks, fixed the comments.  I have let the variable names as they are
now in the code, as both are backup-related code paths so it is IMO
clear that the state is linked to a backup.
--
Michael

Attachment
At Wed, 28 Sep 2022 10:09:39 +0900, Michael Paquier <michael@paquier.xyz> wrote in 
> On Tue, Sep 27, 2022 at 03:11:54PM +0530, Bharath Rupireddy wrote:
> > On Tue, Sep 27, 2022 at 2:20 PM Kyotaro Horiguchi
> > <horikyota.ntt@gmail.com> wrote:
> >> If this is still unacceptable, I propose to change the comment. (I
> >> found that the previous patch forgets about do_pg_backup_stop())
> >>
> >> - * It fills in backup_state with the information required for the backup,
> >> + * It fills in the parameter "state" with the information required for the backup,
> > 
> > +1. There's another place that uses backup_state in the comments. I
> > modified that as well. Please see the attached patch.
> 
> Thanks, fixed the comments.  I have let the variable names as they are
> now in the code, as both are backup-related code paths so it is IMO
> clear that the state is linked to a backup.

Thanks!  I'm fine with that.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center