Hi,

I'm trying to implement the add_one sample in the PG docs using VC++
(for purposes of debugging).  After some pain (had to add the
dllexport declspec below), I am able to get the CREATE FUNCTION
command to recognize the library and function.  However, the function
blows up.  I am able to attach the postgres.exe process and debug this
dll (I set a breakpoint on the int x = 1 line).  I do get that far,
but then blow up trying to retrieve my argument on the following
line.  Digging into this, I find that the fcinfo struct being passed
to me as an address of 0x000002 - that looks a little non-sensical to
me.

I am wondering if I've got the necessary project settings in Visual
Studio.  How do we create a VC++ dll that is compatible with the gcc
PG build?  Does anyone have a clue as to what these might be?  I have
been doing a lot of digging and haven't seen anything directly
addressing this issue.

Many thanks....Eric

__declspec(dllexport)
Datum
add_one(PG_FUNCTION_ARGS)
{
   int x = 1;
    int32   arg = PG_GETARG_INT32(0);

    PG_RETURN_INT32(arg + 1);
}


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Reply via email to