Thread: Strangeness/bug when working with my own datatype in PostgreSQL

Strangeness/bug when working with my own datatype in PostgreSQL

From
Солодовников Константин
Date:
Good time of day!

I've got some strangeness/bug when working with my own datatype in
PostgreSQL.
Here's a short description of the sitiation:

I've developed a 1-byte integer datatype (let's call it "int1").
The input and output functions for this datatype I wrote myself.

Everything works just fine except for the following:

I create a table "test_int1" with two columns "i4" and "i1" of type "int4"
and "int1" respectively.
When I insert a new row into this table without providing a value for the
"i1" column, I get a value of "45" in it.
The column doesn't have any default values. Neither it has "not null" option
set.
If I explicitly provide a NULL value for this column in an insertion
statement, I get what I expect - a NULL value for the column.
Not-supplying a value for any original PGSQL datatype (say, "int4") also
makes it correctly - I see a NULL value.

Any comments/suggestions?
I have PostgreSQL 7.0.3 on FreeBSD 4.2-STABLE.

Best regards.

Konstantin Solodovnikov.


Re: Strangeness/bug when working with my own datatype in PostgreSQL

From
Tom Lane
Date:
Солодовников Константин <ks@tcnet.ru> writes:
> When I insert a new row into this table without providing a value for the
> "i1" column, I get a value of "45" in it.

Seems odd to me too; it should default to NULL if no value is specified
or available from a DEFAULT clause.  Can't guess why you're seeing a
problem without more details, though.  Could you show us the code you
used to define your datatype?
        regards, tom lane