| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | CREATE TABLE LIKE INCLUDING PRIVILEGES |
| Date: | 2026-06-03 07:32:00 |
| Message-ID: | CACJufxGWuBzcF+t0K0Urs6A=ThdFr3pWMw+EANjKNoB=hBw5Rw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Inspired by this message [1], introduce CREATE TABLE LIKE INCLUDING PRIVILEGES.
With this, the source table ACL stored in pg_class.relacl and
pg_attribute.attacl will now be copied to the target table.
This functionality only works if the current user is also the owner of
the source table.
Demo:
CREATE ROLE alice;
CREATE ROLE bob;
SET ROLE alice;
CREATE TABLE src (a int, b int);
GRANT INSERT ON src TO bob WITH GRANT OPTION;
CREATE TABLE dst (LIKE src INCLUDING PRIVILEGES);
SELECT relacl FROM pg_class WHERE relname = 'dst';
relacl
-------------------------------------
{alice=arwdDxtm/alice,bob=a*/alice}
[1]: https://www.postgresql.org/message-id/546590.1771005826%40sss.pgh.pa.us
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-CREATE-TABLE-LIKE-INCLUDING-PRIVILEGES.patch | text/x-patch | 25.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Michael Paquier | 2026-06-03 07:27:18 | Re: [PATCH] doc: Document that invalid indexes are skipped during ATTACH PARTITION |