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 1x5OJv-0002iH-33 for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Sep 2026 14:03:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x5OJv-000pXc-1K for pgsql-hackers@arkaria.postgresql.org; Sat, 12 Sep 2026 14:03:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x5OJu-000pX5-38 for pgsql-hackers@lists.postgresql.org; Sat, 12 Sep 2026 14:03:07 +0000 Received: from mail-qk2-x10.google.com ([2607:f8b0:4864:34::10]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x5OJs-000000001k8-15L0 for pgsql-hackers@postgresql.org; Sat, 12 Sep 2026 14:03:06 +0000 Received: by mail-qk2-x10.google.com with SMTP id af79cd13be357-939695b5741so89482785a.1 for ; Sat, 12 Sep 2026 07:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20251104.gappssmtp.com; s=20251104; t=1789221782; x=1789826582; darn=postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=a/WMLCEPton2Xcy2+R2NS3G1+l29MgjP/1grZTRnhaA=; b=jdTL9XeRjlqfWCfQqNxEpPWO7nj+NAo94OIzvbuhKsFi3e1o5Egxt9VPhSfAV99ZuV g7QLCVfDnnCnFxdeBtpYEEuGevE6ntrLL0yuQ9VKz9TU/ZMcllSpUUrrfNSSaYMqWEZs bV/aFBUR0+jTJ4ejLx8A55EXQSmnsDic5IHITcWSc4k2p+OLExje1v2noNcnAT/uNWMf HmT5ARZH6sVgrVWtyV7D3xBrdZlA8EWl+S7rgJglfsZL0HkuUHno9z4rDMx6YKPJc5v8 WSoW1J9Vv2zuZ046j99Kf7O+ji2G4TXUw2GNjOnm5maOfljerPH3bg4JNqdq3/Ypo8Mf Y92g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789221782; x=1789826582; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=a/WMLCEPton2Xcy2+R2NS3G1+l29MgjP/1grZTRnhaA=; b=An23LnaJMkixqGtXkgoQsalA+DuViMw0JTp/deif+HOeW0NnuomatnOug19IbTOMrQ ldvREdK/BKvzx4azrfrSgsvTA6DgVOBSNPQK9Y6s3vKR8QSVlUIucnqFnhx4RP6CIwoq yWdbhAQIeHjWuCDmsbnC5AkHMEZwlvUj39z07ULokQVIOMPP1qp2BsOoryf0lfbPPVKf NOFWZnTYb6Zkp1p7eEg2FjXS36i201yiFaEBXZHWQfJcKlJj7KiHz2qJASAJbNLwDNE/ /ljyZDtM0ijwMcVprer0g9LGVjYV4JYKVo3T5h6v2vuhtLAsvyPtg6quvw6oKSfgBB7F TK4g== X-Forwarded-Encrypted: i=1; AKwUvByXQRxA/DtSSwTM8KMytwNe4tr0TrlvO1bes6yzFtTlxGwws76ym8kTj75bX0M0cXduGcqLMwnFxR9fkEuH@postgresql.org X-Gm-Message-State: AFuF++nrfL96mExjfVzAmg7fC6G7FvIjx8+C2BOwGT8AfFhOcvH5Pl4c HnngJHCqpaNqu+4va27HYgdcjRlR4ROA4nTpV8/R/VUoywq5iSmKilS6UhqkDTH7gDg= X-Gm-Gg: AYBFou1dSnV/JVqGDWscRaZb/npjUVNNk1BFUs+YBpfWyU4mwkzpEfE4sqItmHdbVat NjXyqtpRIQUqzgd71swxOONPchfuk96fPnhOzrSAAk1zbd1eKE4YOBH8cPPVw/vB14CUgR+R2ON Drs67oeTE1ik+9oNLGN5YT0TrKnLLgFIK2BCuzs7Ha+mqLbxE5eB0xWy9Ari9a+WkwAbxbzywqD QPha/LSgoHqd8zPVCwW7g0lOJpzIz6aim6gYAyJRVLfIt3zwUd1MZZQpuP2TqpSh3JwysPbAqQg sqx0N/s82WG0m9DW28e4PQoz4HRq7Z1YpYoJPeyu+9ZcstOF7ELCCVVNCQ0F68he0l2bjyUe4dm DeJ1K6+zPDPgJdOXgflI4JNewMjK1B5uMLYCFMKfiTyNMj+oI1YGPzB/goK9/7Q7HzF1expahTA lwMvV1qOfnLzH/+9/6TpJOjb4rBP1eZU0ZmayS17qHeQDC3i81H4uswPpgjGju4/mRrta4M7oN9 TbzpYcEbw== X-Received: by 2002:a05:620a:2410:20b0:939:eb65:bd38 with SMTP id af79cd13be357-939eb65be93mr829219885a.35.1789221780937; Sat, 12 Sep 2026 07:03:00 -0700 (PDT) Received: from ?IPV6:2605:a601:a6a6:4300::303? ([2605:a601:a6a6:4300::303]) by smtp.gmail.com with ESMTPSA id af79cd13be357-939e809fd0bsm500374285a.33.2026.09.12.07.03.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 12 Sep 2026 07:03:00 -0700 (PDT) Message-ID: Date: Sat, 12 Sep 2026 10:02:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_get_*_ddl() needs a redesign To: Tom Lane , Robert Haas Cc: Noah Misch , Melanie Plageman , gonzalemario@gmail.com, dbryan.green@gmail.com, euler@eulerto.com, pgsql-hackers@postgresql.org References: <20260827015242.54.noahmisch@microsoft.com> <20260909172132.0a.noahmisch@microsoft.com> <640139.1788975299@sss.pgh.pa.us> <20260910035953.59.noahmisch@microsoft.com> <956966.1789102554@sss.pgh.pa.us> From: Andrew Dunstan Content-Language: en-US In-Reply-To: <956966.1789102554@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-09-11 Fr 12:55 AM, Tom Lane wrote: > 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. > > I think you've put your finger on some of the main issues. The main use case in my mind from the get go was not "How do we make this work for pg_dump?" but "I want to create an object that's like this thing but a bit different. Give me the DDL for this thing so I can tinker with it." That's the use case that people just about always give me when I've talked to them about this. Maybe point A is not insoluble, but I've thought all along that it was a pretty significant barrier, and I don't have a good solution for it. Making this feature contingent on solving that problem would sacrifice the originally intended use case, which would be very sad. Your point B is also well taken. pg_dump formats and arranges the SQL to suit its purposes, but that should not be taken as the canonical arrangement for other uses. Perhaps these functions should have a "dump" flavor that produces output like pg_dump/all. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com