pgsql: Improve generate_partition_qual()'s cache handling on out-of-mem

Started by Michael Paquier4 months ago1 messagescommitters
Jump to latest
#1Michael Paquier
michael@paquier.xyz

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 <exclusion@gmail.com>
Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: /messages/by-id/95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com

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(-)