From: | Shubham Khanna <khannashubham1197(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | Euler Taveira <euler(at)eulerto(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com> |
Subject: | Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided. |
Date: | 2025-03-26 10:32:47 |
Message-ID: | CAHv8RjJSDi-pbybmA+kvfcX5MQAeXDEdPqY=a5svFcJoe9YXYA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Mar 26, 2025 at 10:21 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Wed, Mar 26, 2025 at 2:05 AM Euler Taveira <euler(at)eulerto(dot)com> wrote:
> >
> > On Tue, Mar 25, 2025, at 8:07 AM, Shubham Khanna wrote:
> >
> > Apologies for the oversight. I have attached the patches now. Please
> > find them included here.
> >
> >
> > I started looking at this patch. When I started reading the commit message, I
> > didn't understand why the options that provide names to objects are
> > incompatible with --all option. I agree that --all and --database should be
> > incompatible but the others shouldn't. We already have a check saying that the
> > number of specified objects cannot be different from the number of databases.
> > Why don't rely on it instead of forbidding these options?
> >
>
> We must ensure to match the order of objects specified with the
> database as well (The doc says: The order of the multiple publication
> name switches must match the order of database switches.). It is easy
> for users to do that when explicitly specifying databases with -d
> switches but not with --all case. I can see a way to extend the
> current functionality to allow just fetching databases from the
> publisher and displaying them to the user, then we can expect the user
> to specify the names of other objects in the same order but not
> otherwise.
>
> >
> > What happens if you don't specify the dbname in -P option?
> >
> > + /* Establish a connection to the source server */
> > + conn = connect_database(opt->pub_conninfo_str, true);
> >
> > It defaults to user name. If you are using another superuser (such as admin)
> > the connection might fail if there is no database named 'admin'. vacuumdb that
> > has a similar --all option, uses another option (--maintenance-db) to discover
> > which databases should be vacuumed. I'm not suggesting to add the
> > --maintenance-db option. I wouldn't like to hardcode a specific database
> > (template1, for example) if there is no dbname in the connection string.
> > Instead, suggest the user to specify dbname into -P option. An error message
> > should be provided saying the exact reason: no dbname was specified.
> >
>
> But why shouldn't we use the same specification as vacuumdb, which is:
> "If not specified, the postgres database will be used, or if that does
> not exist, template1 will be used."?
>
I agree that ensuring the correct order of objects (like publications)
matching with databases is crucial, especially when explicitly
specifying databases using -d switches.
To address this, I have created a 0002 patch that aligns object
creation order with the corresponding databases.
> >
> > I checked the applications that provide multiple synopsis using the following command.
> >
> > grep '<cmdsynopsis' doc/src/sgml/ref/*.sgml | awk '{print $1}' | sort | uniq -c
> >
> > There are just 3 applications that have multiple cmdsynopsis. pgbench has 2
> > distinct tasks (load and run) so it makes sense to have 2 synopsis. pg_ctl has
> > multiple tasks and also deserves multiple synopsis. The complexity introduced
> > into vacuumdb (per table, per schema) seems to justify multiple synopsis too.
> > However, the same logic doesn't apply here. IMO 0002 shouldn't be applied
> > because the additional option (--all) doesn't justify multiple synopsis for
> > syntax clarification.
> >
>
> Yeah, also, vacuumdb doesn't have a separate line for --all in
> synopsis. So, I agree with you about not adding '--all' option in the
> synopsis.
>
> --
The attached patches contain the suggested changes. They also address
the comments provided by Ashutosh (at [1]) and Euler (at [2]).
[1] - https://www.postgresql.org/message-id/CAExHW5uvp6LWfgcysohDaOaNhqAbmuc%3D9BwWke%3D6KPRZ%2BwVOkA%40mail.gmail.com
[2] - https://www.postgresql.org/message-id/e32c358b-95b5-426c-9baa-281812821588%40app.fastmail.com
Thanks and regards,
Shubham Khanna.
Attachment | Content-Type | Size |
---|---|---|
v22-0001-Enhance-pg_createsubscriber-to-fetch-and-append-.patch | application/octet-stream | 12.2 KB |
v22-0004-Additional-test-cases.patch | application/octet-stream | 6.3 KB |
v22-0003-Synopsis-for-all-option.patch | application/octet-stream | 1.5 KB |
v22-0002-Fetch-databases-from-publisher.patch | application/octet-stream | 4.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Rahila Syed | 2025-03-26 10:34:17 | Re: Enhancing Memory Context Statistics Reporting |
Previous Message | Ajin Cherian | 2025-03-26 10:15:26 | Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state |