On Tue, Nov 17, 2026 at 6:23 PM Chao Li <[email protected]> wrote:
>
>
>
> > On Nov 18, 2026, at 02:27, Haibo Yan <[email protected]> wrote:
> >
> > Hi Chao,
> >
> > Thanks for reviewing. I haven't found a case where normal writes or
> > a crash left an embedded NUL in pg_stash_advice.tsv. The writer uses a
> > temporary file and durable_rename(), and SQL text input rejects NUL
> > even with SQL_ASCII. I inserted the NUL by hand for the test.
> >
> > Other byte changes can go undetected. NUL is worth checking because
> > the loader mistakes it for EOF, reports success, and can discard the
> > remaining records on the next save.
> >
> > Best regards,
> > Haibo
>
> If this is defensive handling of a manually corrupted file, then the same 
> concern may apply to many other text file readers. In that case, instead of 
> adding a check specifically for the stash file, maybe a better way is to add 
> a generic text file reader to handle all possible errors in a single place.
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
Hi Chao,

Thanks for the suggestion. A shared helper could make sense if several
readers need the same checks. Some parsers can detect NUL as they parse,
so I'd avoid requiring a separate scan in a generic reader.

The stash loader already reads the whole file into memory. A memchr()
check on that buffer prevents it from treating an embedded NUL as EOF
and accepting just the prefix. I'd keep the check here for now and
revisit sharing it once we have another reader with the same needs.

Best regards,
Haibo


Reply via email to