From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Regarding the order of the header file includes |
Date: | 2024-03-07 07:09:35 |
Message-ID: | CAMbWs4930LQ2y=NYuKpnFpS90L_xWkdEMJd1ev0=ZJ=6NuAm4Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Mar 6, 2024 at 6:25 PM Bharath Rupireddy <
bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> On Wed, Mar 6, 2024 at 3:02 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> >
> > I think we generally follow the rule that we include 'postgres.h' or
> > 'postgres_fe.h' first, followed by system header files, and then
> > postgres header files ordered in ASCII value. I noticed that in some C
> > files we fail to follow this rule strictly. Attached is a patch to fix
> > this.
> >
> > Back in 2019, we performed the same operation in commits 7e735035f2,
> > dddf4cdc33, and 14aec03502. It appears that the code has deviated from
> > that point onwards.
> >
> > Please note that this patch only addresses the order of header file
> > includes in backend modules (and might not be thorough). It is possible
> > that other modules may have a similar issue, but I have not evaluated
> > them yet.
>
> +1. I'm just curious to know if you've leveraged any tool from
> src/tools/pginclude or any script or such.
Thanks for looking.
While rebasing one of my patches I noticed that the header file includes
in relnode.c are not sorted in order. So I wrote a naive script to see
if any other C files have the same issue. The script is:
#!/bin/bash
find . -name "*.c" | while read -r file; do
headers=$(grep -o '#include "[^>]*"' "$file" |
grep -v "postgres.h" | grep -v "postgres_fe.h" |
sed 's/\.h"//g')
sorted_headers=$(echo "$headers" | sort)
results=$(diff <(echo "$headers") <(echo "$sorted_headers"))
if [[ $? != 0 ]]; then
echo "Headers in '$file' are out of order"
echo $results
echo
fi
done
Thanks
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2024-03-07 07:13:50 | Re: [PoC] Improve dead tuple storage for lazy vacuum |
Previous Message | Michael Paquier | 2024-03-07 07:07:17 | Re: Add new error_action COPY ON_ERROR "log" |