Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x4tJ9-007Toz-0o for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Sep 2026 04:56:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x4tJ5-00BtDM-2u for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Sep 2026 04:56:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x4tJ5-00BtCr-1v for pgsql-hackers@lists.postgresql.org; Fri, 11 Sep 2026 04:56:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x4tIw-000000045FL-27Gq for pgsql-hackers@postgresql.org; Fri, 11 Sep 2026 04:56:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 68B4tsv1956967; Fri, 11 Sep 2026 00:55:54 -0400 From: Tom Lane To: Robert Haas cc: Noah Misch , Andrew Dunstan , Melanie Plageman , gonzalemario@gmail.com, dbryan.green@gmail.com, euler@eulerto.com, pgsql-hackers@postgresql.org Subject: Re: pg_get_*_ddl() needs a redesign In-reply-to: References: <20260827015242.54.noahmisch@microsoft.com> <20260909172132.0a.noahmisch@microsoft.com> <640139.1788975299@sss.pgh.pa.us> <20260910035953.59.noahmisch@microsoft.com> Comments: In-reply-to Robert Haas message dated "Fri, 11 Sep 2026 00:19:15 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <956965.1789102554.1@sss.pgh.pa.us> Date: Fri, 11 Sep 2026 00:55:54 -0400 Message-ID: <956966.1789102554@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > That said, if this is coming out of v19 anyway, then IMHO it is fair > game to reopen the question of whether we want it in v20. But if we're > going to do that, we should hash that out now rather than in six > months from now or twelve months from now. Personally, I have mixed > feelings about this feature. On the one hand, I am sure it will get > some use, and I have wanted it myself. On the other hand, it will get > far less use, and far less testing, than the equivalent code in > pg_dump, so it's more likely to have bugs now and in the future, and > the fact that there's no reasonable way (at least, not that I can see) > to handle version skew within a facility like this is a major > disadvantage vs. pg_dump. I'm a bit confused why you say that. To my mind, if we were going to proceed in this direction, version skew would ideally be solved like this: 1. Server-side DDL-reconstruction functions only need to work with their particular server version; necessarily so, since that's the only catalog data they'll ever see. 2. pg_dump just calls the source server's DDL-reconstruction functions and doesn't have to worry about version skew. The difficulty is how do we get to #2 from where we are. Part of that could be handled by saying "well, pg_dump calls the server functions when source server version >= N, and otherwise does it locally", and expecting that we could eventually retire the "locally" code. Since the "locally" code would only need to work with frozen server versions, that doesn't seem too unmaintainable. The hard parts as I see it are (A) pg_dump is optimized to gather data across the entire database at once. Converting it to call functions that produce info about a single object at a time would almost certainly be catastrophic for performance on large databases. (B) pg_dump slices and dices the data in ways that don't necessarily make sense for standalone usage. For example it doesn't want to mention a primary key when creating a table, rather it wants to add that constraint (and build the index) after loading data. I do not feel that these problems are necessarily insoluble, but they do require some hard work to define the server-side functionality properly. regards, tom lane