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 1w3JlY-0016eJ-36 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 20:14:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w3JlX-002bB3-0g for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 20:14:47 +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 1w3JlW-002bAv-2G for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 20:14:47 +0000 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w3JlU-000000003Yd-1MlI for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 20:14:45 +0000 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-89a14be4733so17374936d6.2 for ; Thu, 19 Mar 2026 13:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1773951283; x=1774556083; darn=lists.postgresql.org; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=1Yko5OkrksK1Wq3sc2vGqbm8VmYHgQMXik8Gl8biTOI=; b=C96HRGcwnXluZu5aSpTBrX3UeJqImUwJVZvKXRdBPsb4eS0MYdXcrVeqmsLaKuaXxA tJBQBzwXDHlmInKKzD0eeDwZbAksBL/uq3canR77kwoLgx26Pym22d1KTytaT/tuofCC ME0lRnbSyr+ZRLjruyBV1EkWPcszVzc1E5fWWsev9/t/rqKfMkzii+WYGi5aoFngmeMc O+D6mzPhhNYrF0iC2vMZmGHB74nQg3qStD5sdhh6mzX9NFLFtLZmqrHLG1dw6KcD4iaf TgcM6rsvWV+9bQn0Krc0Np+Xoaeev8e5NJw41HQqsk4A9QBcr47tBOuZqcQhGkylF+dn MVjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773951283; x=1774556083; h=in-reply-to:autocrypt: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; bh=1Yko5OkrksK1Wq3sc2vGqbm8VmYHgQMXik8Gl8biTOI=; b=ZOIE8XP6sHPburhLMwBRO1VGM8ApAtQb6EbnXLotuRs4Ua5uh4hthGf0MLlEOSQty/ lyto9RHhqU8xZaWhPCHWva+0MG/DH2901S/gPbUvYhuk2/cNPSgAnYfYtmziGK2xVXj8 IufW3btYi29cXTUwhhRN7DG8WtMI1p2VERqdu5756L+nx4ALENCXPOvjavEpONPBOY8e yuu/k+ECAS/qEconvkW101hHmBjgEDBQEfKhuTbZQFwPOiS24wbBetpJnL1ZKi22kxeJ /KsiWnWqu08ODX0uOx5HQUuSzHyP50bLkRPUaE/eG45wuW2yxnIJzVbsoqMzA/8IBgp4 jo+w== X-Gm-Message-State: AOJu0Ywrok5iER319XH8PgeXofvf6ky5qhOoy0k7Z9AlewrJeHcAJt5W UumWAenFWwHQFHucAFES1h4aXEZNsxrHNI8rJ9gp0lziEVVQPJbSYZ9dgdFWGPoHu5U= X-Gm-Gg: ATEYQzzM0CR6ZUvVuw1A3icTLrygfrvv577nmuyC42G94R1S6yODdjI089krfhzvoDa ton5Y5pNfQvDvVY5iNmaI3hRzcOmPV5cmQQwPGqDWLTht/Tys0tn8nc+egYNk5rXHmxggezx/xi vq5NVS5hc+h5J4YRG+NB7GpONWFzRZobAQX2vVTCBVUWez1UGM1lWYFveT3CLQWGB6ZEgVFWbwa a4tK4cSMUifvCIJrfdeu3QRLs3A1e0vJp3vPRHtUgdnazT9c9PG1FD827/00b6DAPtuCEFfPdM2 AlEaQOfflVhLHHyb7CDD9DxkESi0ifZ8dELMnhCgjC48ehZRiTpldV3JBo6hsVqi6WTqMUxWMQQ tJ9ywIsHdqMWhtohxrSHSCf7Y5fkbQej9JD3nxdhSIScaRsMb8q1Le5hXpa/LFHIf5fQ+jL140/ 55g8rqWvkKs9dRlkkvxiyv8axDcC26H4Nrk+bS7Uj2 X-Received: by 2002:a05:6214:1bce:b0:89a:10d8:f9ca with SMTP id 6a1803df08f44-89c859e84d5mr7160206d6.26.1773951282594; Thu, 19 Mar 2026 13:14:42 -0700 (PDT) Received: from ?IPV6:2605:a601:a6b0:500::1cb? ([2605:a601:a6b0:500::1cb]) by smtp.googlemail.com with ESMTPSA id 6a1803df08f44-89c85215255sm6062456d6.3.2026.03.19.13.14.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Mar 2026 13:14:42 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------BDL2ja4l50XR095C5xmTiwF0" Message-ID: Date: Thu, 19 Mar 2026 16:14:41 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pg_get__*_ddl consolidation To: Mahendra Singh Thalor Cc: PostgreSQL Hackers References: From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQH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IAKTsfD40teP/pp+bsLLMSxPXUYrrprTj7WFB5v61p6dkpSr/ qXmMlyahdxQFaPmfVgVirB1Vk/kHiWNnnGjfUV9nB2Zg9LI0Xb9/ts3LsUiRWXzG3tkMY6XL vsVOxW4XFRND9l2q+WW93aZ1DZl+fqWfYgMvsusFRhmGFOKTRfKPta2Pkv+AhA24N4+PrR5p bU4k2MO8PAGiK8eaYKGFG1bHKuAvoDoF7WXJ3FHxuWqLnKEt4dfOLm5pAe3zq1Lt6q8azT9i QWGpSAK5vQUWQHBHpiDjdPeqKZ6HiAXIIKfSmb+jrvXBqoP+D6/K7rUjG2aXiRtTIAXms9sm VRu7cmw= In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------BDL2ja4l50XR095C5xmTiwF0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-03-19 Th 3:55 PM, Mahendra Singh Thalor wrote: > On Fri, 20 Mar 2026 at 00:04, Andrew Dunstan wrote: >> Greetings >> >> Euler Taveira and I have been working on consolidating these patches. >> >> These patches came out of a suggestion from me some time back [1], and I >> used it as the base for some work at an EDB internal program. Perhaps I >> was motivated a bit by Mao's dictum "Let a hundred flowers bloom; let a >> hundred schools of thought contend." I wanted to see what people would >> come up with. Therefore, if this has seemed a bit chaotic, I apologize, >> both to the authors and to the list. I won't do things quite this way in >> future. >> >> Rather than adding to the already huge ruleutils.c, we decided to create >> a new ddlutils.c file to contain these functions and their associated >> infrastructure. There is in fact a fairly clean separation between these >> functions and ruleutils. We just need to expose one function in ruleutils. >> >> We (Euler and I) decided to concentrate on setting up common >> infrastucture and ensuring a common argument and result structure. In >> this first round, we are proposing to add functions for getting the DDL >> for databases, tablespaces, and roles. We decided to stop there for now. >> This sets up a good basis for dealing with more object types in future. >> To the authors of the remaining patches - rest assured you have not been >> forgotten. >> >> Patch 1 sets up the functions used by the rest for option parsing. see [2] >> Patch 2 implements pg_get_role_dll see[3] >> Patch 3 implements pg_get_tabespace_ddl see [4] >> Patch 4 implements pg_get_database_ddl see [2] >> >> >> cheers >> >> >> andrew >> >> >> [1] >> https://www.postgresql.org/message-id/flat/945db7c5-be75-45bf-b55b-cb1e56f2e3e9%40dunslane.net >> >> [2] >> https://www.postgresql.org/message-id/flat/CANxoLDc6FHBYJvcgOnZyS+jF0NUo3Lq_83-rttBuJgs9id_UDg@mail.gmail.com >> >> [3] >> https://www.postgresql.org/message-id/flat/4c5f895e-3281-48f8-b943-9228b7da6471@gmail.com >> >> [4] >> https://www.postgresql.org/message-id/flat/CAKWEB6rmnmGKUA87Zmq-s=b3Scsnj02C0kObQjnbL2ajfPWGEw@mail.gmail.com >> >> >> -- >> Andrew Dunstan >> EDB:https://www.enterprisedb.com > Hi all, > I was reading these patches and found that any user can get the > definition of database/roles by pg_get__*_ddl. I think these functions > should be restricted only to super users as these are cluster level > objects. You could construct these functions using plpgsql. The information isn't hidden from non-superusers. So what exactly would making these functions superuser-only achieve? Now it's true that the user might not be able to execute the DDL. But that's not the point. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------BDL2ja4l50XR095C5xmTiwF0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 2026-03-19 Th 3:55 PM, Mahendra Singh Thalor wrote:
On Fri, 20 Mar 2026 at 00:04, Andrew Dunstan <andrew@dunslane.net> wrote:
Greetings

Euler Taveira and I have been working on consolidating these patches.

These patches came out of a suggestion from me some time back [1], and I
used it as the base for some work at an EDB internal program. Perhaps I
was motivated a bit by Mao's dictum "Let a hundred flowers bloom; let a
hundred schools of thought contend." I wanted to see what people would
come up with. Therefore, if this has seemed a bit chaotic, I apologize,
both to the authors and to the list. I won't do things quite this way in
future.

Rather than adding to the already huge ruleutils.c, we decided to create
a new ddlutils.c file to contain these functions and their associated
infrastructure. There is in fact a fairly clean separation between these
functions and ruleutils. We just need to expose one function in ruleutils.

We (Euler and I) decided to concentrate on setting up common
infrastucture and ensuring a common argument and result structure. In
this first round, we are proposing to add functions for getting the DDL
for databases, tablespaces, and roles. We decided to stop there for now.
This sets up a good basis for dealing with more object types in future.
To the authors of the remaining patches - rest assured you have not been
forgotten.

Patch 1 sets up the functions used by the rest for option parsing. see [2]
Patch 2 implements pg_get_role_dll see[3]
Patch 3 implements pg_get_tabespace_ddl see [4]
Patch 4 implements pg_get_database_ddl see [2]


cheers


andrew


[1]
https://www.postgresql.org/message-id/flat/945db7c5-be75-45bf-b55b-cb1e56f2e3e9%40dunslane.net

[2]
https://www.postgresql.org/message-id/flat/CANxoLDc6FHBYJvcgOnZyS+jF0NUo3Lq_83-rttBuJgs9id_UDg@mail.gmail.com

[3]
https://www.postgresql.org/message-id/flat/4c5f895e-3281-48f8-b943-9228b7da6471@gmail.com

[4]
https://www.postgresql.org/message-id/flat/CAKWEB6rmnmGKUA87Zmq-s=b3Scsnj02C0kObQjnbL2ajfPWGEw@mail.gmail.com


--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Hi all,
I was reading these patches and found that any user can get the
definition of database/roles by pg_get__*_ddl. I think these functions
should be restricted only to super users as these are cluster level
objects.


You could construct these functions using plpgsql. The information isn't hidden from non-superusers. So what exactly would making these functions superuser-only achieve? Now it's true that the user might not be able to execute the DDL. But that's not the point.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------BDL2ja4l50XR095C5xmTiwF0--