From: | James Harper <james(dot)harper(at)bendigoit(dot)com(dot)au> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | typmod for custom type |
Date: | 2014-02-16 08:12:15 |
Message-ID: | 6035A0D088A63A46850C3988ED045A4B6F3A615D@BITCOM1.int.sbss.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have created a custom type called my_numeric, which is roughly the same as the existing numeric type. I have declared in, out, typmod_in, and typmod_out functions. I create a table like:
CREATE TABLE test (col1 my_numeric(6, 3));
And then do \d test and can see that col1 is declared as (6, 3), which I think confirms that my typmod_in and typmod_out function are correct.
But when I do:
INSERT INTO test VALUES ('12.34');
It behaves as though the typmod parameter to my in function (PG_GETARG_INT32(2)) is passed in as -1. The docs (http://www.postgresql.org/docs/9.3/static/sql-createtype.html) says of the arguments that "the third is the typmod of the destination column, if known (-1 will be passed if not).".
Am I doing something wrong? Don't I need to know the typmod of the destination column so I can confirm that the format of the string being passed in conforms to the type modifier specified (eg so I can reject '1234.5678' for col1 with an overflow error)?
Thanks
James
From | Date | Subject | |
---|---|---|---|
Next Message | Rémi Cura | 2014-02-16 10:38:48 | Toast and slice of toast |
Previous Message | John R Pierce | 2014-02-16 02:44:14 | Re: Restore postgresql data directory to tablespace on new host? Or swap tablespaces? |