Search Postgresql Archives

Re: Adding SHOW CREATE TABLE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 12, 2023 at 4:37 PM Stephen Frost <sfrost@xxxxxxxxxxx> wrote:
Greetings,

* Tom Lane (tgl@xxxxxxxxxxxxx) wrote:
> Stephen Frost <sfrost@xxxxxxxxxxx> writes:
> > Again, would be great to see someone actually work on this.  There's
> > already a good chunk of code in core in pg_dump and in the postgres_fdw
> > for doing exactly this and it'd be great to consolidate that and at the
> > same time expose it via SQL.
...
No, it won't make sense to have yet another copy that's for the
currently-running-server-only, which is why I suggested it go into
either a common library or maybe into libpq.  I don't feel it would
be bad for the common code to have the multi-version understanding even
if the currently running backend will only ever have the option to ask
for the code path that matches its version.

Hmmm...    What's wrong with only being for the currently running server?
That's all I would expect.  Also, if it was there, it limits the expectations to DDL that
works for that server version.

Also, if it's on the backend (or an extension), then it's available to everything.


Agreed- someone needs to have a fair bit of time and willingness to push
on this to make it happen.

If we can work through a CLEAR discussion of what it is, and is not.  I would be
happy to work on this.  I like referencing the FDW.  I also thought of referencing
the CREATE TABLE xyz(LIKE abc INCLUDING ALL).  While it's not doing DDL,
it certainly has to be checking options, etc.  And pg_dump is the "gold standard".

My approach would be to get a version working.  Then figure out how to
generate "literally" all table options, and work the process.  The good news
is that at a certain point the resulting DDL should be "comparable" against a
ton of test tables.

Where do we draw the lines?  Does Table DDL include all indexes?
It should include constraints, clearly.  I would not think it should have triggers.
Literally everything within the <<CREATE TABLE X(...);>>.  (ie, no ALTER .. OWNER TO...)

Next, I would want psql \st to simply call this?

FWIW, we parse our pg_dump output, and store the objects as individual DDL files.
So, I have about 1,000 tables to play with, for which I already know the DDL that pg_dump uses.

But it's a big commitment.  I don't mind if it has a reasonable chance of being accepted.
I accept that I will make a few mistakes (and learn) along the way.
If there are ANY deal killers that would prevent a reasonable solution from being accepted,
please let me know.

Kirk...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux