Re: Recent MemSet change to DirectFunctionCall1 - Mailing list pgsql-patches

From Tom Lane
Subject Re: Recent MemSet change to DirectFunctionCall1
Date
Msg-id 27389.1042095698@sss.pgh.pa.us
Whole thread Raw
In response to Recent MemSet change to DirectFunctionCall1  (Mark Halliwell <mark@transportservices.com.au>)
List pgsql-patches
Mark Halliwell <mark@transportservices.com.au> writes:
> I recently upgraded from 7.2.1 to 7.3 and found that one of my triggers
> stopped working; it would report:
> ERROR:  TIMESTAMP(-1073746888) precision must be between 0 and 6
> The trigger is used to set the time a record changes and does the following
> call:
> DirectFunctionCall1(timestamp_in, CStringGetDatum("now"));
> (My trigger was based upon the code in contrib/spi/moddatetime.c)

This trigger is in error, as is moddatetime.c (I will fix the latter).
If you call a system function, it is up to you to call it with the
appropriate parameter list.

> ! #define PG_GETARG_DATUM(n)     (fcinfo->arg[n])
> --- 167,173 ----
> ! #define PG_GETARG_DATUM(n)       (n >= fcinfo->nargs ? NULL:fcinfo->arg[n])

This is certainly not a fix.  NULL is not even a valid value for
non-pointer argument types, and for those that are pointers, it would
mean instant core dump...

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: updated PITR patch
Next
From: Patrick Macdonald
Date:
Subject: Re: updated PITR patch