Thread: Suggestion to standardize comment format in pg_dump
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. If I am reporting this to the wrong forum, please excuse me. If possible, kindly suggest the correct forum for submitting this request. Regards,
On Wed, Dec 11, 2024, at 3:37 AM, Nohez Poonawala wrote:
Currently, the pg_dump tool outputs comments in different formats forprimary/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: OWNERTo maintain consistency, I suggest modifying the comment format forindexes to include the associated TABLENAME, similar to constraints.For example:- for Index:-- Name: TABLENAME INDEXNAME; Type: INDEX; Schema: SCHEMA; Owner: OWNERThis 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" <euler@eulerto.com> writes: > On Wed, Dec 11, 2024, at 3:37 AM, Nohez Poonawala wrote: >> 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 > ... 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. I think a bigger problem is compatibility. It seems likely that there are tools out there that would be broken by such a change. These comments aren't just comments: they directly reflect what is in the "tag" fields of the per-object entries in the custom dump format. So for example this would also affect the output of "pg_restore -l". Even if you doubt that anything is scanning actual dump files looking for these comments, it seems certain that people have built tools and scripts that examine -l output. There might well be places in pg_restore itself that depend on the tag being just the index name and no more, too. I'll concede that this proposal would have been a good idea if it'd been done that way early on. But I don't think it's such a good idea as to be worth breaking things for. regards, tom lane