Re: Adding SHOW CREATE TABLE

From: Jelte Fennema <postgres(at)jeltef(dot)nl>
To: Kirk Wolak <wolakk(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Adding SHOW CREATE TABLE
Date: 2023-06-05 11:43:42
Message-ID: CAGECzQRuHBs9gjPbvgabQv8XS3QRU9Ex=nH84S_1=wo4POzBzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Thu, 1 Jun 2023 at 18:57, Kirk Wolak <wolakk(at)gmail(dot)com> wrote:
> Can this get turned into a Patch? Were you offering this code up for others (me?) to pull, and work into a patch?
> [If I do the patch, I am not sure it gives you the value of reducing what CITUS has to maintain. But it dawns on
> me that you might be pushing a much bigger patch... But I would take that, as I think there is other value in there]

Attached is a patch which adds the relevant functions from Citus to
Postgres (it compiles without warnings on my machine). I checked with
a few others on the Citus team at Microsoft and everyone thought that
upstreaming this was a good idea, because it's quite a bit of work to
update with every postgres release.

To set expectations though, I don't really have time to work on this
patch. So if you can take it over from here that would be great.

The patch only contains the C functions which generate SQL based on
some oids. The wrappers such as the master_get_table_ddl_events
function were too hard for me to pull out of Citus code, because they
integrated a lot with other pieces. But the bulk of the logic is in
the functions in this patch. Essentially all that
master_get_table_ddl_events does is call the functions in this patch
in the right order.

> The ONLY thing I did not see was "CREATE TEMPORARY " syntax? If you did this on a TEMP table,
> does it generate normal table syntax or TEMPORARY TABLE syntax???

Yeah, the Citus code only handles things that Citus supports in
distributed tables. Which is quite a lot, but indeed not everything
yet. Temporary and inherited tables are not supported in this code
afaik. Possibly more. See the commented out
EnsureRelationKindSupported for what should be supported (normal
tables and partitioned tables afaik).

Attachment Content-Type Size
v1-0001-Add-initial-code-to-generate-table-definition-SQL.patch application/octet-stream 41.0 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2023-06-05 14:02:12 Re: Composite type: Primary Key and validation
Previous Message gzh 2023-06-05 10:06:11 Re: Is there any good optimization solution to improve the query efficiency?

Browse pgsql-hackers by date

  From Date Subject
Next Message 蔡梦娟 (玊于) 2023-06-05 11:44:05 Fix missing initialization of delayChkptEnd
Previous Message Ranier Vilela 2023-06-05 11:24:13 Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c)