Re: Suggestion to standardize comment format in pg_dump

From: "Euler Taveira" <euler(at)eulerto(dot)com>
To: "Nohez Poonawala" <nohezp(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Suggestion to standardize comment format in pg_dump
Date: 2024-12-11 15:14:01
Message-ID: 507163ed-e23a-4ac0-9017-646dbb7b9de8@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 11, 2024, at 3:37 AM, Nohez Poonawala wrote:
> Currently, the pg_dump tool outputs comments in different formats for
> primary/foreign keys and indexes. Below is the comment format.
>
> - for Primary key:
> -- Name: TABLENAME CONSTRAINTNAME; Type: CONSTRAINT; Schema: SCHEMA;
> Owner: OWNER
> - for Foreign key:
> -- Name: TABLENAME CONSTRAINTNAME; Type: FK CONSTRAINT; Schema:
> SCHEMA; Owner: OWNER
> - for Index:
> -- Name: INDEXNAME; Type: INDEX; Schema: SCHEMA; Owner: OWNER
>
> To maintain consistency, I suggest modifying the comment format for
> indexes to include the associated TABLENAME, similar to constraints.
>
> For example:
> - for Index:
> -- Name: TABLENAME INDEXNAME; Type: INDEX; Schema: SCHEMA; Owner: OWNER
>
> This small change would improve clarity and make the output format more uniform.

Constraints and indexes are different classes of objects. Per SQL standard,
different tables can have same constraint names. However, different tables
cannot have same index name (SQL standard says nothing about indexes. That's a
Postgres implementation detail.) Having said that, you don't need the table
name to associate it with an index (because it is unique in a schema) but a
constraint requires a table (because there might be multiple constraints with
the same name in a schema). An argument against this inclusion is that it will
increase the output file size without adding a crucial information. You mention
consistency but since it is a different class of objects I don't think this
argument holds much water.

--
Euler Taveira
EDB https://www.enterprisedb.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-12-11 15:38:03 Re: Suggestion to standardize comment format in pg_dump
Previous Message Marcos Pegoraro 2024-12-11 15:09:00 Re: Document NULL