Re: create function pl/pgsql c langauge

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

Well actually i have already install Pl/PgSql and i
have succesfully implement the code using this
language. Pl/PgSql does not install by defualt on any
database especially when i try to dump and restore the
database to some other server. To solve this problem i
need to implement it in C langauge so that the code of
operator and function restore itself without any
problem. and i dont know how to implement it in C
langauge on Linux.

--- Renê_Salomão <rene(at)ibiz(dot)com(dot)br> wrote: >
Muhammad,
>
> If I understood correctly you need create the
> language Pl/PgSql... why
> dont you just check for CREATELANG...
>
> Ex: prompt># createlang pgplsql database
>
>
> On Wed, 12 Mar 2003 14:38:44 +0000
> (GMT) Muhammad Shariq Muzaffar <shariq77(at)yahoo(dot)com>
> wrote:
>
> > 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
> >
> > ---------------------------(end of
> > broadcast)--------------------------- TIP 5: Have
> you checked our
> > extensive FAQ?
> >
> > http://www.postgresql.org/docs/faqs/FAQ.html
> >
>
>
> -----------------------------
> Renê Salomão
> Ibiz Tecnologia -- www.ibiz.com.br
> (011) 5579-3178 - R. 211

__________________________________________________
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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-03-12 18:32:21 Re: vacuum error
Previous Message Eric Cholet 2003-03-12 18:18:09 Re: vacuum error

Browse pgsql-novice by date

  From Date Subject
Next Message phil campaigne 2003-03-13 03:23:36 permission denied
Previous Message Aarni Ruuhimäki 2003-03-12 17:22:04 Re: Last access time for a table