postgres.git / summary / log / commit / refs

commit    559ec79e320e51a1a6ab24af1ff4a07fbb4de19f
Author:   David Rowley <drowley@postgresql.org>
Date:     Wed Jul 13 05:01:39 2022 +0000
First released in: 16.0, 15.0

    Small cleanup of create_list_bounds()
    
    When checking for interleaved partitions, we mark the partition as
    interleaved when;
    
    1. we find an earlier partition index when looping over the
    sorted-by-Datum indexes[] array, or;
    
    2. we find that the NULL partition allows some non-NULL Datum value.
    
    In the code, as it was written in db632fbca we'll continue to check for
    case 2 when we've already marked the partition as interleaved for case 1.
    Here we make it so we don't bother marking the partition as interleaved
    for case 2 when it's already been marked due to case 1.
    
    Really all this saves is a useless call to bms_add_member(), but since
    this code is new to PG15, it seems worth fixing it now to save anyone the
    trouble of complaining at some time in the future.  We have the
    opportunity to improve this now before PG15 is out.  This might ease some
    future back-patching pain.
    
    Per report and patch by Zhihong Yu.  However, I slightly revised the
    comments and altered the bms_add_member() code to match in both locations.
    We already know that index is equal to boundinfo->null_index from the if
    condition.
    
    Author: Zhihong Yu
    Discussion: https://postgr.es/m/CALNJ-vQbZR0pYxz9zQ5bqXVcwtGgNgVupeEpNT65HZ+yWZnc4g@mail.gmail.com
    Backpatch-through: 15, same as db632fbca.


src/backend/partitioning/partbounds.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/backend/partitioning/partbounds.c b/src/backend/partitioning/partbounds.c index 6b35111ebb6..091d6e886b6 100644 --- a/src/backend/partitioning/partbounds.c +++ b/src/backend/partitioning/partbounds.c @@ -648,13 +648,14 @@ create_list_bounds(PartitionBoundSpec **boundspecs, int nparts, index); /* - * Mark the NULL partition as interleaved if we find that it - * allows some other non-NULL Datum. + * Otherwise, if the null_index exists in the indexes array, + * then the NULL partition must also allow some other Datum, + * therefore it's "interleaved". */ - if (partition_bound_accepts_nulls(boundinfo) && - index == boundinfo->null_index) + else if (partition_bound_accepts_nulls(boundinfo) && + index == boundinfo->null_index) boundinfo->interleaved_parts = bms_add_member(boundinfo->interleaved_parts, - boundinfo->null_index); + index); last_index = index; } [parent: 44b5d5625389]