• Robert Haas's avatar
    Fix a bug in how we generate partition constraints. · 0563a3a8
    Robert Haas authored
    Move the code for doing parent attnos to child attnos mapping for Vars
    in partition constraint expressions to a separate function
    map_partition_varattnos() and call it from the appropriate places.
    Doing it in get_qual_from_partbound(), as is now, would produce wrong
    result in certain multi-level partitioning cases, because it only
    considers the current pair of parent-child relations.  In certain
    multi-level partitioning cases, attnums for the same key attribute(s)
    might differ between various levels causing the same attribute to be
    numbered differently in different instances of the Var corresponding
    to a given attribute.
    
    With this commit, in generate_partition_qual(), we first generate the
    the whole partition constraint (considering all levels of partitioning)
    and then do the mapping, so that Vars in the final expression are
    numbered according the leaf relation (to which it is supposed to apply).
    
    Amit Langote, reviewed by me.
    0563a3a8
partition.h 3.1 KB