Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-19 Thread Akshay Joshi
Thanks Álvaro Will work on it and send the updated patch. On Wed, Nov 19, 2025 at 4:17 PM Álvaro Herrera wrote: > Hello, > > One thing I realized a few days ago is that since commit bd09f024a1bb we > have type regdatabase, so instead of having two functions (one taking > name and one taking Oid)

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-19 Thread Akshay Joshi
On Wed, Nov 19, 2025 at 3:48 PM Japin Li wrote: > > Hi Akshay, > > Thanks for updating the patch. > > On Tue, 18 Nov 2025 at 13:33, Akshay Joshi > wrote: > > Hi Chao > > > > Thanks for reviewing my patch. > > > > On Tue, Nov 18, 2025 at 5:59 AM Chao Li wrote: > > > > Hi Akshay, > > > > I just

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-19 Thread Álvaro Herrera
Hello, One thing I realized a few days ago is that since commit bd09f024a1bb we have type regdatabase, so instead of having two functions (one taking name and one taking Oid), we should have just one, taking regdatabase, just like the functions for producing DDL for other object types that have co

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-19 Thread Japin Li
Hi Akshay, Thanks for updating the patch. On Tue, 18 Nov 2025 at 13:33, Akshay Joshi wrote: > Hi Chao > > Thanks for reviewing my patch. > > On Tue, Nov 18, 2025 at 5:59 AM Chao Li wrote: > > Hi Akshay, > > I just reviewed v3 and got some comments: > > > On Nov 17, 2025, at 22:34, Akshay

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-18 Thread Akshay Joshi
Hi Chao Thanks for reviewing my patch. On Tue, Nov 18, 2025 at 5:59 AM Chao Li wrote: > Hi Akshay, > > I just reviewed v3 and got some comments: > > > On Nov 17, 2025, at 22:34, Akshay Joshi > wrote: > > > > All the review comments have been addressed in v3 patch. > > > 1 - ruleutils.c > ``` >

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-17 Thread Chao Li
Hi Akshay, I just reviewed v3 and got some comments: > On Nov 17, 2025, at 22:34, Akshay Joshi wrote: > > All the review comments have been addressed in v3 patch. 1 - ruleutils.c ``` + if (dbForm->datconnlimit != 0) + get_formatted_string(&buf, prettyFlags, 1, "CONNECTION

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-17 Thread Akshay Joshi
The v3 patch adds a check for the CONNECT privilege on the target database for pg_get_database_ddl(). This aligns its security model with functions like pg_database_size(). Note that revoking permissions on the *pg_database* table alone is insufficient to restrict DDL access; users must manually re

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-17 Thread Akshay Joshi
On Fri, Nov 14, 2025 at 11:19 AM Japin Li wrote: > On Thu, Nov 13, 2025 at 02:02:30PM +0530, Akshay Joshi wrote: > > On Thu, Nov 13, 2025 at 10:18 AM Quan Zongliang > > wrote: > > > > > > > > > > > On 11/13/25 12:17 PM, Quan Zongliang wrote: > > > > > > > > > > > > On 11/12/25 8:04 PM, Akshay Jo

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-14 Thread Álvaro Herrera
On 2025-Nov-13, Quan Zongliang wrote: > A more specific example. Originally, it was impossible to obtain the > definition of "testdb" by accessing pg_database: > > postgres=> SELECT * FROM pg_database WHERE datname='testdb'; > ERROR: permission denied for table pg_database Hmm. So I was th

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-13 Thread Chao Li
Hi Akshay, I quick went through the patch, I do see some problems, but I need some time to wrap up, so I will do a deep review next week. In the meantime, I want to first ask that why there is no privilege check? I think that’s a serious issue. > On Nov 13, 2025, at 16:32, Akshay Joshi wrote:

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-13 Thread Japin Li
On Thu, Nov 13, 2025 at 02:02:30PM +0530, Akshay Joshi wrote: > On Thu, Nov 13, 2025 at 10:18 AM Quan Zongliang > wrote: > > > > > > > On 11/13/25 12:17 PM, Quan Zongliang wrote: > > > > > > > > > On 11/12/25 8:04 PM, Akshay Joshi wrote: > > >> Hi Hackers, > > >> > > >> I’m submitting a patch as

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-13 Thread Quan Zongliang
On 11/13/25 8:28 PM, Álvaro Herrera wrote: But what about the following scenario? If there is no permission to access pg_database. Shouldn't the DDL be returned? postgres=> SELECT * FROM pg_database; ERROR: permission denied for table pg_database postgres=> SELECT pg_get_database_ddl('testd

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-13 Thread Akshay Joshi
On Thu, Nov 13, 2025 at 10:18 AM Quan Zongliang wrote: > > > On 11/13/25 12:17 PM, Quan Zongliang wrote: > > > > > > On 11/12/25 8:04 PM, Akshay Joshi wrote: > >> Hi Hackers, > >> > >> I’m submitting a patch as part of the broader Retail DDL Functions > >> project described by Andrew Dunstan http

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-13 Thread Akshay Joshi
On Thu, Nov 13, 2025 at 9:47 AM Quan Zongliang wrote: > > > On 11/12/25 8:04 PM, Akshay Joshi wrote: > > Hi Hackers, > > > > I’m submitting a patch as part of the broader Retail DDL Functions > > project described by Andrew Dunstan https://www.postgresql.org/message- > > id/945db7c5-be75-45bf-b55

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-13 Thread Quan Zongliang
On 11/13/25 4:30 PM, Akshay Joshi wrote: On Thu, Nov 13, 2025 at 9:47 AM Quan Zongliang > wrote: On 11/12/25 8:04 PM, Akshay Joshi wrote: > Hi Hackers, > > I’m submitting a patch as part of the broader Retail DDL Functions > project d

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-12 Thread Quan Zongliang
On 11/13/25 12:17 PM, Quan Zongliang wrote: On 11/12/25 8:04 PM, Akshay Joshi wrote: Hi Hackers, I’m submitting a patch as part of the broader Retail DDL Functions project described by Andrew Dunstan https://www.postgresql.org/ message- id/945db7c5-be75-45bf-b55b-cb1e56f2e3e9%40dunslane.

Re: [PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-12 Thread Quan Zongliang
On 11/12/25 8:04 PM, Akshay Joshi wrote: Hi Hackers, I’m submitting a patch as part of the broader Retail DDL Functions project described by Andrew Dunstan https://www.postgresql.org/message- id/945db7c5-be75-45bf-b55b-cb1e56f2e3e9%40dunslane.net www.postgresql.org/message-id/945db7c5-be75-

[PATCH] Add pg_get_database_ddl() function to reconstruct CREATE DATABASE statement

2025-11-12 Thread Akshay Joshi
Hi Hackers, I’m submitting a patch as part of the broader Retail DDL Functions project described by Andrew Dunstan https://www.postgresql.org/message-id/945db7c5-be75-45bf-b55b-cb1e56f2e3e9%40dunslane.net This patch adds a new system function pg_get_database_ddl(database_name/database_oid, pretty