Re: disallow alter individual column if partition key contains wholerow reference

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: disallow alter individual column if partition key contains wholerow reference
Date: 2025-08-25 04:07:00
Message-ID: CACJufxE_xWFJKpspCebdT17htqdTKnGDnBWiEfFHD7uqh2X7-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 25, 2025 at 11:58 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> I tested this patch with “partition by range”, it works for me.
>
> Just have a few small comments:
>
> + if (bms_is_member(0 - FirstLowInvalidHeapAttributeNumber, expr_attrs))
>
> Can we simply check “if (Var *)expr->varno == 1 && (Var *) expr->varattno == 0”, which seems more direct?
>
hi.

in has_partition_attrs, we have:
if (partattno != 0)
{
}
else
{
/* Arbitrary expression */
Node *expr = (Node *) lfirst(partexprs_item);
Bitmapset *expr_attrs = NULL;
/* Find all attributes referenced */
pull_varattnos(expr, 1, &expr_attrs);
}

see comments " /* Arbitrary expression */"
after pull_varattnos, we can not assume "expr" is a Var node?

> + /*
> + * If partition expression contains wholerow reference, then any
> + * column is indirect part of the expression now. unconditionally
> + * set used_in_expr to true.
> + */
>
> For the comment, a tiny enhancement:
>
> /*
> * If the partition expression contains a whole-row reference, then every
> * column is implicitly part of the expression. Set used_in_expr to true
> * unconditionally.
> */
>
Thanks, your comments are better than mine.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-08-25 04:36:11 RE: Conflict detection for update_deleted in logical replication
Previous Message Chao Li 2025-08-25 03:59:22 Re: Fixes a trivial bug in dumped parse/query/plan trees