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 
Messages posted by: Dave_Derry
Forum Index » Profile for Dave_Derry » Messages posted by Dave_Derry
Author Message
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
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
OK, I've never used the facility you describe, but let me take a stab at this. From the description you give of the process (In the "Properties tab" I enter: Function Name, The owner, return type, language .... select Definition), which sounds like a wizard, and the error (Syntax error at or near "CREATE" LINE 2: $BODY$CREATE OR REPLACE ), I would guess that what it expects is just the *body* of the function. Not the complete create statement. What you have pasted in is what you would enter into a query window, and what I suspect the wizard is attempting to construct.

Try pasting just the part between the opening $$ (which gets expanded to $BODY$) and the closing $$. In other words just

BEGIN
RETURN i + 1;
END;
 
Forum Index » Profile for Dave_Derry » Messages posted by Dave_Derry
Go to:   
Powered by JForum 2.1.8 © JForum Team