Обсуждение: Postgresql function in C++

Поиск
Список
Период
Сортировка

Postgresql function in C++

От
Jose Mendoza
Дата:

On august 2001 Eniar wrote above this issue the following:

 

On Tue, Aug 07, 2001 at 07:49:06AM -0500, Phillip J. Allen wrote:
> Hi all,
> 
> I was reading Bruce Momjian book on PostgreSQL and his chapter on user
> created functions stated that functions can be written in SQL, PL/PGSQL,
> PL/TCL, PL/Per, and C.  But I have been studying C++ for linux.  So can
> I create a  dynamically linked object file  in C++ and reference it in a
> function?
> 
The easiest way is to write C-wrappers around your C++ code.
 
- Einar Karttunen

 

I would like if it is possible to build a PostgreSQL function in C++.  I have a code generator to solve the problem to communicate postgresql with other database (postgresql included).

 

Some little example will be enough.

 

Thanks

 

Re: Postgresql function in C++

От
Tom Lane
Дата:
Jose Mendoza <unixos@prodigy.net.mx> writes:
> I would like if it is possible to build a PostgreSQL function in C++.

You can do this to the extent that you're using C++ as "a better C".
As soon as you get into any of the interesting features of the language,
like exceptions or RTTI, you're going to have problems due to lack of
library support --- libstdc++ isn't linked into the backend.

You could force it in there if you don't mind using a custom-built
server, but I'm not sure of the potential gotchas of putting libstdc++
into the backend.  One thing I'm pretty sure will not work in any case
is C++ exceptions; the backend uses its own setjmp-based error recovery
and that's not going to play nicely with C++.

            regards, tom lane