lots of errors from fmgr.h when I try to write a C UDF

Started by Anh Phamabout 12 years ago6 messagesgeneral
Jump to latest
#1Anh Pham
atpham.wpi@gmail.com

Hi,
I had Postgres 9.3 setup and run successfully in Eclipse (MacOSX)
I am trying to write a C user-defined function:

*#include <fmgr.h>*
*...*
*#ifdef PG_MODULE_MAGIC*
*PG_MODULE_MAGIC;*
*#endif*
...

However, when I tried to compile the code:
*gcc -fpic -c* ...
It gave me a lot of errors and warnings from fmgr.h:

*.../Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:59:2: error:
unknown type name 'MemoryContext'*
* MemoryContext fn_mcxt; /* memory context to store
fn_extra in */*
* ^*
*/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:71:2: error: unknown
type name 'Oid'*
* Oid fncollation; /* collation for function
to use */*
* ^*
*/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:72:2: error: unknown
type name 'bool'*
* bool isnull; /* function must set true
if result is NULL */*
...

*Any suggestion where I did it wrong?*
Thank you :)

#2Anh Pham
atpham.wpi@gmail.com
In reply to: Anh Pham (#1)
Fwd: lots of errors from fmgr.h when I try to write a C UDF

Hi,
I had Postgres 9.3 setup and run successfully in Eclipse (MacOSX)
I am trying to write a C user-defined function:

*#include <fmgr.h>*
*...*
*#ifdef PG_MODULE_MAGIC*
*PG_MODULE_MAGIC;*
*#endif*
...

However, when I tried to compile the code:
*gcc -fpic -c* ...
It gave me a lot of errors and warnings from fmgr.h:

*.../Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:59:2: error:
unknown type name 'MemoryContext'*
* MemoryContext fn_mcxt; /* memory context to store
fn_extra in */*
* ^*
*/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:71:2: error: unknown
type name 'Oid'*
* Oid fncollation; /* collation for function
to use */*
* ^*
*/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:72:2: error: unknown
type name 'bool'*
* bool isnull; /* function must set true
if result is NULL */*
...

*Any suggestion where I did it wrong?*
Thank you :)

#3Ian Lawrence Barwick
barwick@gmail.com
In reply to: Anh Pham (#2)
Re: Fwd: lots of errors from fmgr.h when I try to write a C UDF

2014-02-01 Anh Pham <atpham.wpi@gmail.com>:

Hi,
I had Postgres 9.3 setup and run successfully in Eclipse (MacOSX)
I am trying to write a C user-defined function:

#include <fmgr.h>
...
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
...

However, when I tried to compile the code:
gcc -fpic -c ...
It gave me a lot of errors and warnings from fmgr.h:

...
/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:59:2: error: unknown
type name 'MemoryContext'
MemoryContext fn_mcxt; /* memory context to store fn_extra
in */
^
/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:71:2: error: unknown
type name 'Oid'
Oid fncollation; /* collation for function to
use */
^
/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:72:2: error: unknown
type name 'bool'
bool isnull; /* function must set true if
result is NULL */

You'll need to include the appropriate header files. Certainly "postgres.h".

Regards

Ian Barwick

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Anh Pham
atpham.wpi@gmail.com
In reply to: Ian Lawrence Barwick (#3)
Re: Fwd: lots of errors from fmgr.h when I try to write a C UDF

Hi,
I actually included 'postgres.h'

However I found out that when I stopped the server, the code then compiled
successfully.
It's weird

On Fri, Jan 31, 2014 at 10:53 PM, Ian Lawrence Barwick <barwick@gmail.com>wrote:

2014-02-01 Anh Pham <atpham.wpi@gmail.com>:

Hi,
I had Postgres 9.3 setup and run successfully in Eclipse (MacOSX)
I am trying to write a C user-defined function:

#include <fmgr.h>
...
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
...

However, when I tried to compile the code:
gcc -fpic -c ...
It gave me a lot of errors and warnings from fmgr.h:

...
/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:59:2: error: unknown
type name 'MemoryContext'
MemoryContext fn_mcxt; /* memory context to store

fn_extra

in */
^
/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:71:2: error: unknown
type name 'Oid'
Oid fncollation; /* collation for

function to

use */
^
/Users/atpham/workspacecdt/pgsql/src/include/fmgr.h:72:2: error: unknown
type name 'bool'
bool isnull; /* function must set

true if

result is NULL */
...

You'll need to include the appropriate header files. Certainly
"postgres.h".

Regards

Ian Barwick

--
Anh T Pham
Computer Science
Worcester Polytechnic Institute

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Anh Pham (#1)
Re: lots of errors from fmgr.h when I try to write a C UDF

Anh Pham <atpham.wpi@gmail.com> writes:

I am trying to write a C user-defined function:

*#include <fmgr.h>*
*...*
*#ifdef PG_MODULE_MAGIC*
*PG_MODULE_MAGIC;*
*#endif*
...

However, when I tried to compile the code:
*gcc -fpic -c* ...
It gave me a lot of errors and warnings from fmgr.h:

Most Postgres backend header files assume that you've included
postgres.h first ... did you do that?

regards, tom lane

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

#6Michael Paquier
michael@paquier.xyz
In reply to: Anh Pham (#4)
Re: Fwd: lots of errors from fmgr.h when I try to write a C UDF

On Sat, Feb 1, 2014 at 1:34 PM, Anh Pham <atpham.wpi@gmail.com> wrote:

Hi,
I actually included 'postgres.h'

However I found out that when I stopped the server, the code then compiled
successfully.

Code compilation and a server status are not related as compilation of
Postgres-related modules require the libraries and headers in place to
compile. You could have those things installed with a server, multiple
servers or even nothing running.
Regards,
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general