From: | Shubham Khanna <khannashubham1197(at)gmail(dot)com> |
---|---|
To: | vignesh C <vignesh21(at)gmail(dot)com> |
Cc: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided. |
Date: | 2025-03-19 06:14:21 |
Message-ID: | CAHv8RjKyOQnjK7c_3UsMoPJYt=br_OOubH3Uq7h9jC=7Y0mshA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Mar 19, 2025 at 11:17 AM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> On Tue, 18 Mar 2025 at 17:34, Shubham Khanna
> <khannashubham1197(at)gmail(dot)com> wrote:
> >
> > I have added an additional test case to 040_pg_createsubscriber.pl as suggested.
> >
> > The attached patch contains the suggested changes.
>
> How about we change the below code:
> +# Verify that user databases (postgres, $db1, $db2) got subscriptions. Both
> +# $db1 and $db2 must be escaped to pass the safe_psql(), but it is difficult.
> +# Thus, we define a cursor, obtain a dbname from the instance and compere one
> +# by one.
> +my @user_dbs = ('postgres', $db1, $db2);
> +
> +my $bgconn = $node_u->background_psql('postgres');
> +$bgconn->query_safe(
> + qq[
> + BEGIN;
> + DECLARE cursor CURSOR FOR SELECT datname FROM pg_subscription,
> pg_database
> + WHERE subdbid = pg_database.oid and datistemplate = 'f'
> + ORDER BY pg_database.oid;
> +]);
> +
> +# Fetch from the cursor three times and confirm the existence of the
> +# subscription on $dbname
> +foreach my $dbname (@user_dbs)
> +{
> + my $result = $bgconn->query_safe("FETCH cursor;");
> +
> + is($result, $dbname, "subscription is created on $dbname");
> +}
>
> like:
> $result = $node_u->safe_psql($db1, 'SELECT datname FROM
> pg_subscription, pg_database WHERE subdbid = pg_database.oid and
> datistemplate = \'f\' ORDER BY pg_database.oid');
> is($result, "postgres
> $db1
> $db2", 'subscription is created on the required databases');
>
> I felt this might simplify your verification logic.
>
I agree with you on this; switching to a single query with safe_psql()
will indeed simplify the test and make the verification logic cleaner.
The attached patch contains the suggested change.
Thanks and regards,
Shubham Khanna.
Attachment | Content-Type | Size |
---|---|---|
v15-0001-Enhance-pg_createsubscriber-to-fetch-and-append-.patch | application/octet-stream | 16.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Bapat | 2025-03-19 06:31:29 | Re: Reducing memory consumed by RestrictInfo list translations in partitionwise join planning |
Previous Message | Bertrand Drouvot | 2025-03-19 05:50:28 | Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits |