Re: Retail DDL

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Retail DDL
Date: 2025-07-25 03:48:15
Message-ID: CAFiTN-sVtUEncxvsNBsU1az-UZ=X_oEVnb2jQnRv4Eu_+mezOA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 25, 2025 at 3:06 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > .... I have been trying to think
> > of a reasonable interface for a single function, where we would pass in,
> > say, a catalog oid plus an object oid, and maybe some optional extra
> > arguments. That seems a bit fragile, though. The alternative is that we
> > have a separate function for each object type, e.g.
> > pg_get_{objecttype}_ddl. I'm kinda leaning that way, but I'd like some
> > sort of consensus before any work gets done.
>
> I'm good with pg_get_{objecttype}_ddl. The reason I like it is that
> that sets expectations for what the function can do, and we don't
> have to immediately cover every object type there is in order to not
> have a function with unexpected restrictions.
>
> A small advantage is that, for object types having a reg* pseudotype,
> we can declare the function as (say)
>
> pg_get_table_ddl(regclass)
>
> and that means this will work with no additional decoration:
>
> select pg_get_table_ddl('mytable');
>
> Nearby, Isaac suggested sort of the reverse of that, where
> you'd have to write
>
> select pg_get_ddl('mytable'::regclass);
>
> but I don't see any great advantages in that --- and it can't scale
> to object types that lack a reg* type.

OTOH, we can have a common function and pass object type as parameter
i.e. select pg_get_ddl('table', 'mytable'), with this the same
function can be extended for different object types.

--
Regards,
Dilip Kumar
Google

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-07-25 03:53:31 Re: Retail DDL
Previous Message cca5507 2025-07-25 03:30:40 Re: Logical replication launcher did not automatically restart when got SIGKILL