Re: [Proposal] vacuumdb --schema only - Mailing list pgsql-hackers
From | Justin Pryzby |
---|---|
Subject | Re: [Proposal] vacuumdb --schema only |
Date | |
Msg-id | 20220420174052.GA10057@telsasoft.com Whole thread Raw |
In response to | Re: [Proposal] vacuumdb --schema only (Nathan Bossart <nathandbossart@gmail.com>) |
Responses |
Re: [Proposal] vacuumdb --schema only
|
List | 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
pgsql-hackers by date: