Skip site navigation (1) Skip section navigation (2)

Re: Problem with DirectFunctionCall3(array_in,...)

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jessica Ditt <jessica(dot)ditt(at)web(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Problem with DirectFunctionCall3(array_in,...)
Date: 2005-04-30 15:48:26
Message-ID: 20050430154826.GA49322@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Thu, Apr 28, 2005 at 02:11:29PM +0200, Jessica Ditt wrote:
> 
> DirectFunctionCall3(array_in, CStringGetDatum(arraystring),
> ObjectIdGetDatum(20), Int32GetDatum(-1));
> 
> unfortunately smashes my postmaster... 

Running a debugger on the core dump shows a segmentation fault at
the following line in array_in() in arrayfuncs.c:

    my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;

Examining the data shows that fcinfo->flinfo is NULL; presumably
dereferencing it caused the segmentation fault.  Looking at the
code for DirectFunctionCall3() in fmgr.c, we see that it initializes
fcinfo by calling InitFunctionCallInfoData() with the second argument
set to NULL, which gets assigned to flinfo.  Apparently that's the
problem.

I don't know if the following is The Right Way To Do It, but it
works for me in simple tests:

    Datum  a;

    a = OidFunctionCall3(F_ARRAY_IN,
                         CStringGetDatum(arraystring),
                         ObjectIdGetDatum(INT8OID),
                         -1);

F_ARRAY_IN is defined in utils/fmgroids.h; INT8OID is defined in
catalog/pg_type.h.

Before using the above code, you might want to see if one of the
developers follows up.  There might be a different way that's
considered best practice.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2005-04-30 16:52:43
Subject: Re: Problem with DirectFunctionCall3(array_in,...)
Previous:From: Michael FuhrDate: 2005-04-30 14:31:45
Subject: Re: Textarea returns

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group