Re: macaddr data type issue - Mailing list pgsql-general

From Tom Lane
Subject Re: macaddr data type issue
Date
Msg-id 9915.998419183@sss.pgh.pa.us
Whole thread Raw
In response to Re: macaddr data type issue  (Justin Clift <justin@postgresql.org>)
Responses Re: macaddr data type issue
Re: macaddr data type issue
List pgsql-general
Justin Clift <justin@postgresql.org> writes:
> What you're attempting to insert is being interpreted as the NULL value

Actually, it's not NULL.  The curious behavior comes from a test in the
macaddr_out routine that causes it to produce an empty-string display if
the MAC address is all zeroes:

    if ((hibits(addr) > 0) || (lobits(addr) > 0))
    {
        sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
                addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
    }
    else
    {
        result[0] = '\0';        /* special case for missing address */
    }

This seems a tad bizarre to me, if not an outright bug.  The right,
SQL-approved way to represent "missing data" is as a NULL; there's no
rationale I can see for treating an all-zeroes address like this.

There's also a special case in macaddr_in that accepts an empty input
string as meaning an all-zeroes address.  This seems bogus as well.

I'm inclined to rip out both special cases, so that an all-zeroes MAC
address is handled exactly like any other address.  Comments?

            regards, tom lane

pgsql-general by date:

Previous
From: "Brent R. Matzelle"
Date:
Subject: Re: New RPMS ?
Next
From: Jason Earl
Date:
Subject: Re: time interval question