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

From Justin Clift
Subject Re: macaddr data type issue
Date
Msg-id 3B829783.5A764E5D@postgresql.org
Whole thread Raw
In response to macaddr data type issue  (Gayland Gump <gumpg@pacifier.com>)
Responses Re: macaddr data type issue  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi Gayland,

What you're attempting to insert is being interpreted as the NULL value
:

techdocs=> create table foo (bar macaddr);
CREATE
testdb=> insert into foo values ('00:00:00:00:00:00');
INSERT 75485253 1
testdb=> insert into foo values ('00:00:00:00:00:01');
INSERT 75485256 1
testdb=> insert into foo values ('000000-000000');
INSERT 75485258 1
testdb=> insert into foo values ('000000-000001');
INSERT 75485261 1
testdb=> insert into foo values (NULL);
INSERT 75485269 1
testdb=> select * from foo;
        bar
-------------------

 00:00:00:00:00:01

 00:00:00:00:00:01

(5 rows)

testdb=>

You can probably use the NULL values (or your 000000-000000 value) as a
placeholder/"missing data" marker.

Does this help?

:-)

Regards and best wishes,

Justin Clift


Gayland Gump wrote:
>
> Hi,
>
> I am looking for some confirmation and perhaps some explanation of and for
> the following observation.  If I use "000000-000000" as input to a
> macaddr data type element in my database no value appears to be stored.  I
> was intending to use this value as a "missing data" marker in my
> application.  I've looked for documentation high and low but haven't been
> able to find anything regarding this behavior.  I did stumble upon some
> source code, which I believe is relevant, which suggests that the code's
> author was planning for a "missing value's" value.  Unfortunately, the
> macaddr data type output function does not seem to produce the
> "00:00:00:00:00:00" string that I would expect.
>
> It seems to me that if I were to input and the database would accept
> "000000-000000" as indicative of missing values that the database should
> output such a value when it is encountered in a dataset.  At very least,
> it would seem that some additional documentation might be warranted. I
> suspect I am missing something here.  Can anyone offer confirmation of
> this behavior and an explanation for, what seems to me to be, this
> counter-intuitive behavior?
>
> Thanks for your time and effort on my behalf.
>
> Gayland
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
   - Indira Gandhi

pgsql-general by date:

Previous
From: Adrian Phillips
Date:
Subject: Re: DBI placeholders
Next
From: "Brent R. Matzelle"
Date:
Subject: Re: New RPMS ?