Improve OOM handling in pg_locale.c - Mailing list pgsql-hackers

From Michael Paquier
Subject Improve OOM handling in pg_locale.c
Date
Msg-id CAB7nPqRMbGqa_mesopcn4MPyTs34eqtVEK7ELYxvvV=oqS00YA@mail.gmail.com
Whole thread Raw
Responses Re: Improve OOM handling in pg_locale.c  (Haribabu Kommi <kommi.haribabu@gmail.com>)
Re: Improve OOM handling in pg_locale.c  (Mithun Cy <mithun.cy@enterprisedb.com>)
List pgsql-hackers
Hi all,

This is a follow-up of
https://www.postgresql.org/message-id/11202.1472597262%40sss.pgh.pa.us
where we are looking at improving OOM handling in the code. In short,
report an ERROR appropriately instead of crashing. As mentioned in
this message, pg_locale.c is trickier to handle because we had better
not call elog() in a code path where the backend's locale are not set
up appropriately. Attached is a patch aimed at fixing that, doing the
following:
- Copy into a temporary struct lconv the results from the call of
localeconv() as those can be overwritten when restoring back the
locales with setlocale().
- Use db_encoding_strdup to encode that correctly.
- Switch back to the backend locales
- Check for any strdup calls that returned NULL and elog()
- If no error, fill in CurrentLocaleConv and return back to caller.

I am attaching that to the next CF.
Thanks,
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Mithun Cy
Date:
Subject: Re: Patch: Implement failover on libpq connect level.
Next
From: Michael Paquier
Date:
Subject: Re: pg_dump, pg_dumpall and data durability