Re: disallow alter individual column if partition key contains wholerow reference - Mailing list pgsql-hackers

From jian he
Subject Re: disallow alter individual column if partition key contains wholerow reference
Date
Msg-id CACJufxG3ffzbD65J1p2xGH5P=TmW7hH6BAyuNB65tRVN_Xk03w@mail.gmail.com
Whole thread Raw
In response to Re: disallow alter individual column if partition key contains wholerow reference  (Kirill Reshke <reshkekirill@gmail.com>)
List pgsql-hackers
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/

Attachment

pgsql-hackers by date:

Previous
From: "zengman"
Date:
Subject: Re: Speed up ICU case conversion by using ucasemap_utf8To*()
Next
From: Chao Li
Date:
Subject: Re: Fix comments on _bt_skiparray_strat_increment/decrement