Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT

Lists: pgsql-hackers
From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-18 23:20:52
Message-ID: CAD21AoCU9YH+b9Rr8YRw7UjmB=1zh8GKQkWNiuN9mVhMvkyrRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I realized that building test_radixtree.c with TEST_SHARED_RT fails
because it eventually sets RT_SHMEM when #include'ing radixtree.h but
it's missing some header files to include. I've attached a patch to
include necessary header files in radixtree.h to make it
self-contained.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0001-Include-necessary-header-files-in-radixtree.h.patch application/octet-stream 974 bytes

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-18 23:41:30
Message-ID: 671136a1-f15e-4caa-ac5d-0e05e29dd754@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 19/11/2024 01:20, Masahiko Sawada wrote:
> I realized that building test_radixtree.c with TEST_SHARED_RT fails
> because it eventually sets RT_SHMEM when #include'ing radixtree.h but
> it's missing some header files to include. I've attached a patch to
> include necessary header files in radixtree.h to make it
> self-contained.

+1. Please make sure the #includes are in alphabetical order.

While we're at it, I noticed that lib/radixtree.h includes "postgres.h".
That's against our usual convention.

--
Heikki Linnakangas
Neon (https://neon.tech)


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-19 00:02:15
Message-ID: CAD21AoCZPtDnsXTzOogry54KfBsdiKgECvJNqpduPXEnckyGkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Nov 18, 2024 at 3:41 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>
> On 19/11/2024 01:20, Masahiko Sawada wrote:
> > I realized that building test_radixtree.c with TEST_SHARED_RT fails
> > because it eventually sets RT_SHMEM when #include'ing radixtree.h but
> > it's missing some header files to include. I've attached a patch to
> > include necessary header files in radixtree.h to make it
> > self-contained.
>
> +1. Please make sure the #includes are in alphabetical order.

Fixed.

>
> While we're at it, I noticed that lib/radixtree.h includes "postgres.h".
> That's against our usual convention.

Good catch. I've updated the patch accordingly.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v2-0001-Include-necessary-header-files-in-radixtree.h.patch application/octet-stream 1.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-19 00:50:09
Message-ID: 3621151.1731977409@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
> On Mon, Nov 18, 2024 at 3:41 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>> While we're at it, I noticed that lib/radixtree.h includes "postgres.h".
>> That's against our usual convention.

> Good catch. I've updated the patch accordingly.

Probably out of scope for this particular patch, but it occurred to me
to grep for other similar violations, and I found three:

src/bin/pg_combinebackup/copy_file.h:#include "c.h"
src/include/fe_utils/option_utils.h:#include "postgres_fe.h"
src/include/fe_utils/query_utils.h:#include "postgres_fe.h"

regards, tom lane


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-19 09:14:18
Message-ID: 202411190914.m5ctbskcsi4d@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 19/11/2024 01:20, Masahiko Sawada wrote:
> I realized that building test_radixtree.c with TEST_SHARED_RT fails
> because it eventually sets RT_SHMEM when #include'ing radixtree.h but
> it's missing some header files to include. I've attached a patch to
> include necessary header files in radixtree.h to make it
> self-contained.

If those includes are only needed when RT_SHMEM is defined, I suggest
they should be guarded by #ifdef RT_SHMEM, per Peter E's IWYU efforts
lately.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"La rebeldía es la virtud original del hombre" (Arthur Schopenhauer)


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-19 22:37:25
Message-ID: CAD21AoDwZZt_LLnZdR9nFXpK=B7kGUy2SxTPoNcE30Jsj_-GFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Nov 18, 2024 at 4:50 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> writes:
> > On Mon, Nov 18, 2024 at 3:41 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
> >> While we're at it, I noticed that lib/radixtree.h includes "postgres.h".
> >> That's against our usual convention.
>
> > Good catch. I've updated the patch accordingly.
>
> Probably out of scope for this particular patch, but it occurred to me
> to grep for other similar violations, and I found three:
>
> src/bin/pg_combinebackup/copy_file.h:#include "c.h"
> src/include/fe_utils/option_utils.h:#include "postgres_fe.h"
> src/include/fe_utils/query_utils.h:#include "postgres_fe.h"

Good catch, make sense to fix them too. Probably we can fix them
including the removal of inclusion of postgres.h from radixtree.h in
one commit, and fix the inclusion issue in radixtree.h in another
commit.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-19 22:37:56
Message-ID: CAD21AoAjRQ8y4ewZuJq6EByW5QaGcHY0i9=znUatEnhVvJDoYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 19, 2024 at 1:14 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> On 19/11/2024 01:20, Masahiko Sawada wrote:
> > I realized that building test_radixtree.c with TEST_SHARED_RT fails
> > because it eventually sets RT_SHMEM when #include'ing radixtree.h but
> > it's missing some header files to include. I've attached a patch to
> > include necessary header files in radixtree.h to make it
> > self-contained.
>
> If those includes are only needed when RT_SHMEM is defined, I suggest
> they should be guarded by #ifdef RT_SHMEM, per Peter E's IWYU efforts
> lately.

Indeed. I'll incorporate it in the next version.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix an error while building test_radixtree.c with TEST_SHARED_RT
Date: 2024-11-26 06:12:29
Message-ID: CAD21AoCM+1tEEBGnU8Z2i4j3ar31yWk_VzVosgw+=K0tGY0yvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 19, 2024 at 2:37 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Tue, Nov 19, 2024 at 1:14 AM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> >
> > On 19/11/2024 01:20, Masahiko Sawada wrote:
> > > I realized that building test_radixtree.c with TEST_SHARED_RT fails
> > > because it eventually sets RT_SHMEM when #include'ing radixtree.h but
> > > it's missing some header files to include. I've attached a patch to
> > > include necessary header files in radixtree.h to make it
> > > self-contained.
> >
> > If those includes are only needed when RT_SHMEM is defined, I suggest
> > they should be guarded by #ifdef RT_SHMEM, per Peter E's IWYU efforts
> > lately.
>
> Indeed. I'll incorporate it in the next version.
>

I've attached the updated patches. Please review them.

I think we should backpatch the fix for radixtree.h so I kept these
changes separated from other changes.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v3-0001-Remove-inclusion-of-fundamental-header-files-from.patch application/octet-stream 1.8 KB
v3-0002-Include-necessary-header-files-in-radixtree.h.patch application/octet-stream 1.4 KB