Subject: C++

From: [email-masked] (Man Wai Wong)
Date: Wed, 8 Jul 92 10:28:12 -0700

Hi fellow,

I am using the postgres version 3.0.  I tried to use Sun CC to develop some type fuctiion to read
in and write out data from a data file.  But postgres seems doesn't reconize the C++
Does postgres supports Sun C++?  How can I let the postgres reconize C++ functions and type?
What switch(es) should I use for complilation?

[email-masked]

---

From: [email-masked]
Date: Wed, 08 Jul 92 11:32:48 -0700

I think there's a way to do this, but it's awfully kludgey.  I
strongly recommend that you avoid attempting to define functions that
are not written in C or Postquel.  These are the only languages we
support.

If you really want to use C++, try doing the following:

Compile your function.  Many C++ implementations actually preprocess
your code and translate it to C.  What you have to do is find out what
your function has been (re-)named by the C++ preprocessor.  You can do
this by running 'nm -t' on your object file.  Assuming you have a C++
method declared as:

int foobar(char, float),

nm should hopefully show you some C function name that looks like foobar with
its signature, i.e. foobar_int_char_float.

This is the function you should register with Postgres, and you will
have to invoke *this* function from your Postgres queries, e.g.

define function foobar_int_char_float
 (language = "c", returntype = int4)
 arg is (char, float8) as "/tmp/cplusplus.o"

retrieve (emp.all)
   where emp.dno = dept.dno
     and emp.salary = foobar_int_char_float('a', dept.budget)

Not very pretty.

CAVEAT:  This may not work in your environment.  It may not work at
all.  Obviously this will not work for inline functions.  It may also
not work if your function calls overloaded methods.  Don't forget that
the calling syntax from Postgres is C-based, i.e. there are no default
arguments, there's no overloading, etc.

So all in all, I don't recommend it.  But it may be possible if you
really need it.

Good luck.
Joe Hellerstein