Обсуждение: pgsql: Improve error message for snapshot import in snapmgr.c, take two

Поиск
Список
Период
Сортировка

pgsql: Improve error message for snapshot import in snapmgr.c, take two

От
Michael Paquier
Дата:
Improve error message for snapshot import in snapmgr.c, take two

When a snapshot file fails to be read in ImportSnapshot(), it would
issue an ERROR as "invalid snapshot identifier" when opening a stream
for it in read-only mode.  The error handling is improved to be more
talkative in failure cases:
- If a snapshot identifier uses incorrect characters, complain with the
same error as before this commit.
- If the snapshot file cannot be found in pg_snapshots/, complain with a
"snapshot \"foo\" does not exist" instead.  This maps to the case where
AllocateFile() fails on ENOENT.  Based on a suggestion from Andres
Freund.
- If AllocateFile() throws something else than ENOENT as errno, report
it with more details in %m instead, as these failures are never
expected.

b29504eeb489 was the first improvement take.  The older error message
exists since bb446b689b66 that introduced snapshot imports.  Two test
cases are added to cover the cases of an identifier with an incorrect
format and of a missing snapshot.

Author: Bharath Rupireddy
Reviewed-by: Andres Freund, Daniel Gustafsson, Michael Paquier
Discussion: https://postgr.es/m/CALj2ACWmr=3KdxDkm8h7Zn1XxBoF6hdzq8WQyMn2y1OL5RYFrg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/78a33bba4c634afc3c67dddeb359b5ce872a0b04

Modified Files
--------------
src/backend/utils/time/snapmgr.c           | 18 +++++++++++++++---
src/test/regress/expected/transactions.out | 11 +++++++++++
src/test/regress/sql/transactions.sql      |  9 +++++++++
3 files changed, 35 insertions(+), 3 deletions(-)