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.
--
Justin