]> granicus.if.org Git - postgresql/commit
Add safeguards in LSN, numeric and float calculation for custom errors
authorMichael Paquier <michael@paquier.xyz>
Mon, 5 Aug 2019 06:35:16 +0000 (15:35 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 5 Aug 2019 06:35:16 +0000 (15:35 +0900)
commita76cfba663ceab79b891cc81a5f941051755b3b0
tree9aaaf52bc2d59eb507d4562ec5f9e6c039122809
parent05ba8370b8e4b5c8f3dd51986b9fdeb43fed5610
Add safeguards in LSN, numeric and float calculation for custom errors

Those data types use parsing and/or calculation wrapper routines which
can generate some generic error messages in the event of a failure.  The
caller of these routines can also pass a pointer variable settable by
the routine to track if an error has happened, letting the caller decide
what to do in the event of an error and what error message to generate.

Those routines have been slacking the initialization of the tracking
flag, which can be confusing when reading the code, so add some
safeguards against calls of these parsing routines which could lead to a
dubious result.

The LSN parsing gains an assertion to make sure that the tracking flag
is set, while numeric and float paths initialize the flag to a saner
state.

Author: Jeevan Ladhe
Reviewed-by: Álvaro Herrera, Michael Paquier
Discussion: https://postgr.es/m/CAOgcT0NOM9oR0Hag_3VpyW0uF3iCU=BDUFSPfk9JrWXRcWQHqw@mail.gmail.com
src/backend/utils/adt/float.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/pg_lsn.c