Thread: interval->day AdjustIntervalForTypmod?
I've been making a bit of progress on adding a day field to the Interval struct (thanks to the help of this list and the find folks on IRC). Selects and basic math seem to be working, and the code is passing more regression tests than it was before. I'm running into a bit of a problem with storing the data in relations. For example: test=# select '1 year 13 mons 2 days 26:03'::interval; interval ------------------------------- 2 years 1 mon 2 days 26:03:00 (1 row) test=# create table interval_tbl (f1 interval); CREATE TABLE test=# insert into interval_tbl (f1) values ('1 year 13 mons 2 days 26:03'::interval); INSERT 0 1 test=# select * from interval_tbl; f1 ----------------- 2 days 26:03:00 (1 row) It appears that the data isn't being stored properly. I think I need to make adjustments to AdjustIntervalForTypmod() in timestamp.c, but I could very easily be wrong. I'm unfamiliar with what this code is supposed to do and typmods in general. I've searched the mailing lists for hints but haven't found anything that has appeared particularly helpful. Would someone be able to give me a bit of background on typmod (and possibly related information) or suggest where I might find more information? Thanks for any assistance. Michael Glaesemann grzm myrealbox com
Michael Glaesemann <grzm@myrealbox.com> writes: > I've been making a bit of progress on adding a day field to the > Interval struct (thanks to the help of this list and the find folks > on IRC). Selects and basic math seem to be working, and the code is > passing more regression tests than it was before. > I'm running into a bit of a problem with storing the data in > relations. For example: Hm, have you adjusted the size (typlen) shown for "interval" in pg_type? (This is of course an initdb-forcing change.) regards, tom lane
On Jun 9, 2005, at 2:35 PM, Tom Lane wrote: > Hm, have you adjusted the size (typlen) shown for "interval" in > pg_type? > (This is of course an initdb-forcing change.) No, I hadn't. I've done that now (editing pg_type.h and bumping the typlen from 12 to 16) and it appears to have fixed it! Thanks. Now on to interval_avg and friends. I am still curious about AdjustIntervalForTypmod, if someone could fill me in, I'm all ears. Thanks, Tom, for the pointer! Michael Glaesemann grzm myrealbox com