Re: [Proposal] vacuumdb --schema only

From: Gilles Darold <gilles(at)migops(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [Proposal] vacuumdb --schema only
Date: 2022-03-07 07:38:04
Message-ID: 93ff0677-518e-3ff4-5235-13c586c3b9dc@migops.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
0001-vacuumdb-schema-only-v3.patch text/x-patch 11.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2022-03-07 07:40:44 Re: Handle infinite recursion in logical replication setup
Previous Message kuroda.hayato@fujitsu.com 2022-03-07 07:37:46 RE: Handle infinite recursion in logical replication setup