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 1vHNln-005Xyp-CV for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Nov 2025 14:48:55 +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 1vHNlm-00EhOo-2B for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Nov 2025 14:48:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vHNlC-00Ee1E-GL for pgsql-hackers@lists.postgresql.org; Fri, 07 Nov 2025 14:48:18 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vHNlA-005uzp-1D for pgsql-hackers@postgresql.org; Fri, 07 Nov 2025 14:48:17 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b3e7cc84b82so158866966b.0 for ; Fri, 07 Nov 2025 06:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=f10-com-br.20230601.gappssmtp.com; s=20230601; t=1762526893; x=1763131693; 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=022xVCL9uz2c9MMaQbF6V4+inWh6IWoZoMPZZz4npJw=; b=UNXfA4HJ/ARqFczx4J1MysfftVJ3JdMbaYG/dY7aapzYvXBeDxTZlL3exrSnTFgwkj w1jguoGk2vsqBC3mzvuES6uBj4En5sUNcj91PN+n2f90EF99zYIstcpTkptDGsJTBXSY 6mRdAnLIaZuS8E+rwwD25M/gVWHkwG/W8vyLuOLrnBYb5/nkWOvoxREb3QCq7Cvidy2V F13bpLs4BpT+4cItCsV/QWTc+FMSS0OipUYu3xU8erqigIhTNRV/ADyFpSowZNC7G/Jv UPpgdx2KZSK3qkiOGBXOaIODqF5rLsxQ6vEG1Sj7MPsl8tOPG8TQ6eB7X2nZUdF43I+q CasA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762526893; x=1763131693; 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=022xVCL9uz2c9MMaQbF6V4+inWh6IWoZoMPZZz4npJw=; b=n6mySraZb6VppNMpkZmY910nmmmST50TGkWH3uZcsOVnVmKHBX/5cUemfUz2SjCWUd JzNYKp3d8xASvw3E7ZBoczXR/d5nDKpaANv4m8NLHGIUcUD8WwUQpxEx1Y7CmZqxt83W Nawz4X3yrKzeMPb7EbZiujrD+EJpuDBBlGOpdWRtNuBzS9cu9bXdvy8PMhu5AzrnrX2C ZeEdCw5lYy8lpS5R0WHGl9V1FEVPrbx5yJ1KG0PJRV0s71S0Io8s0SY5+d+hQswx1XTd y1Y/gaxZO5kgS/r5W4sddqahpKjVIseSB8N/C2I5z9spCLcLo1/XEhOYN1jW9eiFgbgs IA3g== X-Forwarded-Encrypted: i=1; AJvYcCUDxbTerAO5X/PZ5H0HMkKWaQ0KNEO4JZCMxr3JSfqLZP41yvaWUcvkhD4Qy8CRe8uTTnlnJZqXOT8cDF0n@postgresql.org X-Gm-Message-State: AOJu0YwmeLek4qSUaQ23p7SaFp0ULdat4cIRjOKEwKE5ZYnbxkuc2GKP QZIjv7uasmw0jKcjHQcPAQFOrEPB4FUxQ2nf+TXgek+sVGM2no69kwiBvl6vUPx44L96+QCJy+G hPFH5LqwbhtVkaPxIfZtb/PT1zNu/g67ukXs/M10z X-Gm-Gg: ASbGncsHal4TKhiGEoog4MCdmTNG3uOkCgFxXHqGyfMR1tY7aBQUc9ADXwLoCvI5gbt 7Q4trBJ0oRV/xWXdQ0wkDRrykZ36hPd8lmf1gIa3o182VuM9DJHwzFzYT0UXPH45knQLyL6ohz8 dE5N6TP0gHcUYnyvlMe/irgzSu7oJujvYspAkKo2fEdBexLHiUPdFQV5CA1+S8+NtByVcyZCT6+ bUte79wZdk+CrkS1zOLv2QV2TvSMXK4Gpdo949v5xTp0WX55smhcM5cdop/HOpqGX6xGkN0HA== X-Google-Smtp-Source: AGHT+IF6fh5xqgtXwBzO+r3UccLL+QRleXT/EOsXU9P7CdsCszac6MXKhk5O9KnbG6aHANqK2pmELb0LZexer/Gb7/4= X-Received: by 2002:a17:907:c0d:b0:b70:ac7a:2a8b with SMTP id a640c23a62f3a-b72c0928d62mr315371066b.19.1762526893436; Fri, 07 Nov 2025 06:48:13 -0800 (PST) MIME-Version: 1.0 References: <202510151529.s3fpwsgben57@alvherre.pgsql> In-Reply-To: From: Marcos Pegoraro Date: Fri, 7 Nov 2025 11:47:36 -0300 X-Gm-Features: AWmQ_bnI5OxE4IuwAoYR0RVW3C7qkIqmltJaWiLqxAcyPk6jBPAPbisg1ZFfUlg Message-ID: Subject: Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement To: Akshay Joshi Cc: Mark Wong , =?UTF-8?Q?=C3=81lvaro_Herrera?= , pgsql-hackers Content-Type: multipart/alternative; boundary="0000000000006403820643024561" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006403820643024561 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_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_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 --0000000000006403820643024561 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Em sex., 7 de nov. de 2025 =C3=A0s 1= 1:27, Akshay Joshi <aks= hay.joshi@enterprisedb.com> escreveu:
I don=E2=80=99t think we need that s= tatement. Could you please elaborate on where exactly it needs to be added?=

well, these pg_g= et_..._ddl() functions will be cool for compare/clone schemas in a multi te= nant 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_050'= ; and relkind =3D 'r' union all
select pg_ge= t_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 ...=C2=A0where ... union all
...

And pg_get_p= olicy_ddl() will be part of these union all selects
=
Because that would be good to worry about creat= e that only if it does not exists or drop first too.

regards
Marcos
--0000000000006403820643024561--