From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Gilles Darold <gilles(at)migops(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [Proposal] vacuumdb --schema only |
Date: | 2022-03-06 15:04:17 |
Message-ID: | 20220306150417.GO27651@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
0001-vacuumdb-schema-only.patch | text/x-diff | 12.5 KB |
0002-f1.patch | text/x-diff | 3.1 KB |
0003-f2.patch | text/x-diff | 4.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2022-03-06 15:19:39 | Re: role self-revocation |
Previous Message | Andrew Dunstan | 2022-03-06 12:46:04 | Re: ltree_gist indexes broken after pg_upgrade from 12 to 13 |