create function pl/pgsql c langauge

From: Muhammad Shariq Muzaffar <shariq77(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: pgsql-novice(at)postgresql(dot)org
Subject: create function pl/pgsql c langauge
Date: 2003-03-12 14:38:44
Message-ID: 20030312143844.14290.qmail@web41105.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

hi
I have created a function in pl/pgsql for xid data
type

CREATE FUNCTION xid_neq(xid, xid) RETURNS bool AS
'BEGIN
IF $2 IS NULL THEN
return ''f'';
ELSE
IF $1 IS NULL THEN
return ''f'';
ELSE return float4in(xidout($1)) <>
float4in(xidout($2));
END IF;
END IF;
END' LANGUAGE 'plpgsql' IMMUTABLE;

with the operator <>

CREATE OPERATOR public.<> (
PROCEDURE = xid_neq,
LEFTARG = xid,
RIGHTARG = xid,
COMMUTATOR ='<>',
NEGATOR ='=',
RESTRICT = neqsel,
JOIN = neqjoinsel);

Now, to implement above code I need Pl/PgSql installed
on the database. To solve this problem i need to
create this function in C language. As I am novice to
linux and pgsql, i have tried my best to implement the
above code in c language but unable to do so.
According to the online help i got, i think i have to
write the code in a file outside pgsql and then i have
to compile it through gcc. Also i think i need
postgres.h to complete the opeartion which is
available only in the distribution code.

The code i come up with for c langauage is

bool xid_neq(xid arg1,xid arg2)
{
if(arg1 isnull){
return (false);
}
else
if(arg2 isnull){
return(false);
}
else
return (arg1 != arg2);
}

How am i supoose to create the function now. I think i
am very much confused in this new environment.

please help...

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Delorme 2003-03-12 14:44:48 The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard
Previous Message Stefan Sturm 2003-03-12 14:27:58 Performance Problem

Browse pgsql-novice by date

  From Date Subject
Next Message Tim Pushor 2003-03-12 14:52:27 Re: SERIAL does not ROLLBACK
Previous Message Jules Alberts 2003-03-12 11:11:05 Re: filtering out doubles with SELECT