| From: | Quan Zongliang <quanzongliang(at)yeah(dot)net> |
|---|---|
| To: | Mohamed ALi <moali(dot)pg(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] vacuumdb: Add --exclude-database option |
| Date: | 2026-06-05 09:25:52 |
| Message-ID: | 265ba292-df58-417a-a542-f9918c17e255@yeah.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 5/16/26 12:47 AM, Mohamed ALi wrote:
> Hi hackers,
>
> Attached is a patch that adds --exclude-database (-D) to vacuumdb,
> allowing users to skip specific databases when using --all.
>
> Motivation
> ----------
>
> "vacuumdb --all" vacuums every connectable database without exception.
> In production environments, operators often need to skip certain databases
> during maintenance — for example, test databases, large inactive databases
> with historical data.
> The current workaround is to manually vacuum each database
> individually or write wrapper scripts.
>
The parameter "D and d(dname)" conforms to the usage of "N and n."
Adhering to the original definition, this is fine.
In the vacuum_all_databases function. If the condition 'if
(dbsToExclude)' is used. All 'exclude-database' processing (including
variable definitions) can be placed in a separate code block. How about
this? Irrelevant personal preferences.
--
Quan Zongliang
> Usage
> -----
>
> vacuumdb --all --exclude-database=test_db
> vacuumdb --all -D db1 -D db2 -D db3
>
> The option requires --all
>
> Testing
> -------
>
> The patch passes all existing vacuumdb TAP tests (100_vacuumdb,
> 101_vacuumdb_all, 102_vacuumdb_stages) and includes 4 new TAP tests
> in 101_vacuumdb_all.pl covering exclusion, multiple exclusions, and
> error cases.
>
> I've also attached a standalone test script (test_exclude_database.sh)
> that exercises the feature with 11 test scenarios:
>
> 1. Single database exclusion
> 2. Multiple database exclusions (-D db1 -D db2)
> 3. Exclude all databases
> 4. Exclude non-existent database (silently ignored)
> 5. Exclude maintenance database (postgres)
> 6. Case sensitivity (exact case excludes, wrong case does not)
> 7. --exclude-database without --all (error)
> 8. --exclude-database with -d (error)
> 9. SQL injection protection
> 10. --help output
> 11. -d with -D and --all (conflicting options error)
>
> All tests pass. The test script is portable — it uses standard libpq
> environment variables and auto-detects binaries. Test output is also
> attached (test_exclude_database_results.txt).
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Masashi Kamura (Fujitsu) | 2026-06-05 09:26:01 | RE: ECPG: inconsistent behavior with the document in “GET/SET DESCRIPTOR.” |
| Previous Message | Heikki Linnakangas | 2026-06-05 09:04:52 | Re: Fix domain fast defaults on empty tables |