Improve generate_partition_qual()'s cache handling on out-of-memory errors

An in-flight failure when trying to set rd_partcheckcxt or
rd_partcheck, while for example doing an allocation in copyObject(),
would leave a backend cache in a corrupted state.  The operations are
now ordered so as we avoid a leak in the cache memory context and a
semi-filled cache state when an allocation failure happens.

This is unlikely going to be hit in practice.  Like the other
improvements of this kind, no backpatch is done.

Reported-by: Alexander Lakhin <[email protected]>
Author: Matthias van de Meent <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fc6425fbe7a1fc7458fc27060ec78c5d98757690

Modified Files
--------------
src/backend/utils/cache/partcache.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)

Reply via email to