Re: CREATE TABLE LIKE INCLUDING POLICIES
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-12-23T07:47:00Z
Lists: pgsql-hackers
Attachments
- v2-0002-refactoring-CreatePolicy-split-policy-qual-check-qual.patch (text/x-patch)
- v2-0001-add-RangeTblEntry-to-CreatePolicyStmt.patch (text/x-patch)
- v2-0003-CREATE-TABLE-LIKE-INCLUDING-POLICIES.patch (text/x-patch)
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