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 =3D DirectFunctionCall3(timestamp_in,
CStringGetDatum("now"),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(0));
=20=20=20=20
Datum interv =3D DirectFunctionCall3(interval_in,
CStringGetDatum("7 Days"),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(0));
=20=20=20=20
Datum tnow_pl_interval =3D DirectFunctionCall2(timestamp_pl_span,
tnow,
interv);
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
text *ptext =3D DatumGetTextP(DirectFunctionCall1(textin, DirectFunctionCa=
ll1(timestamp_out,tnow_pl_interval)));
if (ptext =3D=3D NULL)
PG_RETURN_NULL();
PG_RETURN_TEXT_P(ptext);
}
When called such as:
Bugs=3D> 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=3D> 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:=20
"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