postgres.git / summary / log / commit / refs

commit    c35e5dd9ae972393338b81a2427ab4e587f18534
Author:   David Rowley <drowley@postgresql.org>
Date:     Thu Jan 08 22:02:59 2026 +0000
First released in: 14.21, 15.16, 16.12, 17.8, 18.2

    Fix possible incorrect column reference in ERROR message
    
    When creating a partition for a RANGE partitioned table, the reporting
    of errors relating to converting the specified range values into
    constant values for the partition key's type could display the name of a
    previous partition key column when an earlier range was specified as
    MINVALUE or MAXVALUE.
    
    This was caused by the code not correctly incrementing the index that
    tracks which partition key the foreach loop was working on after
    processing MINVALUE/MAXVALUE ranges.
    
    Fix by using foreach_current_index() to ensure the index variable is
    always set to the List element being worked on.
    
    Author: myzhen <zhenmingyang@yeah.net>
    Reviewed-by: zhibin wang <killerwzb@gmail.com>
    Discussion: https://postgr.es/m/273cab52.978.19b96fc75e7.Coremail.zhenmingyang@yeah.net
    Backpatch-through: 14


src/backend/parser/parse_utilcmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index e96b38a59d5..1d6864f9521 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -4439,12 +4439,14 @@ transformPartitionRangeBounds(ParseState *pstate, List *blist, int i, j; - i = j = 0; + j = 0; foreach(lc, blist) { Node *expr = lfirst(lc); PartitionRangeDatum *prd = NULL; + i = foreach_current_index(lc); + /* * Infinite range bounds -- "minvalue" and "maxvalue" -- get passed in * as ColumnRefs. @@ -4522,7 +4524,6 @@ transformPartitionRangeBounds(ParseState *pstate, List *blist, prd = makeNode(PartitionRangeDatum); prd->kind = PARTITION_RANGE_DATUM_VALUE; prd->value = (Node *) value; - ++i; } prd->location = exprLocation(expr); [parent: 6c99c715ddb3]