Re: Fix incorrect comments in tuplesort.c

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: cca5507 <cca5507(at)qq(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix incorrect comments in tuplesort.c
Date: 2025-12-07 23:10:00
Message-ID: CAKFQuwaEXRcvDn7S3o5hEnB9Yt5jgecbfyGY+gLohAcV2p=Pzg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 7, 2025 at 3:09 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:

> The comment is effectively
> explaining that we don't want to make the array big enough so that a
> malloc will always be required.

Doesn't what you are saying contradict both the formula (the +1
post-division) and the comments:

/*
* Initial size of array must be more than ALLOCSET_SEPARATE_THRESHOLD;
* see comments in grow_memtuples().
*/
state->memtupsize = INITIAL_MEMTUPSIZE;
state->memtuples = NULL;

and in grow_memtuples:

* That shouldn't happen because we chose the
* initial array size large enough to ensure that palloc will be treating
* both old and new arrays as separate chunks.

?

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-12-07 23:29:12 Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
Previous Message Peter Geoghegan 2025-12-07 22:30:54 Re: Moving _bt_readpage and _bt_checkkeys into a new .c file