EnterpriseDB: The Enterprise Postgres Company Postgres Plus Forums: The PostgreSQL Open Source Database from EnterpriseDB
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 

Unable to create a C language function  XML

Forum Index » Standard Server
Author Message
Dave_Derry

New member

Joined: 2 Sep 2010 14:23:43
Messages: 3
Offline

I'm trying to get a feel for creating a function in C, but am encountering a problem. I'm working on Solaris, and according to 'pg_config --version' am working with a Postgres 8.1.18 database. 'pg_config --includedir' gives me /usr/include/pgsql.

If I set my -I flags to that directory and it server subdirectory I am able to compile a simple c file into a .so. However when I try to 'create or replace function' using that .so I get an error that it is missing a magic block. I tried to include:

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

in the .c file, but it didn't help. grep of that directory finds no files that contain PG_MODULE_MAGIC.

I did find /usr/postgres/8.2/include and /usr/postgres/8.3/include directories though, and tried compiling against them. Using 8.2, when I create the function I get an "incompatible library" magic block mismatch error. But if I compile against 8.3 the error states "Server: 8.2, Library: 8.3".

I am really at a loss how to resolve this problem. Can anyone recommend a solution?

Thanks,
Dave D
Vibhor_K

Senior member
[Avatar]

Joined: 3 Jul 2009 09:46:15
Messages: 444
Offline

It's more like a incompatibility issue.

Please share the code. Let me see if I can make it workable for PG8.4.

Thanks & Regards,
Vibhor Kumar
Blog:http://vibhork.blogspot.com
[Email] [WWW]
Dave_Derry

New member

Joined: 2 Sep 2010 14:23:43
Messages: 3
Offline

Yep, definitely a compatibility issue. I didn't mention that we aren't running on a raw PostGreSQL system, but are on Greenplum. With some more searching and experimenting I found that if I build against /usr/local/greenplum-db-3.3.6.1/include/postgresql I am able to create the function and execute it. Right now it doesn't do anything other than a simple select, but at least I now have managed to do that much.

Thanks,
Dave
 
Forum Index » Standard Server
Go to:   
Powered by JForum 2.1.8 © JForum Team