Re: How to compile, link and use a C++ extension

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, jacques klein <jacques(dot)klei(at)googlemail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How to compile, link and use a C++ extension
Date: 2015-08-14 18:10:14
Message-ID: CAM3SWZTOQ+fKpGumWiPV4SiTR+6YL=yWzkwAUZAkbaSpLYELzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 14, 2015 at 10:28 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-08-14 18:16:47 Re: How to compile, link and use a C++ extension
Previous Message Robert Haas 2015-08-14 18:00:46 Re: why can the isolation tester handle only one waiting process?