CurrentMemoryContext is NULL

From: "Guan Wang" <anderswang(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: CurrentMemoryContext is NULL
Date: 2007-07-06 19:43:10
Message-ID: dd5c86230707061243k1ce6dd35l7c168dea91a9278@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi guys,

I've played with PostgreSql for couple weeks. Currently, I try to develop an
extension on windows system with VC++2005. I installed the full package of
PostgreSql 8.3 with include files and libraries. Compilation is ok in
vc2005, besides some warnings. But, when I tried to run my function in psql,
I always got a run time error. After I got the PostgreSql source codes, I
complied my own libpostgres.lib. And then link my code with this lib. Run
it, got the same error. I found the CurrentMemoryContext is NULL, which was
supposed to be initialized by the backend itself. Anyone could tell me what
happened here? Just because it's windows? or I should use cygwin?

I noticed CurrentMemoryContext is supposed to be imported to my dll by the
macro DLLIMPORT. It seems like PostgreSql can't send this parameter to my
dll...

Thank you for helping me!

The snippet of my codes looks like below:

#include "postgres.h"

#include "fmgr.h"

PG_FUNTION_INFO_V1(foobar)

Datum foobar(PG_FUNCTION_ARGS)
{
void* ptr=palloc(10); // or pgport_palloc(10); error occurred here,
CurrentMemoryContext equals to NULL, NULL pointer!
return NULL;
}

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2007-07-06 20:10:32 Re: Bgwriter strategies
Previous Message Alvaro Herrera 2007-07-06 19:19:12 Re: Still recommending daily vacuum...