Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vIKGy-004B8g-Td for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 05:17:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vIKGu-00E9Vf-V0 for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 05:16:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vIKGu-00E9VT-Ib for pgsql-hackers@lists.postgresql.org; Mon, 10 Nov 2025 05:16:56 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vIKGr-006vKv-1n for pgsql-hackers@postgresql.org; Mon, 10 Nov 2025 05:16:55 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5930f751531so2362992e87.3 for ; Sun, 09 Nov 2025 21:16:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1762751812; x=1763356612; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=X5pMS+KSMRVufkPl2insH/1GdeR5c17b1Yuuomix4oI=; b=Wg6ntFP9hQtr7atJYRvIEvKCDThBfQ8I60Hni2jEcVrZrlfzKwy+eSPD3PUxnpmX8K ahd7ED0ZXz7tYe/+vPGWxdS468Kj2GHz7vcBUsKcgbrFjKSKlVbAKiVtvTo9L+Lwjxm8 XI37w+TQ5/FojpHDAvMM1GRF/xLl7eY5JyM0HEGYkiLsqa4sHAilx5ut4gUvkqo3GVsX FmqVFGfjVmS+iV9VRPxpLD4v4U20XAgPVJcbEIJegwv1pBB65zINaycDz6q8o/LQ6co5 Im1BHwrf7QSSrCCa3Ly67FJsg6YKd0CAXopMmst64N17Vs/Ma3NZhKWtSW49tmymoHnX 73uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762751812; x=1763356612; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X5pMS+KSMRVufkPl2insH/1GdeR5c17b1Yuuomix4oI=; b=hP/RuKoHRISwcwWTz92tlJZ/+H0Gsemf4i+qq124DE+c9deke+JJ5gUVZk61TsNc5B dvE5dLrVsm12GzHOrgPcHNSfEaGancJHbvkXzfHrKjSJ7/SSod+13tVPmLRSpXoD++Fc NdsFETFwzNhwlKv768XN0Jst+AWmzJf+2NAKHP3kkb00WTjNcIDZfGSURmPucaQYFglt biqnHiTnMja0Gf1N3B7M2AWZ5TVfvzcdr608AbgKaYuWsYIIeN56Y0nxhKSBL+Ewcaf9 OXtl9LY9ZFJZ8B/Xa2iXNQsuqnjhNMCMPYJw0Clt2p02xOmBB05gZitkxMs8/wm612yj RGzQ== X-Forwarded-Encrypted: i=1; AJvYcCUQ8nCFeigm3HiHIVLuwdJVZe87bH33MNobjmpSapfgUGLhYdRCbYmx+AwjfTyrp0YNPRteuzU77xlJm24T@postgresql.org X-Gm-Message-State: AOJu0Ywb6z3k7VyESzx+oV2yzuwotvMA/3XiwY34cCYgoiVsOXDKipnr 9ugtZN2yVQITormjFXoMi5/UuyEgPN0kq+3QyvovNQvfYC4XECkHqELwkegMzfGYDAxuGzMTzIq kjiG7Ya4hXYeBpw3fskBCjs3aF0MAOo9YyvW1zjNS X-Gm-Gg: ASbGncvYroFxiu3ga59YM/4ozmPzG0K1aVEDpYhu/XuOC/CpErUhkQy91/1Odu6TQkg OHbc2nA5snDfatPM7UZxNTdUoIEKpnVxAnaVUOBqmRDAKJN9bPGt0usx9/k/xUDukm34OiGDVvC lekvy1o7W82w4FmIeWFfVRcIypnBwVHb24yiRnCEqhahkH5xHuNDdiUB3GBmSspB3iEkw176pMT 5jP/VFPw4sXjxHfn2wR8HvUKrq+S/bK+MXgn5dQ1irOMjd8fd3ZN5EJRKr89A== X-Google-Smtp-Source: AGHT+IG/P9FYwqdGkbk+7K2h3WM6h5bNJfgoI9itU/+ZrrwpYCOv/GREF7kjM/Efg253ZJJeZMm+Cg+dZA+Glmlzldk= X-Received: by 2002:a05:6512:3d03:b0:583:903e:b5a4 with SMTP id 2adb3069b0e04-5945f1b78e7mr2104510e87.46.1762751811826; Sun, 09 Nov 2025 21:16:51 -0800 (PST) MIME-Version: 1.0 References: <202510151529.s3fpwsgben57@alvherre.pgsql> In-Reply-To: From: Akshay Joshi Date: Mon, 10 Nov 2025 10:46:40 +0530 X-Gm-Features: AWmQ_bmo5NBHeyjEnjLsr0Mjmvirf5WbdPk8vLLpqSeoUJYN4CARNLOIChaijmo Message-ID: Subject: Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement To: Marcos Pegoraro Cc: Mark Wong , =?UTF-8?Q?=C3=81lvaro_Herrera?= , pgsql-hackers Content-Type: multipart/alternative; boundary="0000000000009248a1064336a39b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009248a1064336a39b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the clarification. However, I still believe this is out of scope for the CREATE POLICY DDL. The command ALTER TABLE ... ENABLE ROW LEVEL SECURITY seems more appropriate as part of the CREATE TABLE reconstruction rather than CREATE POLICY. That said, I=E2=80=99m open to adding it if the majority feels it should be included in this feature. On Fri, Nov 7, 2025 at 8:18=E2=80=AFPM Marcos Pegoraro = wrote: > Em sex., 7 de nov. de 2025 =C3=A0s 11:27, Akshay Joshi < > akshay.joshi@enterprisedb.com> escreveu: > >> I don=E2=80=99t think we need that statement. Could you please elaborate= on where >> exactly it needs to be added? >> > > well, these pg_get_..._ddl() functions will be cool for compare/clone > schemas in a multi tenant world. > Instead of dump/sed/restore a schema to create a new one, I could use > something like > select pg_get_table_ddl(oid) from pg_class where nspname =3D 'customer_05= 0' > and relkind =3D 'r' union all > select pg_get_constraint_ddl(oid) from pg_constraint inner join pg_class > on ... where ... union all > select pg_get_trigger_ddl(oid) from pg_trigger inner join pg_class on > ... where ... union all > ... > > And pg_get_policy_ddl() will be part of these union all selects > > Because that would be good to worry about create that only if it does not > exists or drop first too. > > regards > Marcos > --0000000000009248a1064336a39b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Thanks for the clarification. However, I still believe = this is out of scope for the CREATE POLICY DDL. The command ALTER TABLE ...=C2=A0ENABLE ROW LEVEL SECURITY=C2=A0seems more= appropriate as part of the CREATE TABLE reconstruction rather= than CREATE POLICY.

That said, I=E2=80=99m open to adding it if the majority feels it should= be included in this feature.


On Fri, Nov 7, 2025 = at 8:18=E2=80=AFPM Marcos Pegoraro <marcos@f10.com.br> wrote:
Em sex., 7 de nov.= de 2025 =C3=A0s 11:27, Akshay Joshi <akshay.joshi@enterprisedb.com> escr= eveu:
I don=E2=80=99t think = we need that statement. Could you please elaborate on where exactly it need= s to be added?

wel= l, these pg_get_..._ddl() functions will be cool for compare/clone schemas = in a multi tenant world.
Instead of dump/sed/restore= a schema to create a new one, I could use something like
select pg_get_table_ddl(oid) from pg_class where nspname =3D 'c= ustomer_050' and relkind =3D 'r' union all
select pg_get_constraint_ddl(oid) from pg_constraint inner join pg_class= on ... where ... union all
select pg_get_trigger_dd= l(oid) from pg_trigger inner join pg_class on ...=C2=A0where ... union all<= /div>
...

And pg_get_policy_ddl() will be part of these union all selects

Because that would be good to wo= rry about create that only if it does not exists or drop first too.

regards
= Marcos
--0000000000009248a1064336a39b--