Re: [Proposal] vacuumdb --schema only - Mailing list pgsql-hackers

From Gilles Darold
Subject Re: [Proposal] vacuumdb --schema only
Date
Msg-id 93ff0677-518e-3ff4-5235-13c586c3b9dc@migops.com
Whole thread Raw
In response to Re: [Proposal] vacuumdb --schema only  (Justin Pryzby <pryzby@telsasoft.com>)
Responses Re: [Proposal] vacuumdb --schema only  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
Le 06/03/2022 à 16:04, Justin Pryzby a écrit :
> On Sun, Mar 06, 2022 at 09:39:37AM +0100, Gilles Darold wrote:
>> Attached a new patch version that adds the -N | --exclude-schema option
>> to the vacuumdb command as suggested. Documentation updated too.
>>
>> +        pg_log_error("cannot vacuum all tables in schema(s) and and exclude specific schema(s) at the same time");
> and and
>
> It's odd that schema_exclusion is a global var, but schemas/excluded are not.
>
> Also, it seems unnecessary to have two schemas vars, since they can't be used
> together.  Maybe there's a better way than what I did in 003.
>
>> +        for (cell = schemas ? schemas->head : NULL; cell; cell = cell->next)
> It's preferred to write cell != NULL
>
>> +       bool            schemas_listed = false;
> ...
>> +        for (cell = schemas ? schemas->head : NULL; cell; cell = cell->next)
>> +        {
>> +            if (!schemas_listed) {
>> +                appendPQExpBufferStr(&catalog_query,
>> +                                     " AND pg_catalog.quote_ident(ns.nspname)");
>> +                if (schema_exclusion)
>> +                    appendPQExpBufferStr(&catalog_query, " NOT IN (");
>> +                else
>> +                    appendPQExpBufferStr(&catalog_query, " IN (");
>> +
>> +                schemas_listed = true;
>> +            }
>> +            else
>> +                appendPQExpBufferStr(&catalog_query, ", ");
>> +
>> +            appendStringLiteralConn(&catalog_query, cell->val, conn);
>> +            appendPQExpBufferStr(&catalog_query, "::pg_catalog.regnamespace::pg_catalog.name");
>> +
>> +        }
>> +        /* Finish formatting schema filter */
>> +        if (schemas_listed)
>> +            appendPQExpBufferStr(&catalog_query, ")\n");
>>      }
> Maybe it's clearer to write this with =ANY() / != ALL() ?
> See 002.
>

I have applied your changes and produced a new version v3 of the patch,
thanks for the improvements. The patch have been added to commitfest
interface, see here https://commitfest.postgresql.org/38/3587/


-- 
Gilles Darold

Attachment

pgsql-hackers by date:

Previous
From: "kuroda.hayato@fujitsu.com"
Date:
Subject: RE: Handle infinite recursion in logical replication setup
Next
From: Dilip Kumar
Date:
Subject: Re: Handle infinite recursion in logical replication setup