[PATCH] Preserve keyword headers on input validation errors

From: djka 66jsda <kjadasad(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] Preserve keyword headers on input validation errors
Date: 2026-10-23 02:01:52
Message-ID: CAHNJ3aCeeWaEF-F6_9MPKX_8_qrDr-FWnabkBD2LZUEdsjvWxg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

src/tools/gen_keywordlist.pl opens and writes its output header before
checking keyword case and ordering. An uppercase, duplicate, or out-of-order
keyword therefore causes the command to fail after truncating a previously
valid header. If no output exists, the command leaves a partial new header.

The attached patch moves output creation and the opening boilerplate after
the existing validation. It does not change keyword parsing, validation
rules, or the generated format. It covers these input validation errors;
it does not make output replacement atomic for later generation or I/O errors.

The patch is based on master at
f52d405113c83f691fffac261bfec297209c21b4.

A standalone regression script is attached separately. Run it against
either the original or patched tree with:

perl check-keyword-output.pl /path/to/postgres/src/tools/gen_keywordlist.pl

Validation:
- On Windows (Git for Windows Perl 5.36.1) and Linux/WSL (Perl 5.34.0),
the original fails 6 of 16 assertions; the patch passes all 16. The
failing assertions cover preserving an existing header and avoiding a
partial new header for each of the three invalid inputs. Valid input
and uppercase keywords with --no-case-fold also remain supported.
- On Windows, outputs from the SQL, ECPG C, ECPG, and both PL/pgSQL keyword
lists are byte-identical before and after, using their build options.
- Perl syntax checks on both platforms and patch application checks pass.

The standalone regression is not wired into PostgreSQL's test suite.
No PostgreSQL server build or full regression run is claimed for this patch.

This was first reported downstream in IvorySQL; the maintainer requested
an upstream submission:
https://github.com/IvorySQL/IvorySQL/pull/2839#issuecomment-6354402538

The patch and validation were prepared with assistance from OpenAI Codex.

Would this small change be appropriate?

Attachment Content-Type Size
check-keyword-output.pl text/plain 1.8 KB
v1-preserve-keyword-output.patch text/x-patch 2.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-10-23 02:23:29 Re: Publication of same parent table with ONLY-ness mismatch should error
Previous Message Chao Li 2026-10-23 01:59:36 Re: Incremental backup can use a summary past a timeline switch