Thread

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pgindent: improve formatting of multiline comments.

  2. Adjust style of some debugging macros.

  3. Fix a couple of comments.

  4. Add IGNORE NULLS/RESPECT NULLS option to Window functions.

  5. Split WaitEventSet functions to separate source file

  1. [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@timescale.com> — 2025-06-19T14:51:36Z

    Hi,
    
    Michael (cc:'ed) pointed out [1] that pg_bsd_indent could do a
    slightly better job when it comes to formatting multiline comments. I
    prepared a patch that fixes this.
    
    How to test it:
    
    ```
    ninja -C build
    cp build/src/tools/pg_bsd_indent/pg_bsd_indent ~/bin/pg_bsd_indent
    cp src/tools/pgindent/pgindent ~/bin/pgindent
    pgindent src/backend/utils/adt/varlena.c
    git diff
    ```
    
    Expected changes:
    
    ```
    -/* name_text()
    +/*
    + * name_text()
      * Converts a Name type to a text type.
      */
    ```
    
    Everything else should work as before.
    
    Thoughts and feedback are most welcomed.
    
    [1]: https://postgr.es/m/CAJ7c6TN7ppSmZMPejvKZreOs%3D%2BkJEhrGQNuVpmTjj9W-%3DMjgCg%40mail.gmail.com
    
    -- 
    Best regards,
    Aleksander Alekseev
    
  2. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Arseniy Mukhin <arseniy.mukhin.dev@gmail.com> — 2025-06-19T20:33:55Z

    On Thu, Jun 19, 2025 at 5:51 PM Aleksander Alekseev
    <aleksander@timescale.com> wrote:
    >
    > Hi,
    >
    > Michael (cc:'ed) pointed out [1] that pg_bsd_indent could do a
    > slightly better job when it comes to formatting multiline comments. I
    > prepared a patch that fixes this.
    >
    > How to test it:
    >
    > ```
    > ninja -C build
    > cp build/src/tools/pg_bsd_indent/pg_bsd_indent ~/bin/pg_bsd_indent
    > cp src/tools/pgindent/pgindent ~/bin/pgindent
    > pgindent src/backend/utils/adt/varlena.c
    > git diff
    > ```
    >
    > Expected changes:
    >
    > ```
    > -/* name_text()
    > +/*
    > + * name_text()
    >   * Converts a Name type to a text type.
    >   */
    > ```
    >
    > Everything else should work as before.
    >
    > Thoughts and feedback are most welcomed.
    >
    > [1]: https://postgr.es/m/CAJ7c6TN7ppSmZMPejvKZreOs%3D%2BkJEhrGQNuVpmTjj9W-%3DMjgCg%40mail.gmail.com
    >
    > --
    > Best regards,
    > Aleksander Alekseev
    
    Hi Aleksander!
    
    Thank you for the patch!
    
    I tried it with the whole project and almost always it works great.
    But I noticed two cases where it works probably not as expected:
    
    1) comments which don't have a star on each line. For example:
    file 'cube.c'
    
    before:
    /* make up a metric in which one box will be 'lower' than the other
       -- this can be useful for sorting and to determine uniqueness */
    
    after:
    /*
     * make up a metric in which one box will be 'lower' than the other
       -- this can be useful for sorting and to determine uniqueness */
    
    2) comments where closing */ is on the last comment line. For example:
    file 'crypt-blowfish.c'
    
    before:
    /* This has to be bug-compatible with the original implementation, so
     * only encode 23 of the 24 bytes. :-) */
    
    after:
    /*
     * This has to be bug-compatible with the original implementation, so
     * only encode 23 of the 24 bytes. :-) */
    
    
    Best regards,
    Arseniy Mukhin
    
    
    
    
  3. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@timescale.com> — 2025-06-20T13:44:08Z

    Hi Arseniy,
    
    > I tried it with the whole project and almost always it works great.
    > But I noticed two cases where it works probably not as expected:
    >
    > 1) comments which don't have a star on each line. For example:
    > file 'cube.c'
    >
    > before:
    > /* make up a metric in which one box will be 'lower' than the other
    >    -- this can be useful for sorting and to determine uniqueness */
    >
    > after:
    > /*
    >  * make up a metric in which one box will be 'lower' than the other
    >    -- this can be useful for sorting and to determine uniqueness */
    >
    > 2) comments where closing */ is on the last comment line. For example:
    > file 'crypt-blowfish.c'
    >
    > before:
    > /* This has to be bug-compatible with the original implementation, so
    >  * only encode 23 of the 24 bytes. :-) */
    >
    > after:
    > /*
    >  * This has to be bug-compatible with the original implementation, so
    >  * only encode 23 of the 24 bytes. :-) */
    
    Thanks for the review. You are right, these comments shouldn't be affected.
    
    It's going to be simpler to modify pgindent then. PFA the updated patch.
    
    -- 
    Best regards,
    Aleksander Alekseev
    
  4. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Bruce Momjian <bruce@momjian.us> — 2025-06-20T13:56:41Z

    On Fri, Jun 20, 2025 at 04:44:08PM +0300, Aleksander Alekseev wrote:
    > Hi Arseniy,
    > 
    > > I tried it with the whole project and almost always it works great.
    > > But I noticed two cases where it works probably not as expected:
    > >
    > > 1) comments which don't have a star on each line. For example:
    > > file 'cube.c'
    > >
    > > before:
    > > /* make up a metric in which one box will be 'lower' than the other
    > >    -- this can be useful for sorting and to determine uniqueness */
    > >
    > > after:
    > > /*
    > >  * make up a metric in which one box will be 'lower' than the other
    > >    -- this can be useful for sorting and to determine uniqueness */
    > >
    > > 2) comments where closing */ is on the last comment line. For example:
    > > file 'crypt-blowfish.c'
    > >
    > > before:
    > > /* This has to be bug-compatible with the original implementation, so
    > >  * only encode 23 of the 24 bytes. :-) */
    > >
    > > after:
    > > /*
    > >  * This has to be bug-compatible with the original implementation, so
    > >  * only encode 23 of the 24 bytes. :-) */
    > 
    > Thanks for the review. You are right, these comments shouldn't be affected.
    > 
    > It's going to be simpler to modify pgindent then. PFA the updated patch.
    
    Given the quality of BSD indent code, I have _always_ found it easier to
    modify pgindent.  ;-
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        https://momjian.us
      EDB                                      https://enterprisedb.com
    
      Do not let urgent matters crowd out time for investment in the future.
    
    
    
    
  5. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@timescale.com> — 2025-06-20T14:01:41Z

    Hi,
    
    > Given the quality of BSD indent code, I have _always_ found it easier to
    > modify pgindent.  ;-
    
    :D Initially I thought that the problem was simple enough to solve it
    in C, but this turned out not to be true.
    
    > It's going to be simpler to modify pgindent then. PFA the updated patch.
    
    I noticed a mistake in v2. Here is the corrected patch. Changes
    comparing to the previous version:
    
    ```
    -    $lines[-1] =~ s!/(.+)\*/!/$1\n \*/!;
    +    $lines[-1] =~ s!(.+) \*/!$1\n \*/!;
    ```
    
    -- 
    Best regards,
    Aleksander Alekseev
    
  6. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Bruce Momjian <bruce@momjian.us> — 2025-06-20T14:14:17Z

    On Fri, Jun 20, 2025 at 05:01:41PM +0300, Aleksander Alekseev wrote:
    > Hi,
    > 
    > > Given the quality of BSD indent code, I have _always_ found it easier to
    > > modify pgindent.  ;-
    > 
    > :D Initially I thought that the problem was simple enough to solve it
    > in C, but this turned out not to be true.
    
    I always found it ironic that a tool designed to make source code easier
    to understand like BSD indent is so hard to understand.  Its use of
    short variable names alone is confusing.
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        https://momjian.us
      EDB                                      https://enterprisedb.com
    
      Do not let urgent matters crowd out time for investment in the future.
    
    
    
    
  7. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Arseniy Mukhin <arseniy.mukhin.dev@gmail.com> — 2025-06-21T18:54:21Z

    On Fri, Jun 20, 2025 at 5:01 PM Aleksander Alekseev
    <aleksander@timescale.com> wrote:
    >
    > Hi,
    >
    > > Given the quality of BSD indent code, I have _always_ found it easier to
    > > modify pgindent.  ;-
    >
    > :D Initially I thought that the problem was simple enough to solve it
    > in C, but this turned out not to be true.
    >
    > > It's going to be simpler to modify pgindent then. PFA the updated patch.
    >
    > I noticed a mistake in v2. Here is the corrected patch. Changes
    > comparing to the previous version:
    >
    
    Thanks!
    
    Now it affects 4 times more files (380). What I noticed:
    1) Most of the comments are bordered comments like this:
    -/* --------------------------------------------------------------------------------
    +/*
    + * --------------------------------------------------------------------------------
      * Public IO related functions operating on IO Handles
      * --------------------------------------------------------------------------------
      */
    
    Do we want to skip such comments?
    I have also seen comments with '====' border.
    
    2) Some comments like this:
    
    before:
    /* Author: Linus Tolke
       (actually most if the code is "borrowed" from the distribution and just
       slightly modified)
     */
    
    after:
    /*
     * Author: Linus Tolke
       (actually most if the code is "borrowed" from the distribution and just
       slightly modified)
     */
    
    I guess closing */ on the separate line is the trigger?
    If I'm not wrong there are only 3 such comments, maybe it is easier to
    fix them by hand?)
    
    3) It seems all geqo related file contains such comment:
    -/* contributed by:
    +/*
    + * contributed by:
        =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
        *  Martin Utesch                             * Institute of
    Automatic Control          *
        =
    
    
    Best regards,
    Arseniy Mukhin
    
    
    
    
  8. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@timescale.com> — 2025-06-23T10:42:32Z

    Hi Arseniy,
    
    Thanks for the feedback!
    
    > Now it affects 4 times more files (380). What I noticed:
    > 1) Most of the comments are bordered comments like this:
    > -/* --------------------------------------------------------------------------------
    > +/*
    > + * --------------------------------------------------------------------------------
    >   * Public IO related functions operating on IO Handles
    >   * --------------------------------------------------------------------------------
    >   */
    >
    > Do we want to skip such comments?
    > I have also seen comments with '====' border.
    
    Personally I don't have a strong opinion on this. We can easily add an
    exception for "/* ---" and "/* ===" comments if somebody believes this
    is a problem. I choose not to add such an exception just yet only
    because I don't like unnecessary exceptions :)
    
    > 2) Some comments like this:
    >
    > before:
    > /* Author: Linus Tolke
    >    (actually most if the code is "borrowed" from the distribution and just
    >    slightly modified)
    >  */
    >
    > after:
    > /*
    >  * Author: Linus Tolke
    >    (actually most if the code is "borrowed" from the distribution and just
    >    slightly modified)
    >  */
    >
    > I guess closing */ on the separate line is the trigger?
    > If I'm not wrong there are only 3 such comments, maybe it is easier to
    > fix them by hand?)
    >
    > 3) It seems all geqo related file contains such comment:
    > -/* contributed by:
    > +/*
    > + * contributed by:
    >     =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
    >     *  Martin Utesch                             * Institute of
    > Automatic Control          *
    
    You are right, these comments shouldn't have been changed. Apparently
    the script is going to need slightly more complicated checks that I
    initially thought.
    
    Here is the corrected patch v4.
    
    -- 
    Best regards,
    Aleksander Alekseev
    
  9. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Nathan Bossart <nathandbossart@gmail.com> — 2025-10-23T20:25:15Z

    On Mon, Jun 23, 2025 at 01:42:32PM +0300, Aleksander Alekseev wrote:
    >> Do we want to skip such comments?
    >> I have also seen comments with '====' border.
    > 
    > Personally I don't have a strong opinion on this. We can easily add an
    > exception for "/* ---" and "/* ===" comments if somebody believes this
    > is a problem. I choose not to add such an exception just yet only
    > because I don't like unnecessary exceptions :)
    
    +1 for adding an exception for "/* -----" style comments.  I tested running
    pgindent after applying the patch, and the first thing I noticed was all
    these (IMHO) unnecessary changes.  I don't think it helps readability, and
    even if it did, it's arguably not worth the churn.
    
    -- 
    nathan
    
    
    
    
  10. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@tigerdata.com> — 2025-10-27T12:13:33Z

    Hi Nathan,
    
    > > Personally I don't have a strong opinion on this. We can easily add an
    > > exception for "/* ---" and "/* ===" comments if somebody believes this
    > > is a problem. I choose not to add such an exception just yet only
    > > because I don't like unnecessary exceptions :)
    >
    > +1 for adding an exception for "/* -----" style comments.  I tested running
    > pgindent after applying the patch, and the first thing I noticed was all
    > these (IMHO) unnecessary changes.  I don't think it helps readability, and
    > even if it did, it's arguably not worth the churn.
    
    OK, here is the corrected patch v5.
    
    -- 
    Best regards,
    Aleksander Alekseev
    
  11. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Nathan Bossart <nathandbossart@gmail.com> — 2025-10-27T14:55:38Z

    On Mon, Oct 27, 2025 at 03:13:33PM +0300, Aleksander Alekseev wrote:
    > OK, here is the corrected patch v5.
    
    Thanks.  I had to run pgindent twice before it stopped making changes, but
    the results look pretty good to me.  However, I still noticed a few
    oddities.
    
    --- a/contrib/seg/seg.c
    +++ b/contrib/seg/seg.c
    @@ -2,9 +2,9 @@
      * contrib/seg/seg.c
      *
      ******************************************************************************
    -  This file contains routines that can be bound to a Postgres backend and
    -  called by the backend in the process of processing queries.  The calling
    -  format for these routines is dictated by Postgres architecture.
    + *  This file contains routines that can be bound to a Postgres backend and
    + *  called by the backend in the process of processing queries.  The calling
    + *  format for these routines is dictated by Postgres architecture.
     ******************************************************************************/
    
    This one is a little weird, but maybe it's okay...  It looks like pgindent
    retains the spacing (or lack of spacing) in this situation.  It's probably
    not worth the complexity to try to make it smarter here.
    
    --- a/src/backend/access/nbtree/nbtsort.c
    +++ b/src/backend/access/nbtree/nbtsort.c
    @@ -69,7 +69,7 @@
     /*
      * DISABLE_LEADER_PARTICIPATION disables the leader's participation in
      * parallel index builds.  This may be useful as a debugging aid.
    -#undef DISABLE_LEADER_PARTICIPATION
    + *#undef DISABLE_LEADER_PARTICIPATION
      */
    
    IMHO we should either remove this line or move it out of the comment.
    AFAICT we ordinarily don't #undef debugging stuff like this, presumably so
    you can change it with compile flags.
    
    In aclcheck.c and analyze.c, The **** and ==== lines are still getting
    bumped down to a new line.
    
    -.* This function just encapsulates the framing rules.
    + *.* This function just encapsulates the framing rules.
    
    This looks like a goof in commit 25a30bb.  I'll go fix that one separately.
    
    --- a/src/backend/storage/ipc/waiteventset.c
    +++ b/src/backend/storage/ipc/waiteventset.c
    @@ -2010,7 +2010,7 @@ ResOwnerReleaseWaitEventSet(Datum res)
      * NB: be sure to save and restore errno around it.  (That's standard practice
      * in most signal handlers, of course, but we used to omit it in handlers that
      * only set a flag.) XXX
    -  *
    + *  *
    
    This one looks like a goof in commit 393e0d2.  It's interesting that
    pgindent chooses to add an extra * here, though.
    
    -- 
    nathan
    
    
    
    
  12. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Michael Paquier <michael@paquier.xyz> — 2025-10-27T23:35:15Z

    On Mon, Oct 27, 2025 at 09:55:38AM -0500, Nathan Bossart wrote:
    >  /*
    >   * DISABLE_LEADER_PARTICIPATION disables the leader's participation in
    >   * parallel index builds.  This may be useful as a debugging aid.
    > -#undef DISABLE_LEADER_PARTICIPATION
    > + *#undef DISABLE_LEADER_PARTICIPATION
    >   */
    > 
    > IMHO we should either remove this line or move it out of the comment.
    > AFAICT we ordinarily don't #undef debugging stuff like this, presumably so
    > you can change it with compile flags.
    
    I would put this one on a separate line, outside the comment.  It's
    minor, still we use this style in pg_config_manual.h.  See around
    REALLOCATE_BITMAPSETS.
    --
    Michael
    
  13. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Chao Li <li.evan.chao@gmail.com> — 2025-10-28T00:36:33Z

    
    > On Oct 28, 2025, at 07:35, Michael Paquier <michael@paquier.xyz> wrote:
    > 
    > On Mon, Oct 27, 2025 at 09:55:38AM -0500, Nathan Bossart wrote:
    >> /*
    >>  * DISABLE_LEADER_PARTICIPATION disables the leader's participation in
    >>  * parallel index builds.  This may be useful as a debugging aid.
    >> -#undef DISABLE_LEADER_PARTICIPATION
    >> + *#undef DISABLE_LEADER_PARTICIPATION
    >>  */
    >> 
    >> IMHO we should either remove this line or move it out of the comment.
    >> AFAICT we ordinarily don't #undef debugging stuff like this, presumably so
    >> you can change it with compile flags.
    > 
    > I would put this one on a separate line, outside the comment.  It's
    > minor, still we use this style in pg_config_manual.h.  See around
    > REALLOCATE_BITMAPSETS.
    > --
    > Michael
    
    +1
    
    --
    Chao Li (Evan)
    HighGo Software Co., Ltd.
    https://www.highgo.com/
    
    
    
    
    
    
    
    
  14. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Chao Li <li.evan.chao@gmail.com> — 2025-10-28T00:57:36Z

    
    > On Oct 27, 2025, at 20:13, Aleksander Alekseev <aleksander@tigerdata.com> wrote:
    > 
    > Hi Nathan,
    > 
    >>> Personally I don't have a strong opinion on this. We can easily add an
    >>> exception for "/* ---" and "/* ===" comments if somebody believes this
    >>> is a problem. I choose not to add such an exception just yet only
    >>> because I don't like unnecessary exceptions :)
    >> 
    >> +1 for adding an exception for "/* -----" style comments.  I tested running
    >> pgindent after applying the patch, and the first thing I noticed was all
    >> these (IMHO) unnecessary changes.  I don't think it helps readability, and
    >> even if it did, it's arguably not worth the churn.
    > 
    > OK, here is the corrected patch v5.
    > 
    > -- 
    > Best regards,
    > Aleksander Alekseev
    > <v5-0001-pgindent-improve-formatting-of-multiline-comments.patch>
    
    1. I just ran the patched pgindent against a random file, then I got a lot diffs like:
    
    ```
            /*
    -        * Direct advancement: avoid waking non-caught up backends that
    -        * aren't interested in our notifications.
    +        * Direct advancement: avoid waking non-caught up backends that aren't
    +        * interested in our notifications.
             */
    ```
    
    I am afraid that would generate a lot of noises for future reviews.
    
    2. A typo in the patch
    
    ```
    +    # Check each line except for the fist and the last one
    ```
    
    fist => first
    
    3. As you are updating pgindent, I want to report an issue, you may address in a separate patch or just in this patch, up to you.
    
    See this code:
    ```
                else
                     /*
                      * fetch all the rest of the page
                      */
                     copysize = QUEUE_PAGESIZE - curoffset;
    ```
    
    In the “else” clause, there is a multiple-line comment block, and a single line of code. Pgindent will add an empty line between “else” and the comment block, which is weird. If the comment is one-line, then no empty line will be inserted.
    
    Best regards,
    --
    Chao Li (Evan)
    HighGo Software Co., Ltd.
    https://www.highgo.com/
    
    
    
    
    
  15. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@tigerdata.com> — 2025-11-10T09:28:06Z

    Hi,
    
    > I am afraid that would generate a lot of noises for future reviews.
    >
    > 2. A typo in the patch
    >
    > ```
    > +    # Check each line except for the fist and the last one
    > ```
    
    Thanks, fixed.
    
    > 3. As you are updating pgindent, I want to report an issue, you may address in a separate patch or just in this patch, up to you.
    >
    > See this code:
    > ```
    >             else
    >                  /*
    >                   * fetch all the rest of the page
    >                   */
    >                  copysize = QUEUE_PAGESIZE - curoffset;
    > ```
    >
    > In the “else” clause, there is a multiple-line comment block, and a single line of code. Pgindent will add an empty line between “else” and the comment block, which is weird. If the comment is one-line, then no empty line will be inserted.
    
    I didn't manage to find this code. The closest thing I see is in
    src/backend/commands/async.c:
    
    ```
                else
                {
                    /* fetch all the rest of the page */
                    copysize = QUEUE_PAGESIZE - curoffset;
                }
    ```
    
    Last time it was touched 15 years ago and pgindent processes it as expected.
    
    > 1. I just ran the patched pgindent against a random file, then I got a lot diffs like:
    >
    > ```
    >         /*
    > -        * Direct advancement: avoid waking non-caught up backends that
    > -        * aren't interested in our notifications.
    > +        * Direct advancement: avoid waking non-caught up backends that aren't
    > +        * interested in our notifications.
    >          */
    > ```
    
    I'm not sure if this is part of the PostgreSQL code base either. My
    best guess is that something is wrong with whitespaces here (tabs vs
    spaces). We have plenty of multiline comments like this and from what
    I can tell they are processed correctly.
    
    -- 
    Best regards,
    Aleksander Alekseev
    
  16. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Chao Li <li.evan.chao@gmail.com> — 2025-11-11T06:28:43Z

    
    > On Nov 10, 2025, at 17:28, Aleksander Alekseev <aleksander@tigerdata.com> wrote:
    > 
    >> 1. I just ran the patched pgindent against a random file, then I got a lot diffs like:
    >> 
    >> ```
    >>        /*
    >> -        * Direct advancement: avoid waking non-caught up backends that
    >> -        * aren't interested in our notifications.
    >> +        * Direct advancement: avoid waking non-caught up backends that aren't
    >> +        * interested in our notifications.
    >>         */
    >> ```
    > 
    > I'm not sure if this is part of the PostgreSQL code base either. My
    > best guess is that something is wrong with whitespaces here (tabs vs
    > spaces). We have plenty of multiline comments like this and from what
    > I can tell they are processed correctly.
    
    I recalled that. I ran pgindent on a file from a patch I was reviewing, so, the file was not pgindent-ed yet at the time.
    
    I just tried to run the patched pgindent on several files and no diff generated. So this comment is resolved.
    
    Regards,
    --
    Chao Li (Evan)
    HighGo Software Co., Ltd.
    https://www.highgo.com/
    
    
    
    
    
    
    
    
  17. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Nathan Bossart <nathandbossart@gmail.com> — 2025-12-11T21:43:31Z

    On Tue, Oct 28, 2025 at 08:36:33AM +0800, Chao Li wrote:
    > On Oct 28, 2025, at 07:35, Michael Paquier <michael@paquier.xyz> wrote:
    >> On Mon, Oct 27, 2025 at 09:55:38AM -0500, Nathan Bossart wrote:
    >>> /*
    >>>  * DISABLE_LEADER_PARTICIPATION disables the leader's participation in
    >>>  * parallel index builds.  This may be useful as a debugging aid.
    >>> -#undef DISABLE_LEADER_PARTICIPATION
    >>> + *#undef DISABLE_LEADER_PARTICIPATION
    >>>  */
    >>> 
    >>> IMHO we should either remove this line or move it out of the comment.
    >>> AFAICT we ordinarily don't #undef debugging stuff like this, presumably so
    >>> you can change it with compile flags.
    >> 
    >> I would put this one on a separate line, outside the comment.  It's
    >> minor, still we use this style in pg_config_manual.h.  See around
    >> REALLOCATE_BITMAPSETS.
    > 
    > +1
    
    Here's a patch for this.  I also changed the #undefs to #defines.
    
    -- 
    nathan
    
  18. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Nathan Bossart <nathandbossart@gmail.com> — 2025-12-11T21:48:27Z

    With the latest patch applied, I'm still seeing problems with **** and ====
    lines in aclcheck.c and analyze.c, as mentioned upthread [0].  I think we
    should also figure out what we want to do for things like this:
    
      ******************************************************************************
    -  This file contains routines that can be bound to a Postgres backend and
    -  called by the backend in the process of processing queries.  The calling
    -  format for these routines is dictated by Postgres architecture.
    + *  This file contains routines that can be bound to a Postgres backend and
    + *  called by the backend in the process of processing queries.  The calling
    + *  format for these routines is dictated by Postgres architecture.
     ******************************************************************************/
    
    Could we modify the patch to leave these kinds of comments alone?
    
    [0] https://postgr.es/m/aP-H6kSsGOxaB21k%40nathan
    
    -- 
    nathan
    
    
    
    
  19. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@tigerdata.com> — 2025-12-12T11:32:13Z

    Hi Nathan,
    
    > [...]
    > I think we should also figure out what we want to do for things like this:
    >
    >   ******************************************************************************
    > -  This file contains routines that can be bound to a Postgres backend and
    > -  called by the backend in the process of processing queries.  The calling
    > -  format for these routines is dictated by Postgres architecture.
    > + *  This file contains routines that can be bound to a Postgres backend and
    > + *  called by the backend in the process of processing queries.  The calling
    > + *  format for these routines is dictated by Postgres architecture.
    >  ******************************************************************************/
    >
    > Could we modify the patch to leave these kinds of comments alone?
    
    I see 3 files that have this comment:
    
    - src/tutorial/complex.c
    - contrib/seg/seg.c
    - contrib/cube/cube.c
    
    Note that cube.c is not affected by the new version of pgindent,
    because the comment starts with `/****`. Such comments are kept as is.
    
    seg.c and cube.c use a mixed format. The comments start with `/*`
    followed by ` *` lines but several lines below don't have ` *` in the
    beginning. I don't instantly see a way to process this situation in
    pgindent. We can either let it modify these comments, or alternatively
    change the first lines of the comments from `/*` to `/**`.
    
    -- 
    Best regards,
    Aleksander Alekseev
    
    
    
    
  20. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Álvaro Herrera <alvherre@kurilemu.de> — 2025-12-12T15:53:39Z

    It's strange to see this thread go on about messing with the Perl script
    because we're too afraid of pg_bsd_indent.  Maybe we should take
    ownership of that code -- improve its own indentation to our
    conventions, add comments, rename unclear variables, and so on until we
    have something we can work with, and fix these weird bugs and
    idiosincratic behaviors we don't like.  I just found out this code dates
    back from 1976.
    
    We have a _huge_ regression test for it: our own source code repository.
    It's not like any breakage is going to go unnoticed.
    
    -- 
    Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
    "Cómo ponemos nuestros dedos en la arcilla del otro. Eso es la amistad; jugar
    al alfarero y ver qué formas se pueden sacar del otro" (C. Halloway en
    La Feria de las Tinieblas, R. Bradbury)
    
    
    
    
  21. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Tom Lane <tgl@sss.pgh.pa.us> — 2025-12-12T16:17:01Z

    =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@kurilemu.de> writes:
    > It's strange to see this thread go on about messing with the Perl script
    > because we're too afraid of pg_bsd_indent.  Maybe we should take
    > ownership of that code -- improve its own indentation to our
    > conventions, add comments, rename unclear variables, and so on until we
    > have something we can work with, and fix these weird bugs and
    > idiosincratic behaviors we don't like.  I just found out this code dates
    > back from 1976.
    
    I've worked with that code a little bit, and it's mostly unreadable
    spaghetti :-(.  If somebody wants to make an effort to make it not
    so awful, that'd be great, but I fear it's a very nontrivial project.
    
    Having said that, we've already basically forked it from the NetBSD
    upstream, so there is no reason not to diverge further.
    
    > We have a _huge_ regression test for it: our own source code repository.
    > It's not like any breakage is going to go unnoticed.
    
    True.
    
    			regards, tom lane
    
    
    
    
  22. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Nathan Bossart <nathandbossart@gmail.com> — 2025-12-12T16:23:14Z

    On Fri, Dec 12, 2025 at 11:17:01AM -0500, Tom Lane wrote:
    > =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@kurilemu.de> writes:
    >> It's strange to see this thread go on about messing with the Perl script
    >> because we're too afraid of pg_bsd_indent.  Maybe we should take
    >> ownership of that code -- improve its own indentation to our
    >> conventions, add comments, rename unclear variables, and so on until we
    >> have something we can work with, and fix these weird bugs and
    >> idiosincratic behaviors we don't like.  I just found out this code dates
    >> back from 1976.
    > 
    > I've worked with that code a little bit, and it's mostly unreadable
    > spaghetti :-(.  If somebody wants to make an effort to make it not
    > so awful, that'd be great, but I fear it's a very nontrivial project.
    
    Yeah, I tried to find a bug in it recently and could do little more than
    trial-and-error in the areas that seemed vaguely close (with no success).
    I'm generally critical of efforts to rewrite things from scratch, but this
    might be a case where it's the better option.
    
    -- 
    nathan
    
    
    
    
  23. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Tom Lane <tgl@sss.pgh.pa.us> — 2025-12-12T18:37:23Z

    Nathan Bossart <nathandbossart@gmail.com> writes:
    > Yeah, I tried to find a bug in it recently and could do little more than
    > trial-and-error in the areas that seemed vaguely close (with no success).
    > I'm generally critical of efforts to rewrite things from scratch, but this
    > might be a case where it's the better option.
    
    There's something to be said for that approach.  Presumably, a rewrite
    could be smaller because we wouldn't need to support all the options
    bsd_indent has, just the behavior PG wants.
    
    I wonder whether it'd be possible to get rid of the need for
    typedefs.list while at it.  That might be impractical --- IIRC, C
    syntax is ambiguous if you don't know which identifiers are typedefs.
    Still, I believe there are other indenters that get away without
    that knowledge, so maybe the ambiguity isn't fatal for indentation
    purposes.
    
    With or without that nice-to-have, it'd be a lot of work with
    not all that much payoff, so I'm finding it hard to recommend
    that somebody go after this.  But maybe someone will find it
    irresistible to scratch that itch.
    
    			regards, tom lane
    
    
    
    
  24. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@tigerdata.com> — 2025-12-12T21:47:30Z

    Hi,
    
    > It's strange to see this thread go on about messing with the Perl script
    > because we're too afraid of pg_bsd_indent.  Maybe we should take
    > ownership of that code -- improve its own indentation to our
    > conventions, add comments, rename unclear variables, and so on until we
    > have something we can work with, and fix these weird bugs and
    > idiosincratic behaviors we don't like.  I just found out this code dates
    > back from 1976.
    
    > With or without that nice-to-have, it'd be a lot of work with
    > not all that much payoff, so I'm finding it hard to recommend
    > that somebody go after this.  But maybe someone will find it
    > irresistible to scratch that itch.
    
    I was thinking just recently that rewriting pgindent in Python might
    be a good idea for future refactoring, but probably only if and after
    we merge PyTest patchset [1]. (Which strangely enough is missing on
    the nearest open commitfest.)
    
    [1]: https://www.postgresql.org/message-id/flat/CAOYmi%2BkThkM9Z87u%3DR_Wi7fCor2i%2BUZKAyq0UCyprzCwTQvqgA%40mail.gmail.com
    --
    Best regards,
    Aleksander Alekseev
    
    
    
    
  25. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Bruce Momjian <bruce@momjian.us> — 2025-12-19T20:02:12Z

    On Fri, Dec 12, 2025 at 11:17:01AM -0500, Tom Lane wrote:
    > =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@kurilemu.de> writes:
    > > It's strange to see this thread go on about messing with the Perl script
    > > because we're too afraid of pg_bsd_indent.  Maybe we should take
    > > ownership of that code -- improve its own indentation to our
    > > conventions, add comments, rename unclear variables, and so on until we
    > > have something we can work with, and fix these weird bugs and
    > > idiosincratic behaviors we don't like.  I just found out this code dates
    > > back from 1976.
    > 
    > I've worked with that code a little bit, and it's mostly unreadable
    > spaghetti :-(.  If somebody wants to make an effort to make it not
    > so awful, that'd be great, but I fear it's a very nontrivial project.
    
    Yes, this is why we had to wrap the pg_bsd_indent call in Perl.
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        https://momjian.us
      EDB                                      https://enterprisedb.com
    
      Do not let urgent matters crowd out time for investment in the future.
    
    
    
    
  26. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Michael Paquier <michael@paquier.xyz> — 2025-12-21T22:33:15Z

    On Fri, Dec 19, 2025 at 03:02:12PM -0500, Bruce Momjian wrote:
    > On Fri, Dec 12, 2025 at 11:17:01AM -0500, Tom Lane wrote:
    >> =?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@kurilemu.de> writes:
    >>> It's strange to see this thread go on about messing with the Perl script
    >>> because we're too afraid of pg_bsd_indent.  Maybe we should take
    >>> ownership of that code -- improve its own indentation to our
    >>> conventions, add comments, rename unclear variables, and so on until we
    >>> have something we can work with, and fix these weird bugs and
    >>> idiosincratic behaviors we don't like.  I just found out this code dates
    >>> back from 1976.
    >> 
    >> I've worked with that code a little bit, and it's mostly unreadable
    >> spaghetti :-(.  If somebody wants to make an effort to make it not
    >> so awful, that'd be great, but I fear it's a very nontrivial project.
    > 
    > Yes, this is why we had to wrap the pg_bsd_indent call in Perl.
    
    Removing one layer, finishing with only a C function or a perl script
    would be really nice.  I am wondering if removing the perl script
    would not be the way to go, just owning the portion of the code we
    care about, which is already in the tree anyway.
    
    From what I can see, we rely on a set of options through $indent_opts,
    it seems like one would enter a fail-and-retry repeat loop until
    things get rather right: 
    - Remove as much code from pg_bsd_indent as possible.
    - Integrate some of the options in the perl script into the binary.
    
    If the binary gets slim enough and more understandable, perhaps we
    could even keep both, we have all the pgtypedef business which is
    specific to the Postgres tree as well.
    --
    Michael
    
  27. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Tom Lane <tgl@sss.pgh.pa.us> — 2026-05-04T16:40:19Z

    Aleksander Alekseev <aleksander@tigerdata.com> writes:
    > Thanks, Nathan. Re-submitting v6 to make it visible by cfbot again and
    > in order to simplify the work of reviewers a bit.
    
    I tested the v6 patch by running it on current HEAD.  Pretty nearly all
    the changes it makes are improvements, but it seems like there's still
    some work to be done.  In particular, in src/port/inet_aton.c it
    produces this diff:
    
    --- a/src/port/inet_aton.c
    +++ b/src/port/inet_aton.c
    @@ -36,7 +37,8 @@
      * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    - * SUCH DAMAGE.  */
    + * SUCH DAMAGE. 
    + */
     
     #include "c.h"
    
    in which not all the trailing whitespace has been removed from the
    first line, causing "git diff --check" to complain:
    
    $ git diff --check
    src/port/inet_aton.c:40: trailing whitespace.
    + * SUCH DAMAGE. 
    
    In this case the problem is that the cleanup pattern only accounts for
    one trailing space.  But a variant of this, which I think affects many
    of the steps in the patch, is that there could be tab(s) there.  You
    should fix the patterns to allow any number of spaces/tabs at the
    spots where they currently expect just one space.  This might result
    in finding cleanups they miss now.
    
    Another amusing diff I noticed:
    
    --- a/src/backend/partitioning/partbounds.c
    +++ b/src/backend/partitioning/partbounds.c
    @@ -5713,7 +5713,7 @@ check_parent_values_in_new_partitions(Relation parent,
      * 3. In case new partitions don't contain the DEFAULT partition and the
      *	  partitioned table does not have the DEFAULT partition, the following
      *	  should be true: the sum of the bounds of new partitions should be equal
    - &	  to the bound of the split partition.
    + * &	  to the bound of the split partition.
      *
      * parent:			partitioned table
      * splitPartOid:	split partition Oid
    
    Clearly, this is somebody's off-by-one-key typo, and the correct
    fix is s/&/*/.  I suspect that fixing that manually is the most
    expedient answer, rather than trying to make pg_bsd_indent smart
    enough to DTRT.
    
    One other nitpick is that the patch itself needs to be run through
    pgperltidy (which has different opinions than your editor about
    tabs vs spaces, apparently).
    
    			regards, tom lane
    
    
    
    
  28. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Nathan Bossart <nathandbossart@gmail.com> — 2026-05-04T17:11:23Z

    On Mon, May 04, 2026 at 12:40:19PM -0400, Tom Lane wrote:
    > Another amusing diff I noticed:
    > 
    > --- a/src/backend/partitioning/partbounds.c
    > +++ b/src/backend/partitioning/partbounds.c
    > @@ -5713,7 +5713,7 @@ check_parent_values_in_new_partitions(Relation parent,
    >   * 3. In case new partitions don't contain the DEFAULT partition and the
    >   *	  partitioned table does not have the DEFAULT partition, the following
    >   *	  should be true: the sum of the bounds of new partitions should be equal
    > - &	  to the bound of the split partition.
    > + * &	  to the bound of the split partition.
    >   *
    >   * parent:			partitioned table
    >   * splitPartOid:	split partition Oid
    > 
    > Clearly, this is somebody's off-by-one-key typo, and the correct
    > fix is s/&/*/.  I suspect that fixing that manually is the most
    > expedient answer, rather than trying to make pg_bsd_indent smart
    > enough to DTRT.
    
    +1.  This patch has been rather good at finding small mistakes like this,
    which I've been manually fixing along the way.
    
    -- 
    nathan
    
    
    
    
  29. Re: [PATCH] pg_bsd_indent: improve formatting of multiline comments

    Aleksander Alekseev <aleksander@tigerdata.com> — 2026-05-05T13:06:21Z

    Hi Tom,
    
    Thanks for your feedback.
    
    > In this case the problem is that the cleanup pattern only accounts for
    > one trailing space.  But a variant of this, which I think affects many
    > of the steps in the patch, is that there could be tab(s) there.  You
    > should fix the patterns to allow any number of spaces/tabs at the
    > spots where they currently expect just one space.  This might result
    > in finding cleanups they miss now.
    
    Fair point. Fixed.
    
    > Another amusing diff I noticed:
    >
    > [...]
    >
    > Clearly, this is somebody's off-by-one-key typo, and the correct
    > fix is s/&/*/.  I suspect that fixing that manually is the most
    > expedient answer, rather than trying to make pg_bsd_indent smart
    > enough to DTRT.
    
    Agree.
    
    > One other nitpick is that the patch itself needs to be run through
    > pgperltidy (which has different opinions than your editor about
    > tabs vs spaces, apparently).
    
    Fixed in v7.
    
    -- 
    Best regards,
    Aleksander Alekseev