From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: let ALTER COLUMN SET DATA TYPE cope with POLICY dependency |
Date: | 2025-09-15 02:51:53 |
Message-ID: | CACJufxGPcBzdL9T6Qh=OFecN8zqxuU0QXfYF8F3WYV=uzwYCdA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Sep 12, 2025 at 4:19 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
>
> in [1],
> RememberAllDependentForRebuilding
> /*
> * A policy can depend on a column because the column is
> * specified in the policy's USING or WITH CHECK qual
> * expressions. It might be possible to rewrite and recheck
> * the policy expression, but punt for now. It's certainly
> * easy enough to remove and recreate the policy; still, FIXME
> * someday.
> */
> After 11 year, I am trying to allow column type changes to cope with
> security policy dependencies.
>
> CREATE TABLE s (a int, b int);
> CREATE POLICY p2 ON s USING (s.b = 1);
> --master branch will result error
> ALTER TABLE s ALTER COLUMN b SET DATA TYPE INT8;
> ERROR: cannot alter type of a column used in a policy definition
> DETAIL: policy p2 on table s depends on column "b"
>
> with the attached patch, ALTER TABLE SET DATA TYPE can cope with columns that
> have associated security policy.
> The above ALTER TABLE SET DATA TYPE will just work fine.
> The code roughly follows how statistics are recreated after a column
> data type change.
v1 coding is not as aligned as with how statistics are recreated after
data changes.
For example, we have transformStatsStmt, but don't have transformPolicyStmt.
v2-0001 refactor CreatePolicy.
introduce transformPolicyStmt, very similar to transformStatsStmt,
and we don't need two ParseState (qual_pstate, with_check_pstate).
but we need one ParseState for recordDependencyOnExpr.
v2-0002 is the same as v1-0001 mostly, using transformPolicyStmt in
ATPostAlterTypeParse.
Attachment | Content-Type | Size |
---|---|---|
v2-0002-let-ALTER-COLUMN-SET-DATA-TYPE-cope-with-POLICY-dependency.patch | text/x-patch | 27.5 KB |
v2-0001-refactor-CreatePolicy.patch | text/x-patch | 10.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2025-09-15 02:55:12 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |
Previous Message | Dilip Kumar | 2025-09-15 02:46:01 | Re: Incorrect logic in XLogNeedsFlush() |