Re: How to compile, link and use a C++ extension - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: How to compile, link and use a C++ extension
Date
Msg-id 55CE33B5.6000405@dunslane.net
Whole thread Raw
In response to Re: How to compile, link and use a C++ extension  (Peter Geoghegan <pg@heroku.com>)
List pgsql-hackers

On 08/14/2015 02:10 PM, Peter Geoghegan wrote:
> On Fri, Aug 14, 2015 at 10:28 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Yeah.  The painful issues you're going to face are not that.  They are
>> memory management (C++ "new" does not talk to palloc or vice versa)
>> and error handling ("throw" does not interoperate with PG_TRY()).
> It's worse than that. Any use of longjmp() will cause undefined
> behavior in C++. That's because each C++ object's destructor will not
> be called (possibly other reasons, too).
>
> I suggest looking at the PL/V8 code for an example of how to make C++
> code work as a Postgres extension. IIRC they've made specific
> trade-offs that might be useful for Jacques' use case too.
>

Yeah, although be aware that PLv8 still has odd buggy behaviours that I 
am not sure are not related to some C/C++ impedance mismatch.

cheers

andrew



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Management of simple_eval_estate for plpgsql DO blocks
Next
From: Andres Freund
Date:
Subject: Re: Raising our compiler requirements for 9.6