Re: adding operators

Lists: pgsql-hackers
From: "Islam Hegazy" <islheg(at)gmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: adding operators
Date: 2007-10-01 00:12:08
Message-ID: 006601c803c0$dadb52f0$0d0e9f88@pc.cpsc.ucalgary.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dear PostgreSQL developers

I am a graduate student in the University of Calgary. I want to add some new operators to PostgreSQL to perform some specific tasks in a project I am working in. My problem is that I cannot find my way into the code, where should I start and where to find the documentation for the code.

Regards
Islam Hegazy


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Islam Hegazy" <islheg(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: adding operators
Date: 2007-10-01 02:38:07
Message-ID: 37ed240d0709301938t3cd9ac34h160e51aee954c752@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10/1/07, Islam Hegazy <islheg(at)gmail(dot)com> wrote:
> I am a graduate student in the University of Calgary. I want to add some new
> operators to PostgreSQL to perform some specific tasks in a project I am
> working in. My problem is that I cannot find my way into the code, where
> should I start and where to find the documentation for the code.

There's no need to hack Postgres to add operators. You can do so by
defining functions using CREATE FUNCTION, and then hooking operators
up to them using CREATE OPERATOR.

http://www.postgresql.org/docs/8.2/static/xoper.html
http://www.postgresql.org/docs/8.2/static/sql-createoperator.html

Regards,
BJ


From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: "Islam Hegazy" <islheg(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: adding operators
Date: 2007-10-01 06:53:57
Message-ID: 20071001025357.aacc36c1.darcy@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 1 Oct 2007 12:38:07 +1000
"Brendan Jurd" <direvus(at)gmail(dot)com> wrote:
> On 10/1/07, Islam Hegazy <islheg(at)gmail(dot)com> wrote:
> > I am a graduate student in the University of Calgary. I want to add some new
> > operators to PostgreSQL to perform some specific tasks in a project I am
> > working in. My problem is that I cannot find my way into the code, where
> > should I start and where to find the documentation for the code.
>
> There's no need to hack Postgres to add operators. You can do so by
> defining functions using CREATE FUNCTION, and then hooking operators
> up to them using CREATE OPERATOR.

And if you need to add C code you can do that too. Check some examples
in contrib such as my chkpass module for examples.

--
D'Arcy J.M. Cain <darcy(at)druid(dot)net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.


From: "Islam Hegazy" <islheg(at)gmail(dot)com>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>, <darcy(at)druid(dot)net>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: adding operators
Date: 2007-10-01 17:17:47
Message-ID: 010301c80450$cdbe6180$0d0e9f88@pc.cpsc.ucalgary.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks for this information. It was really helpful.

Another problem that is facing me is altering existing functions. For
example, what if I want to change the execution of the SUM function to work
as follows:

select sum(a)
from mytable w(5);

which means to sum only 5 records or records that arrived in the last 5
minutes. Do I need to change the core code of PostgreSQL to implement such
thing?

Regards
Islam Hegazy

----- Original Message -----
From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Islam Hegazy" <islheg(at)gmail(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Sent: Sunday, September 30, 2007 8:38 PM
Subject: Re: [HACKERS] adding operators

> On 10/1/07, Islam Hegazy <islheg(at)gmail(dot)com> wrote:
>> I am a graduate student in the University of Calgary. I want to add some
>> new
>> operators to PostgreSQL to perform some specific tasks in a project I am
>> working in. My problem is that I cannot find my way into the code, where
>> should I start and where to find the documentation for the code.
>
> There's no need to hack Postgres to add operators. You can do so by
> defining functions using CREATE FUNCTION, and then hooking operators
> up to them using CREATE OPERATOR.
>
> http://www.postgresql.org/docs/8.2/static/xoper.html
> http://www.postgresql.org/docs/8.2/static/sql-createoperator.html
>
> Regards,
> BJ


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Islam Hegazy <islheg(at)gmail(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, darcy(at)druid(dot)net, pgsql-hackers(at)postgresql(dot)org
Subject: Re: adding operators
Date: 2007-10-01 18:09:01
Message-ID: 470137BD.20104@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Islam Hegazy wrote:
> Thanks for this information. It was really helpful.
>
> Another problem that is facing me is altering existing functions. For
> example, what if I want to change the execution of the SUM function to
> work as follows:
>
> select sum(a)
> from mytable w(5);
>
> which means to sum only 5 records or records that arrived in the last
> 5 minutes. Do I need to change the core code of PostgreSQL to
> implement such thing?
>
>

The first can be done with a limit clause, the second using a where
clause on a timestamp column - there is no good case that I can see for
either usage, not to mention the question of standards compatibility.

cheers

andrew


From: "Islam Hegazy" <islheg(at)gmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: code documentation
Date: 2007-10-04 23:02:27
Message-ID: 005601c806de$81ccd410$0d0e9f88@pc.cpsc.ucalgary.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all

I wonder if there is a PostgreSQL code documentation that may help in
understanding the code.

Regards
Islam Hegazy


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Islam Hegazy <islheg(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: code documentation
Date: 2007-10-04 23:44:35
Message-ID: 20071004234435.GH28896@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Islam Hegazy escribió:
> Hi all
>
> I wonder if there is a PostgreSQL code documentation that may help in
> understanding the code.

Yes. There is the developer's FAQ, then there is the "internals"
chapter in the official docs, then there's the various README's
sprinkled throughout the code, and finally there's the comments in the
code itself.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Uma Krishnan <ukris03(at)yahoo(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Islam Hegazy <islheg(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: code documentation
Date: 2007-10-05 01:37:32
Message-ID: 964058.40842.qm@web51508.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Also Doxygen docs are greatly help. You can generate them yourself for the latest or obtain them from doxygen.postgresql.org. I found doxygen and the FAQ internals to be most useful.

Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote: Islam Hegazy escribi�:
> Hi all
>
> I wonder if there is a PostgreSQL code documentation that may help in
> understanding the code.

Yes. There is the developer's FAQ, then there is the "internals"
chapter in the official docs, then there's the various README's
sprinkled throughout the code, and finally there's the comments in the
code itself.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq