Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement

From: Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
To: Mark Wong <markwkm(at)gmail(dot)com>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement
Date: 2025-11-07 12:20:52
Message-ID: CANxoLDfw=ERY89RR08s+qXwgUQvLCFF0pVG_e0fDT14rwZsWRg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

Make the pretty flag a default parameter by adding CREATE OR REPLACE
FUNCTION in system_functions.sql.
Attached is the v7 patch, which is ready for review.

On Mon, Nov 3, 2025 at 5:17 PM Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
wrote:

> Hi Hackers,
>
> Added a new #define GET_DDL_PRETTY_FLAGS because the existing #define
> GET_PRETTY_FLAGS is not suitable for formatting reconstructed DDLs. The
> existing #define GET_PRETTY_FLAGS always indents the code, regardless of
> whether the flag is set to true or false, which is not the desired
> behavior for pg_get_<object>_ddl functions.
>
> Updated the logic of the get_formatted_string function based on Tim
> Waizenegger’s suggestion.
>
> I am attaching the new v6 patch, which is ready for review.
>
> On Tue, Oct 28, 2025 at 3:08 PM Akshay Joshi <
> akshay(dot)joshi(at)enterprisedb(dot)com> wrote:
>
>> Thanks, Mark, for your review comments and the updated patch.
>>
>> I’ve incorporated your changes and prepared a combined v5 patch. The v5
>> patch is attached for further review.
>>
>> On Mon, Oct 27, 2025 at 10:15 PM Mark Wong <markwkm(at)gmail(dot)com> wrote:
>>
>>> Hi everyone,
>>>
>>> On Thu, Oct 16, 2025 at 01:47:53PM +0530, Akshay Joshi wrote:
>>> >
>>> >
>>> > On Wed, Oct 15, 2025 at 10:55 PM Álvaro Herrera <alvherre(at)kurilemu(dot)de>
>>> wrote:
>>> >
>>> > Hello,
>>> >
>>> > I have reviewed this patch before and provided a number of
>>> comments that
>>> > have been addressed by Akshay (so I encourage you to list my name
>>> and
>>> > this address in a Reviewed-by trailer line in the commit
>>> message). One
>>> > thing I had not noticed is that while this function has a "pretty"
>>> flag,
>>> > it doesn't use it to pass anything to pg_get_expr_worker()'s
>>> prettyFlags
>>> > argument, and I think it should -- probably just
>>> >
>>> > prettyFlags = GET_PRETTY_FLAGS(pretty);
>>> >
>>> > same as pg_get_querydef() does.
>>>
>>> Kinda sorta similar thought, I've noticed some existing functions like
>>> pg_get_constraintdef make the "pretty" flag optional, so I'm wondering
>>> if that scheme is also preferred here.
>>>
>>> I've attached a small diff to the original
>>> 0001-Add-pg_get_policy_ddl-function-to-reconstruct-CREATE.patch to
>>> illustrate the additional work to follow suit, if so desired.
>>>
>>> Regards,
>>> Mark
>>> --
>>> Mark Wong <markwkm(at)gmail(dot)com>
>>> EDB https://enterprisedb.com
>>>
>>

Attachment Content-Type Size
v7-0001-Add-pg_get_policy_ddl-function-to-reconstruct-CREATE.patch application/octet-stream 25.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marcos Pegoraro 2025-11-07 13:14:20 Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement
Previous Message Álvaro Herrera 2025-11-07 12:11:44 Re: [PATCH] Add pg_get_subscription_ddl() function