On Wed, Sep 21, 2016 at 10:25 AM, Michael Paquier
<michael.paqu...@gmail.com> wrote:
> On Wed, Sep 21, 2016 at 12:32 AM, Robert Haas <robertmh...@gmail.com> wrote:
>> For what it's worth, I think it's fine.  Good error messages are a useful 
>> thing.
>> More generally, I think the whole patch looks good and should be committed.
> Hm. I'd think that it is still more portable to just issue a WARNING
> message in palloc_extended() when MCXT_ALLOC_NO_OOM then. Other code
> paths could benefit from that as well, and the patch proposed does
> nothing for the other places calling it. I am fine to write a patch
> for this purpose if you agree on that.

Or in short the attached. All the other callers of palloc_extended
benefit from that.
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 5cf388f..52b9c1b 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -973,6 +973,10 @@ palloc_extended(Size size, int flags)
                                         errmsg("out of memory"),
                                         errdetail("Failed on request of size 
%zu.", size)));
+               ereport(WARNING,
+                               (errcode(ERRCODE_OUT_OF_MEMORY),
+                                errmsg("out of memory"),
+                                errdetail("Failed on request of size %zu.", 
                return NULL;
diff --git a/src/common/fe_memutils.c b/src/common/fe_memutils.c
index 58c5c4c..0d44ef6 100644
--- a/src/common/fe_memutils.c
+++ b/src/common/fe_memutils.c
@@ -30,9 +30,9 @@ pg_malloc_internal(size_t size, int flags)
        tmp = malloc(size);
        if (tmp == NULL)
+               fprintf(stderr, _("could not allocate %zu bytes of memory\n"), 
                if ((flags & MCXT_ALLOC_NO_OOM) == 0)
-                       fprintf(stderr, _("out of memory\n"));
                return NULL;
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to