Writing triggers in C++

From: Jacob Rief <jacob(dot)rief(at)gmx(dot)at>
To: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Writing triggers in C++
Date: 2007-02-13 23:22:58
Message-ID: 1171408978.5704.29.camel@ruben
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I tried to write a trigger using C++. This requires to include the
following header-files:

extern "C" {
#include <postgres.h>
#include <executor/spi.h>
#include <commands/trigger.h>
#include <fmgr.h>
}

Unfortunately some of the included headers define some structs and
functions where a few identifiers are C++ keywords.
The compiler-directive 'extern "C"' does not help here, it just tells
the compiler not to mangle C-identifiers. 'extern "C"' does not rename
C++ keywords into something else. Therefore AFAIK, if someone wants to
include those headers files into a C++ program, the identifiers causing
problems have to be renamed manually.

For instance, Postgresql version 8.2.3
/usr/include/pgsql/server/nodes/primnodes.h:950:
List *using; /* USING clause, if any (list of String) */
'using' is a C++ keyword

/usr/include/pgsql/server/nodes/parsenodes.h:179:
Oid typeid; /* type identified by OID */
'typeid' is a C++ keyword

/usr/include/pgsql/server/nodes/parsenodes.h:249,265,401,943,1309:
TypeName *typename;
'typename' is a C++ keyword

/usr/include/pgsql/server/utils/builtins.h:544:
extern char *quote_qualified_identifier(const char *namespace,
'namespace' is a C++ keyword

Is there any convention how to rename such identifiers? If I would
rename those identifiers (I simply would add an underscore to each of
them), would such a patch be accepted and adopted onto one of the next
releases?

Regards, Jacob

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2007-02-13 23:53:27 Fixing insecure security definer functions
Previous Message Bruce Momjian 2007-02-13 23:17:03 Re: [HACKERS] Another aspect of set_ps_display ()