Cleanup: Replace sscanf with strtol/strtoul in snapmgr

From: Amul Sul <sulamul(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Cleanup: Replace sscanf with strtol/strtoul in snapmgr
Date: 2026-04-20 05:06:21
Message-ID: CAAJ_b97mG=6ybUYE8nQyDfKkhaxTCD8rE8s6L8efNmqHaUYNWQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

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.

--
Regards,
Amul Sul
EDB: http://www.enterprisedb.com

Attachment Content-Type Size
0001-snapmgr-replace-sscanf-with-strtol-strtoul-in-snapsh.patch application/x-patch 4.1 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2026-04-20 05:25:43 Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value)
Previous Message vignesh C 2026-04-20 05:04:47 Re: EXCEPT TABLE - Case inconsistency for describe \d and \dRp+