Re: [Proposal] vacuumdb --schema only

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Gilles Darold <gilles(at)migops(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [Proposal] vacuumdb --schema only
Date: 2022-04-20 17:40:52
Message-ID: 20220420174052.GA10057@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 20, 2022 at 10:38:46AM -0700, Nathan Bossart wrote:
> > +void
> > +check_objfilter(VacObjectFilter curr_objfilter, VacObjectFilter curr_option)
> > +{
> > + switch (curr_option)
> > + {
> > + case OBJFILTER_NONE:
> > + break;
> > + case OBJFILTER_DATABASE:
> > + /* When filtering on database name, vacuum on all database is not allowed. */
> > + if (curr_objfilter == OBJFILTER_ALL)
> > + pg_fatal("cannot vacuum all databases and a specific one at the same time");
> > + break;
> > + case OBJFILTER_ALL:
> > + /* When vacuuming all database, filter on database name is not allowed. */
> > + if (curr_objfilter == OBJFILTER_DATABASE)
> > + pg_fatal("cannot vacuum all databases and a specific one at the same time");
> > + /* When vacuuming all database, filter on schema name is not allowed. */
> > + if (curr_objfilter == OBJFILTER_SCHEMA)
> > + pg_fatal("cannot vacuum specific schema(s) in all databases");
> > + /* When vacuuming all database, schema exclusion is not allowed. */
> > + if (curr_objfilter == OBJFILTER_SCHEMA_EXCLUDE)
> > + pg_fatal("cannot exclude from vacuum specific schema(s) in all databases");
> > + /* When vacuuming all database, filter on table name is not allowed. */
> > + if (curr_objfilter == OBJFILTER_TABLE)
> > + pg_fatal("cannot vacuum specific table(s) in all databases");
> > + break;
> > + case OBJFILTER_TABLE:
> > + /* When filtering on table name, filter by schema is not allowed. */
> > + if (curr_objfilter == OBJFILTER_SCHEMA)
> > + pg_fatal("cannot vacuum all tables in schema(s) and specific table(s) at the same time");
> > + /* When filtering on table name, schema exclusion is not allowed. */
> > + if (curr_objfilter == OBJFILTER_SCHEMA_EXCLUDE)
> > + pg_fatal("cannot vacuum specific table(s) and exclude specific schema(s) at the same time");
> > + break;
> > + case OBJFILTER_SCHEMA:
> > + /* When filtering on schema name, filter by table is not allowed. */
> > + if (curr_objfilter == OBJFILTER_TABLE)
> > + pg_fatal("cannot vacuum all tables in schema(s) and specific table(s) at the same time");
> > + /* When filtering on schema name, schema exclusion is not allowed. */
> > + if (curr_objfilter == OBJFILTER_SCHEMA_EXCLUDE)
> > + pg_fatal("cannot vacuum all tables in schema(s) and exclude specific schema(s) at the same time");
> > + /* filtering on schema name can not be use on all database. */
> > + if (curr_objfilter == OBJFILTER_ALL)
> > + pg_fatal("cannot vacuum specific schema(s) in all databases");
> > + break;
> > + case OBJFILTER_SCHEMA_EXCLUDE:
> > + /* When filtering on schema exclusion, filter by table is not allowed. */
> > + if (curr_objfilter == OBJFILTER_TABLE)
> > + pg_fatal("cannot vacuum all tables in schema(s) and specific table(s) at the same time");
> > + /* When filetring on schema exclusion, filter by schema is not allowed. */
> > + if (curr_objfilter == OBJFILTER_SCHEMA)
> > + pg_fatal("cannot vacuum all tables in schema(s) and exclude specific schema(s) at the same time");
> > + break;
> > + }
> > +}
>
> I don't think this handles all combinations. For example, the following
> command does not fail:
>
> vacuumdb -a -N test postgres
>
> Furthermore, do you think it'd be possible to dynamically generate the
> message?

Not in the obvious way, because that breaks translatability.

--
Justin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2022-04-20 17:43:57 Re: [Proposal] vacuumdb --schema only
Previous Message Nathan Bossart 2022-04-20 17:38:46 Re: [Proposal] vacuumdb --schema only