Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement
Florin Irion <irionr@gmail.com>
From: Florin Irion <irionr@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, Haritabh Gupta <haritabh1992@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2026-03-02T16:41:41Z
Lists: pgsql-hackers
Attachments
- v8-0001-Add-pg_get_domain_ddl-function-to-reconstruct-CRE.patch (text/plain) patch v8-0001
Hi Haritabh, Tom, Thanks for the thorough review. v8 fixes all reported bugs and adds round-trip tests to address the forcing-function concern. Haritabh's bugs — all fixed in attached v8. On 19/02/26 01:10, Tom Lane wrote: > This report crystallized something that's been bothering me > about not only pg_get_domain_ddl() but all the similar patches > that are in the queue. They are adding a large amount of new > code that will have to be kept in sync with behavior elsewhere > and there is basically zero forcing function to ensure that > that happens. Even the rather-overly-voluminous test cases > proposed for the functions cannot catch errors of omission, > especially not future errors of omission. v8 adds a PL/pgSQL round-trip harness that captures DDL, drops the domain, re-executes the DDL, and ASSERTs the regenerated DDL is identical, any suggestions on how to improve it are welcomed. This function can be re-used also with other get_<object>_ddl as it accepts a parameter for the <object_type>, this way we can use some common code. > I don't really know what to do about this, but I don't like the > implementation approach that's being proposed. I think it's > loading too much development effort and future maintenance effort > onto us in comparison to the expected benefit of having these > functions. I understand your point that there are multiple implementations and each have its own way of doing it. I think we should start somewhere and eventually ask further implementations to adapt to use common code or make it work with all existing (at that point) implementations, one at a time. pg_get_domain_ddl implementation uses mainly common code in ruleutils.c plus some glue code. We could maybe also create a new separate module and put all the code for all these features there. What do you think? Cheers, Florin -- *Florin Irion* www.enterprisedb.com <https://www.enterprisedb.com>