Re: Retail DDL

Поиск
Список
Период
Сортировка
От Dilip Kumar
Тема Re: Retail DDL
Дата
Msg-id CAFiTN-sVtUEncxvsNBsU1az-UZ=X_oEVnb2jQnRv4Eu_+mezOA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Retail DDL  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Retail DDL
Список pgsql-hackers
On Fri, Jul 25, 2025 at 3:06 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Andrew Dunstan <andrew@dunslane.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



В списке pgsql-hackers по дате отправления: