From: | Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de> |
---|---|
To: | Sebastien Lemieux <slemieux(at)elitra(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Extending PostgreSQL in C or C++ |
Date: | 2003-06-17 21:51:34 |
Message-ID: | 3EEF8D66.4060202@web.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Blasby wrote:
> Sebastien Lemieux wrote:
>
>> Hi,
>>
>> I need to extend postgreSQL to support some specific function I
>> will code in C (ideally C++ if it can work!).
>
>
> Be very carefull with using C++ functions inside postgresql. If the
> C++ code throws an exception the postgresql backend will get a SIGABRT
> and terminate.
>
> You can solve this by linking the std c++ library to the postmaster.
> We tried everything we could think of to fix this, but this was the
> only solution that worked.
>
> For a complete discussion, you can read the PostGIS (GIS spatial
> objects for Postgresql) mailing list (http://postgis.refractions.net)
> and the GEOS (Geometry Engine, Open Source) mailing list
> (http://geos.refractions.net)
>
If you try C++, you will find some nasty name/reserved words collisions,
but it will work:
#define using __using
#define typeid __typeid
#define typename __typename
#define namespace __namespace
#define delete __delete
extern "C"
{
#include "postgres.h"
#include "executor/spi.h"
#include "funcapi.h"
}
#undef using
#undef typeid
#undef typename
#undef namespace
#undef delete
Fortunately, my code didn't use exceptions...
Regards,
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2003-06-17 22:31:50 | Re: [HACKERS] CVS -Tip compile issue -- FreeBSD 4.8 |
Previous Message | Andreas Pflug | 2003-06-17 21:45:34 | Re: pg_get_triggerdef in pg_dump |