Re: CREATE TABLE LIKE INCLUDING POLICIES

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CREATE TABLE LIKE INCLUDING POLICIES
Date: 2025-12-23 07:47:00
Message-ID: CACJufxGg9cEs1P7p8Ak2oQ0F9AZQbHtdTcUzUpvsHZ9THeZOQw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

to avoid repeated name lookup issue, I added a RangeTblEntry field to
CreatePolicyStmt.
see v2-0001-add-RangeTblEntry-to-CreatePolicyStmt.patch commit message too.

v2-0001, v2-0002 will be used in thread [1] too.
Please also check polished v2-0003.

The main logic is for each source table POLICY, using pg_policy catalog
information, produces a CreatePolicyStmt node. The source relation is already
locked in AccessShareLock, but POLICY qual, with check qual may reference other
unrelated relations, we also need to lock them in AccessShareLock too.

[1]: https://postgr.es/m/CACJufxE42vysVEDEmaoBGmGYLZTCgUAwh_h-c9dcSLDtD5jE3g@mail.gmail.com

--
jian
https://www.enterprisedb.com

Attachment Content-Type Size
v2-0002-refactoring-CreatePolicy-split-policy-qual-check-qual.patch text/x-patch 10.8 KB
v2-0001-add-RangeTblEntry-to-CreatePolicyStmt.patch text/x-patch 3.9 KB
v2-0003-CREATE-TABLE-LIKE-INCLUDING-POLICIES.patch text/x-patch 35.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2025-12-23 08:13:06 Re: Allow GUC settings in CREATE SUBSCRIPTION CONNECTION to take effect
Previous Message zengman 2025-12-23 07:46:11 Re: Sequence Access Methods, round two