Re: Cleanup: Replace sscanf with strtol/strtoul in snapmgr
Andreas Karlsson <andreas@proxel.se>
From: Andreas Karlsson <andreas@proxel.se>
To: Amul Sul <sulamul@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-01T08:08:45Z
Lists: pgsql-hackers
On 4/20/26 07:06, Amul Sul wrote: > The attached patch replaces sscanf with strtol and strtoul in the > ImportSnapshot helpers (parseIntFromText, parseXidFromText, and > parseVxidFromText) to improve reliability and efficiency. By utilizing > the end pointer, we can locate the next line without re-scanning the > entire string. > > Additionally, this change aligns the snapshot code with the rest of > the Postgres backend, which already favors these functions for safer > parsing. I personally prefer this safer and easier to verify parsing so from me this is a +1. I also reviewed the patch and it is simple, looks like it handles errors correctly and matches code we have in other parts of our code so I am all for merging it in its current shape. It also preserves the old behavior of ignoring random stuff at the end of each line, for good and bad. Looks good to me! Andreas