Skip site navigation (1) Skip section navigation (2)

Re: BUG #3841: core dump in uuid-ossp

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dmitriy <im(at)ionflux(dot)ru>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3841: core dump in uuid-ossp
Date: 2007-12-27 19:40:44
Message-ID: 20071227194044.GP5709@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-bugs
Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> >     if (err != NULL)
> >         ereport(ERROR,
> >                 (errmsg("OSSP uuid failure: %s", err)));
> >     else
> >         ereport(ERROR,
> >                 (errmsg("OSSP uuid failure: error code %d", rc)));
> 
> Maybe "OSSP uuid library failure"?  Otherwise seems OK.

Sold.

> > Alternatively we could pass the called function name into
> > pguuid_complain, but I'm not sure it's worth the trouble (what does it
> > give the user, anyway?)
> 
> Probably not much, if the uuid_error() strings are well written.

char *uuid_error(uuid_rc_t rc)
{
    char *str;

    switch (rc) {
        case UUID_RC_OK:  str = "everything ok";    break;
        case UUID_RC_ARG: str = "invalid argument"; break;
        case UUID_RC_MEM: str = "out of memory";    break;
        case UUID_RC_SYS: str = "system error";     break;
        case UUID_RC_INT: str = "internal error";   break;
        case UUID_RC_IMP: str = "not implemented";  break;
        default:          str = NULL;               break;
    }
    return str;
}


> Can we throw some more specific SQLSTATE than the default "internal
> error" here?  Offhand I can't think of anything, but as a rule of
> thumb an ereport() ought to have an errcode().  If it really is an
> internal error then elog() is good enough.

Hmm.  I looked at the extant list, and found that the contrib/xml2 code
uses ERRCODE_EXTERNAL_ROUTINE_EXCEPTION whereas pgcrypto uses
ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION.

In passing, I noticed the use of xml_ereport and xml_ereport_by_code in
the core XML code, and I'm left wondering whether we shouldn't add them
to the list of gettext triggers in nls.mk.  Also some messages there are
marked with ERRCODE_INTERNAL_ERROR.  (PLy_elog too?)

(Sorry, totally unrelated:) Wow, in plpython.c there is this:

static void *
PLy_malloc(size_t bytes)
{
    void       *ptr = malloc(bytes);

    if (ptr == NULL)
        ereport(FATAL,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory")));
    return ptr;
}

I wonder why is it a good idea to have this report be FATAL.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

pgsql-bugs by date

Next:From: Simon RiggsDate: 2007-12-27 20:20:01
Subject: Re: BUG #3843: archiver process is restarted after thesmart shutdown
Previous:From: Tom LaneDate: 2007-12-27 18:51:11
Subject: Re: BUG #3841: core dump in uuid-ossp

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group