Re: Retail DDL

2025-07-25 Thread Zhang Mingli
Hi, On Jul 25, 2025 at 21:35 +0800, Tom Lane , wrote: > =?utf-8?Q?=C3=81lvaro?= Herrera writes: > > Reproducing a table might need multiple commands. Do you intend to > > return a single string containing multiple semicolon-separated commands, > > or are you thinking in a RETURNS SETOF where eac

Re: Retail DDL

2025-07-25 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > Reproducing a table might need multiple commands. Do you intend to > return a single string containing multiple semicolon-separated commands, > or are you thinking in a RETURNS SETOF where each row contains a single > command? In the same vein: would we

Re: Retail DDL

2025-07-25 Thread Andrew Dunstan
On 2025-07-25 Fr 4:34 AM, Álvaro Herrera wrote: On 2025-Jul-24, Andrew Dunstan wrote: Obviously we already have some functions for things like views and triggers, but most notably we don't have one for tables, something users have long complained about. I have been trying to think of a reason

Re: Retail DDL

2025-07-25 Thread Hannu Krosing
A related improvement would be to also support CREATE EXTENSION psql; To make at least the `\d ...` commands available to any client And while we are at it, why not also CREATE EXTENSION pgbench; To make the fancy random distribution functions (at least) from pgbench available from inside the

Re: Retail DDL

2025-07-25 Thread Hannu Krosing
I have been thinking of this from a little different direction. We already have all the needed functionality in pg_dump so why not just have an option to do CREATE EXTENSION pg_dump; Which would wrap and expose whatever the current version of pg_dump is doing. It still would need to resolve the

Re: Retail DDL

2025-07-25 Thread Álvaro Herrera
On 2025-Jul-24, Andrew Dunstan wrote: > Obviously we already have some functions for things like views and > triggers, but most notably we don't have one for tables, something users > have long complained about. I have been trying to think of a reasonable > interface for a single function, where w

Re: Retail DDL

2025-07-24 Thread Ashutosh Bapat
Hi Andrew, On Fri, Jul 25, 2025 at 1:56 AM Andrew Dunstan wrote: > > Some years ago I gave a talk about $subject, but somehow it dropped off > my radar. Now I'm looking at it again. The idea is to have a function > (or set of functions) that would allow the user to get the DDL for any > database

Re: Retail DDL

2025-07-24 Thread Dilip Kumar
On Fri, Jul 25, 2025 at 9:23 AM Tom Lane wrote: > > Dilip Kumar writes: > > 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. > > And you'll work regclas

Re: Retail DDL

2025-07-24 Thread Tom Lane
Dilip Kumar writes: > 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. And you'll work regclass/regtype/etc into that how? AFAICS the only way would involv

Re: Retail DDL

2025-07-24 Thread Dilip Kumar
On Fri, Jul 25, 2025 at 3:06 AM Tom Lane wrote: > > Andrew Dunstan 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 fra

Re: Retail DDL

2025-07-24 Thread Tom Lane
Andrew Dunstan 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 separat

Re: Retail DDL

2025-07-24 Thread Thom Brown
On Thu, 24 Jul 2025 at 21:46, Matheus Alcantara wrote: > > On Thu Jul 24, 2025 at 5:26 PM -03, Andrew Dunstan wrote: > > Some years ago I gave a talk about $subject, but somehow it dropped off > > my radar. Now I'm looking at it again. The idea is to have a function > > (or set of functions) that

Re: Retail DDL

2025-07-24 Thread Matheus Alcantara
On Thu Jul 24, 2025 at 5:26 PM -03, Andrew Dunstan wrote: > Some years ago I gave a talk about $subject, but somehow it dropped off > my radar. Now I'm looking at it again. The idea is to have a function > (or set of functions) that would allow the user to get the DDL for any > database object.

Re: Retail DDL

2025-07-24 Thread Isaac Morland
On Thu, 24 Jul 2025 at 16:26, Andrew Dunstan wrote: > Some years ago I gave a talk about $subject, but somehow it dropped off > my radar. Now I'm looking at it again. The idea is to have a function > (or set of functions) that would allow the user to get the DDL for any > database object. Obvious

Retail DDL

2025-07-24 Thread Andrew Dunstan
Some years ago I gave a talk about $subject, but somehow it dropped off my radar. Now I'm looking at it again. The idea is to have a function (or set of functions) that would allow the user to get the DDL for any database object. Obviously we already have some functions for things like views an