Bug in pg_dump --filter? - Invalid object types can be misinterpreted as valid
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-08-02T09:47:42Z
Lists: pgsql-hackers
Attachments
- v1-0001-pg_dump-Fix-incorrect-parsing-of-object-types-in-.patch (application/octet-stream) patch v1-0001
Hi, It looks like pg_dump --filter can mistakenly treat invalid object types in the filter file as valid ones. For example, the invalid type "table-data" (probably a typo for "table_data") is incorrectly recognized as "table", and pg_dump runs without error when it should fail. -------------------------------------------- $ cat filter.txt exclude table-data one $ pg_dump --filter filter.txt -- -- PostgreSQL database dump -- ... $ echo $? 0 -------------------------------------------- This happens because pg_dump (filter_get_keyword() in pg_dump/filter.c) identifies tokens as sequences of ASCII alphabetic characters, treating non-alphabetic characters (like hyphens) as token boundaries. As a result, "table-data" is parsed as "table". To fix this, I've attached the patch that updates pg_dump --filter so that it treats tokens as strings of non-space characters separated by spaces or line endings, ensuring invalid types like "table-data" are correctly rejected. Thought? With the patch: -------------------------------------------- $ cat filter.txt exclude table-data one $ pg_dump --filter filter.txt pg_dump: error: invalid format in filter read from file "filter.txt" on line 1: unsupported filter object type: "table-data" -------------------------------------------- Regards, -- Fujii Masao
Commits
-
pg_dump: Fix incorrect parsing of object types in pg_dump --filter.
- 7dafc4a413f4 17.6 landed
- e3764229e6bd 18.0 landed
- 85ccd7e30a6d 19 (unreleased) landed