Re: Regarding the order of the header file includes

Поиск
Список
Период
Сортировка
От Richard Guo
Тема Re: Regarding the order of the header file includes
Дата
Msg-id CAMbWs4930LQ2y=NYuKpnFpS90L_xWkdEMJd1ev0=ZJ=6NuAm4Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Regarding the order of the header file includes  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Ответы Re: Regarding the order of the header file includes  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Список pgsql-hackers

On Wed, Mar 6, 2024 at 6:25 PM Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote:
On Wed, Mar 6, 2024 at 3:02 PM Richard Guo <guofenglinux@gmail.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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Add new error_action COPY ON_ERROR "log"
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: [PoC] Improve dead tuple storage for lazy vacuum