Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement - Mailing list pgsql-hackers

From Marcos Pegoraro
Subject Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement
Date
Msg-id CAB-JLwaDPJupWecAsvmNc7y7L5cQjV5P9epSFsTed1hEDbqUSA@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement  (Akshay Joshi <akshay.joshi@enterprisedb.com>)
List pgsql-hackers
Em sex., 7 de nov. de 2025 às 11:27, Akshay Joshi <akshay.joshi@enterprisedb.com> escreveu:
I don’t 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 = 'customer_050' and relkind = '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

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Xlogprefetcher: Use atomic add for increment counter
Next
From: vignesh C
Date:
Subject: Re: Logical Replication of sequences