Thread

  1. Strangeness/bug when working with my own datatype in PostgreSQL

    KS <ks@tcnet.ru> — 2001-02-24T23:47:26Z

    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.
    
    
  2. Re: Strangeness/bug when working with my own datatype in PostgreSQL

    Tom Lane <tgl@sss.pgh.pa.us> — 2001-02-25T04:36:54Z

    =?KOI8-R?Q?=F3=CF=CC=CF=C4=CF=D7=CE=C9=CB=CF=D7_=EB=CF=CE=D3=D4=C1?= =?KOI8-R?Q?=CE=D4=C9=CE?= <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