Re: Adding SHOW CREATE TABLE

From: Kirk Wolak <wolakk(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Nathaniel Sabanski <sabanski(dot)n(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Adding SHOW CREATE TABLE
Date: 2023-05-13 07:59:35
Message-ID: CACLU5mTytXMbNcqtsQXzDB7Du2r37BuYw9XDF4UE8MCQn=dFew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, May 12, 2023 at 8:37 PM Stephen Frost <sfrost(at)snowman(dot)net> wrote:

> Greetings,
> ..
> I mean ... it's already in postgres_fdw, just not in a way that can be
> returned to the user. I don't think I'd want this functionality to
> depend on postgres_fdw or generally on an extension though, it should
> be part of core in some fashion.
>

I will start with postgres_fdw then, but gladly review the other source...
Just thinking about the essence of the syntax.
SHOW CREATE TABLE abc(LIKE real_table); -- Output CREATE TABLE abc();
using real_table?

I'd look at the IMPORT FOREIGN SCHEMA stuff in postgres_fdw. We're
> already largely answering these questions by what options that takes.
>

Will do.

> > But it's a big commitment. I don't mind if it has a reasonable chance of
> > being accepted.
>

> Yes, it's a large effort, no doubt.
>

At least there is a base of code to start with.
I see a strong need to come up with a shell script to that could:

FOR <every schema.table> DO
psql -c "SHOW... \g | cat > <schema.table.DDL> "
pg_dump -- <schema.table> only | remove_comments_normalize | cat
<schema.table.pg_dump>
DIFF <schema.table.DDL> <schema.table.pg_dump>

Of course, since our tests are usually all perl, a perl version.
But I would clearly want some heavy testing/validation.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kirk Wolak 2023-05-13 08:58:26 Re: Window function for get the last value to extend missing rows
Previous Message FOUTE K. Jaurès 2023-05-13 07:54:22 Re: PG_Cron - Error Message Connection failed

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2023-05-13 08:20:20 Re: Should CSV parsing be stricter about mid-field quotes?
Previous Message Kirk Wolak 2023-05-13 07:25:11 Re: Adding SHOW CREATE TABLE