dbTalk Databases Forums  

pgsql function using C++?, or at least C interfacing with C++ lib?

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss pgsql function using C++?, or at least C interfacing with C++ lib? in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Eric Parusel
 
Posts: n/a

Default pgsql function using C++?, or at least C interfacing with C++ lib? - 10-16-2004 , 06:12 PM






Hello,

I've got a C++ library I need to use, and I want to use it from a pgsql
function.
Would anyone happen to have any examples of how to accomplish something
like this?
I see examples of C-based functions for pgsql (like dbsize, etc, in
contrib).

Which way should I go about this?

1) C based function, calling a C++ library (is this possible?)
2) C++ based function, calling a C++ library (I read in the pgsql docs
that compiling C++ code for use with pgsql is either partially
incompatible, or just a bad idea?)

Also note that I would like to pass the function the following arguments:
int4, _varchar (array of varchars)

Any help would be appreciated, I'm not incredibly experienced in these
matters.

Thanks,
Eric

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Dann Corbit
 
Posts: n/a

Default Re: pgsql function using C++?, or at least C interfacing with C++ lib? - 10-16-2004 , 06:21 PM






Quote:
-----Original Message-----
From: pgsql-general-owner (AT) postgresql (DOT) org
[mailtogsql-general-owner (AT) postgresql (DOT) org] On Behalf Of Eric Parusel
Sent: Saturday, October 16, 2004 4:12 PM
To: pgsql-general (AT) postgresql (DOT) org
Subject: [GENERAL] pgsql function using C++?, or at least C
interfacing with C++ lib?


Hello,

I've got a C++ library I need to use, and I want to use
it from a pgsql
function.
Would anyone happen to have any examples of how to accomplish
something
like this?
I see examples of C-based functions for pgsql (like dbsize, etc, in
contrib).

Which way should I go about this?

1) C based function, calling a C++ library (is this possible?)
If you want to do this, publish an interface in your C++ library with
the interface functions declared as extern "C"

Quote:
2) C++ based function, calling a C++ library (I read in the
pgsql docs
that compiling C++ code for use with pgsql is either partially
incompatible, or just a bad idea?)
C++ calling C++ is not portable because of name mangling. Other than
that, if you use the same compiler there is rarely any problem.

Quote:
Also note that I would like to pass the function the
following arguments: int4, _varchar (array of varchars)

Any help would be appreciated, I'm not incredibly experienced
in these
matters.
I would use an extern "C" interface, if I were in your shoes.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: pgsql function using C++?, or at least C interfacing with C++ lib? - 10-16-2004 , 10:56 PM



"Dann Corbit" <DCorbit (AT) connx (DOT) com> writes:
Quote:
I've got a C++ library I need to use, and I want to use
it from a pgsql function.

If you want to do this, publish an interface in your C++ library with
the interface functions declared as extern "C"
Note that the backend does not incorporate any C++ library support,
which is rather a severe handicap. For instance it will probably
not work to use catch/throw constructs.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.