Thread
-
Re: disallow alter individual column if partition key contains wholerow reference
jian he <jian.universality@gmail.com> — 2025-12-31T02:57:14Z
On Tue, Oct 28, 2025 at 11:24 PM Kirill Reshke <reshkekirill@gmail.com> wrote: > > I can see that 0 - FirstLowInvalidHeapAttributeNumber is an existing > coding practise in sources, but so is > InvalidAttrNumber - FirstLowInvalidHeapAttributeNumber (sepgsql > contrib extension). I'm voting for the second one, even though it is > less used. > hi. now it's: + /* + * If the partition expression contains a whole-row reference, + * then all columns are indirectly associated with that + * expression. + */ + if (bms_is_member(InvalidAttrNumber - FirstLowInvalidHeapAttributeNumber, + expr_attrs)) + { + if (used_in_expr) + *used_in_expr = true; + return true; + } also polished the commit message. below is the commit message: -------------------------- For partition key expressions containing whole-row reference, we cannot rely on pg_depend lookups to determine whether an individual column can be altered (drop, set data type). As noted in the comments for find_expr_references_walker, no dependency entries are recorded for whole-row expressions. Therefore whole-row reference check is needed in has_partition_attrs. Partition key expressions contain whole-row reference, it is effectively equivalent to all user columns being indirectly associated with that expression. Since columns that in a partition key cannot be altered in any way, the same restriction should be applied to whole-row reference expressions in the partition key. -------------------------- -- jian https://www.enterprisedb.com/