Re: Suggestion to standardize comment format in pg_dump - Mailing list pgsql-hackers

From Euler Taveira
Subject Re: Suggestion to standardize comment format in pg_dump
Date
Msg-id 507163ed-e23a-4ac0-9017-646dbb7b9de8@app.fastmail.com
Whole thread Raw
In response to Suggestion to standardize comment format in pg_dump  (Nohez Poonawala <nohezp@gmail.com>)
Responses Re: Suggestion to standardize comment format in pg_dump
List 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

pgsql-hackers by date:

Previous
From: Marcos Pegoraro
Date:
Subject: Re: Document NULL
Next
From: Tom Lane
Date:
Subject: Re: Suggestion to standardize comment format in pg_dump