From: | "Donald Fraser" <demolish(at)cwgsy(dot)net> |
---|---|
To: | "[BUGS]" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Bug in AdjustIntervalForTypmod function |
Date: | 2003-05-13 16:55:29 |
Message-ID: | 005d01c31970$790295f0$1664a8c0@DEMOLITION |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC 2.96
The following function definition:
extern Datum testDate(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(testDate);
Datum
testDate(PG_FUNCTION_ARGS)
{
Datum tnow = DirectFunctionCall3(timestamp_in,
CStringGetDatum("now"),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(0));
Datum interv = DirectFunctionCall3(interval_in,
CStringGetDatum("7 Days"),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(0));
Datum tnow_pl_interval = DirectFunctionCall2(timestamp_pl_span,
tnow,
interv);
text *ptext = DatumGetTextP(DirectFunctionCall1(textin, DirectFunctionCall1(timestamp_out,tnow_pl_interval)));
if (ptext == NULL)
PG_RETURN_NULL();
PG_RETURN_TEXT_P(ptext);
}
When called such as:
Bugs=> SELECT "testDate"();
Produces this error message:
ERROR: AdjustIntervalForTypmod(): internal coding error
Yet when I call the equivalent SQL it reports no error, such as:
Bugs=> SELECT timestamp_pl_span('now'::timestamp(0), '7 Days'::interval(0));
timestamp_pl_span
---------------------
2003-05-20 17:35:21
(1 row)
I searched through the code and found that the failure was occuring in the function:
"static void AdjustIntervalForTypmod(Interval *interval, int32 typmod)"
To get around the problem I set the type modifier for the "Interval" as "-1".
Regards
Donald Fraser
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-05-13 17:44:52 | Re: Bug in AdjustIntervalForTypmod function |
Previous Message | shaodi | 2003-05-13 06:01:01 | Bugs Report-20030513 |