Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement
| От | Florin Irion |
|---|---|
| Тема | Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement |
| Дата | |
| Msg-id | 853e2793-c9dd-4ad5-8d0a-6e75619d46b1@gmail.com обсуждение исходный текст |
| Ответ на | Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement (Tom Lane <tgl@sss.pgh.pa.us>) |
| Список | pgsql-hackers |
Tom, Álvaro, thanks for the direction — I think the v9 patch addresses both of your concerns nicely. No extra test run. The event trigger is installed once in test_setup.sql, so it piggybacks on the existing regression suite. Every CREATE that fires ddl_command_end is checked inline — there is no separate execution of the core tests. Developers don't have to remember anything. The trigger inspects command_tag to derive the object type, then probes pg_catalog for a matching pg_get_<type>_ddl() function. If one exists it round-trips the object right there; if not it silently moves on. Adding a new pg_get_type_ddl() or pg_get_sequence_ddl() in the future automatically extends coverage to every CREATE of that type across the entire suite — zero changes to the trigger or to existing tests. Inline verification at creation time. The trigger does: get DDL → DROP → CREATE from DDL → get DDL → ASSERT match Because it runs at creation time, nothing yet depends on the new object, so the drop/recreate is safe. A session-local GUC guards against recursion (the recreate fires the trigger again). Bugs of omission. Tom raised the concern that comparing DDL output against DDL output could mask a missing property. The key thing here is that the test suite continues running with the recreated object. If the DDL function omits, say, a CHECK constraint, the recreated domain silently loses it — and any subsequent test that exercises that constraint will fail. So omissions surface as unexpected failures elsewhere in the suite, not just in the DDL comparison itself. With the current patch, 160 domains across 33 test files are automatically round-tripped. The dedicated object_ddl.sql file is gone — a small set of pg_get_domain_ddl() output-format tests (pretty printing, quoted identifiers, NOT VALID rendering, built-in type name shadowing, error cases) now lives in domain.sql alongside the rest of the domain coverage. v9 attached. While working on this I bumped into an unrelated crash and started a new thread [1] for it. [1] https://www.postgresql.org/message-id/c6fff161-9aee-4290-9ada-71e21e4d84de%40gmail.com -- Cheers, Florin EDB -- www.enterprisedb.com
Вложения
В списке pgsql-hackers по дате отправления: