Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

Поиск
Список
Период
Сортировка
Искать

Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

От:
Japin Li <japinli@hotmail.com>
Дата:
Вложения:

Hi, hackers

While reading smgr.h, I noticed an inconsistent type usage in
pgaio_io_set_target_smgr(). Currently the function is declared as:

    extern void pgaio_io_set_target_smgr(PgAioHandle *ioh,
                                         SMgrRelationData *smgr,
                                         ForkNumber forknum,
                                         BlockNumber blocknum,
                                         int nblocks,

However, SMgrRelation is defined as "typedef SMgrRelationData * SMgrRelation;",
and all other functions in the smgr subsystem use SMgrRelation as the parameter
type.

To keep the code consistent with the rest of the smgr API, this patch changes
the parameter from SMgrRelationData * to SMgrRelation in both the definition
and declaration.

This is purely a style/consistency cleanup with no functional change.

Thoughts? Is this change acceptable?

-- 
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

Re: Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Mar 13, 2026, at 15:05, Japin Li  wrote:
> 
> 
> Hi, hackers
> 
> While reading smgr.h, I noticed an inconsistent type usage in
> pgaio_io_set_target_smgr(). Currently the function is declared as:
> 
>    extern void pgaio_io_set_target_smgr(PgAioHandle *ioh,
>                                         SMgrRelationData *smgr,
>                                         ForkNumber forknum,
>                                         BlockNumber blocknum,
>                                         int nblocks,
> 
> However, SMgrRelation is defined as "typedef SMgrRelationData * SMgrRelation;",
> and all other functions in the smgr subsystem use SMgrRelation as the parameter
> type.
> 
> To keep the code consistent with the rest of the smgr API, this patch changes
> the parameter from SMgrRelationData * to SMgrRelation in both the definition
> and declaration.
> 
> This is purely a style/consistency cleanup with no functional change.
> 
> Thoughts? Is this change acceptable?
> 
> -- 
> Regards,
> Japin Li
> ChengDu WenWu Information Technology Co., Ltd.
> 
> 

pgaio_io_set_target_smgr doesn’t update smgr, so, instead of “SMgrRelation”,  I think it’s better to change the type to "const SMgrRelationData *”.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Re: Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

От:
Japin Li <japinli@hotmail.com>
Дата:
Вложения:

Hi, Chao

On Fri, 13 Mar 2026 at 15:29, Chao Li  wrote:
>> On Mar 13, 2026, at 15:05, Japin Li  wrote:
>> 
>> 
>> Hi, hackers
>> 
>> While reading smgr.h, I noticed an inconsistent type usage in
>> pgaio_io_set_target_smgr(). Currently the function is declared as:
>> 
>>    extern void pgaio_io_set_target_smgr(PgAioHandle *ioh,
>>                                         SMgrRelationData *smgr,
>>                                         ForkNumber forknum,
>>                                         BlockNumber blocknum,
>>                                         int nblocks,
>> 
>> However, SMgrRelation is defined as "typedef SMgrRelationData * SMgrRelation;",
>> and all other functions in the smgr subsystem use SMgrRelation as the parameter
>> type.
>> 
>> To keep the code consistent with the rest of the smgr API, this patch changes
>> the parameter from SMgrRelationData * to SMgrRelation in both the definition
>> and declaration.
>> 
>> This is purely a style/consistency cleanup with no functional change.
>> 
>> Thoughts? Is this change acceptable?
>> 
>> -- 
>> Regards,
>> Japin Li
>> ChengDu WenWu Information Technology Co., Ltd.
>> 
>> 
>
> pgaio_io_set_target_smgr doesn’t update smgr, so, instead of “SMgrRelation”,  I think it’s better to change the type to "const SMgrRelationData *”.

Thanks for the review! Makes sense — I've updated the patch to v2.

-- 
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

Re: Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Mar 14, 2026, at 11:07, Japin Li  wrote:
> 
> 
> Hi, Chao
> 
> On Fri, 13 Mar 2026 at 15:29, Chao Li  wrote:
>>> On Mar 13, 2026, at 15:05, Japin Li  wrote:
>>> 
>>> 
>>> Hi, hackers
>>> 
>>> While reading smgr.h, I noticed an inconsistent type usage in
>>> pgaio_io_set_target_smgr(). Currently the function is declared as:
>>> 
>>>   extern void pgaio_io_set_target_smgr(PgAioHandle *ioh,
>>>                                        SMgrRelationData *smgr,
>>>                                        ForkNumber forknum,
>>>                                        BlockNumber blocknum,
>>>                                        int nblocks,
>>> 
>>> However, SMgrRelation is defined as "typedef SMgrRelationData * SMgrRelation;",
>>> and all other functions in the smgr subsystem use SMgrRelation as the parameter
>>> type.
>>> 
>>> To keep the code consistent with the rest of the smgr API, this patch changes
>>> the parameter from SMgrRelationData * to SMgrRelation in both the definition
>>> and declaration.
>>> 
>>> This is purely a style/consistency cleanup with no functional change.
>>> 
>>> Thoughts? Is this change acceptable?
>>> 
>>> -- 
>>> Regards,
>>> Japin Li
>>> ChengDu WenWu Information Technology Co., Ltd.
>>> 
>>> 
>> 
>> pgaio_io_set_target_smgr doesn’t update smgr, so, instead of “SMgrRelation”,  I think it’s better to change the type to "const SMgrRelationData *”.
> 
> Thanks for the review! Makes sense — I've updated the patch to v2.
> 
> -- 
> Regards,
> Japin Li
> ChengDu WenWu Information Technology Co., Ltd.
> 
> 

“const SMgrRelation *” will not work as you expected, you have to do “const SMgrRelationData *”. We want to protect the data the pointer pointing to from changing but the pointer itself.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Re: Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

От:
Japin Li <japinli@hotmail.com>
Дата:
Вложения:
On Mon, 16 Mar 2026 at 08:50, Chao Li  wrote:
>> On Mar 14, 2026, at 11:07, Japin Li  wrote:
>> 
>> 
>> Hi, Chao
>> 
>> On Fri, 13 Mar 2026 at 15:29, Chao Li  wrote:
>>>> On Mar 13, 2026, at 15:05, Japin Li  wrote:
>>>> 
>>>> 
>>>> Hi, hackers
>>>> 
>>>> While reading smgr.h, I noticed an inconsistent type usage in
>>>> pgaio_io_set_target_smgr(). Currently the function is declared as:
>>>> 
>>>>   extern void pgaio_io_set_target_smgr(PgAioHandle *ioh,
>>>>                                        SMgrRelationData *smgr,
>>>>                                        ForkNumber forknum,
>>>>                                        BlockNumber blocknum,
>>>>                                        int nblocks,
>>>> 
>>>> However, SMgrRelation is defined as "typedef SMgrRelationData * SMgrRelation;",
>>>> and all other functions in the smgr subsystem use SMgrRelation as the parameter
>>>> type.
>>>> 
>>>> To keep the code consistent with the rest of the smgr API, this patch changes
>>>> the parameter from SMgrRelationData * to SMgrRelation in both the definition
>>>> and declaration.
>>>> 
>>>> This is purely a style/consistency cleanup with no functional change.
>>>> 
>>>> Thoughts? Is this change acceptable?
>>>> 
>>>> -- 
>>>> Regards,
>>>> Japin Li
>>>> ChengDu WenWu Information Technology Co., Ltd.
>>>> 
>>>> 
>>> 
>>> pgaio_io_set_target_smgr doesn’t update smgr, so, instead of “SMgrRelation”,  I think it’s better to change the type to "const SMgrRelationData *”.
>> 
>> Thanks for the review! Makes sense — I've updated the patch to v2.
>> 
>> -- 
>> Regards,
>> Japin Li
>> ChengDu WenWu Information Technology Co., Ltd.
>> 
>> 
>
> “const SMgrRelation *” will not work as you expected, you have to do “const SMgrRelationData *”. We want to protect the data the pointer pointing to from changing but the pointer itself.

Thanks for pointing that out!  I hadn't noticed the difference before.
Updated as you suggested.

>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/

-- 
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

Re: Use SMgrRelation instead of SMgrRelationData * in pgaio_io_set_target_smgr()

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Mar 16, 2026, at 10:31, Japin Li  wrote:
> 
> On Mon, 16 Mar 2026 at 08:50, Chao Li  wrote:
>>> On Mar 14, 2026, at 11:07, Japin Li  wrote:
>>> 
>>> 
>>> Hi, Chao
>>> 
>>> On Fri, 13 Mar 2026 at 15:29, Chao Li  wrote:
>>>>> On Mar 13, 2026, at 15:05, Japin Li  wrote:
>>>>> 
>>>>> 
>>>>> Hi, hackers
>>>>> 
>>>>> While reading smgr.h, I noticed an inconsistent type usage in
>>>>> pgaio_io_set_target_smgr(). Currently the function is declared as:
>>>>> 
>>>>>  extern void pgaio_io_set_target_smgr(PgAioHandle *ioh,
>>>>>                                       SMgrRelationData *smgr,
>>>>>                                       ForkNumber forknum,
>>>>>                                       BlockNumber blocknum,
>>>>>                                       int nblocks,
>>>>> 
>>>>> However, SMgrRelation is defined as "typedef SMgrRelationData * SMgrRelation;",
>>>>> and all other functions in the smgr subsystem use SMgrRelation as the parameter
>>>>> type.
>>>>> 
>>>>> To keep the code consistent with the rest of the smgr API, this patch changes
>>>>> the parameter from SMgrRelationData * to SMgrRelation in both the definition
>>>>> and declaration.
>>>>> 
>>>>> This is purely a style/consistency cleanup with no functional change.
>>>>> 
>>>>> Thoughts? Is this change acceptable?
>>>>> 
>>>>> -- 
>>>>> Regards,
>>>>> Japin Li
>>>>> ChengDu WenWu Information Technology Co., Ltd.
>>>>> 
>>>>> 
>>>> 
>>>> pgaio_io_set_target_smgr doesn’t update smgr, so, instead of “SMgrRelation”,  I think it’s better to change the type to "const SMgrRelationData *”.
>>> 
>>> Thanks for the review! Makes sense — I've updated the patch to v2.
>>> 
>>> -- 
>>> Regards,
>>> Japin Li
>>> ChengDu WenWu Information Technology Co., Ltd.
>>> 
>>> 
>> 
>> “const SMgrRelation *” will not work as you expected, you have to do “const SMgrRelationData *”. We want to protect the data the pointer pointing to from changing but the pointer itself.
> 
> Thanks for pointing that out!  I hadn't noticed the difference before.
> Updated as you suggested.
> 
>> 
>> Best regards,
>> --
>> Chao Li (Evan)
>> HighGo Software Co., Ltd.
>> https://www.highgo.com/
> 
> -- 
> Regards,
> Japin Li
> ChengDu WenWu Information Technology Co., Ltd.
> 
> 

V3 LGTM.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






FAQ