Обсуждение: adding operators

Поиск
Список
Период
Сортировка

adding operators

От
"Islam Hegazy"
Дата:
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
 

Re: adding operators

От
"Brendan Jurd"
Дата:
On 10/1/07, Islam Hegazy <islheg@gmail.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


Re: adding operators

От
"D'Arcy J.M. Cain"
Дата:
On Mon, 1 Oct 2007 12:38:07 +1000
"Brendan Jurd" <direvus@gmail.com> wrote:
> On 10/1/07, Islam Hegazy <islheg@gmail.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@druid.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.


Re: adding operators

От
"Islam Hegazy"
Дата:
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@gmail.com>
To: "Islam Hegazy" <islheg@gmail.com>
Cc: <pgsql-hackers@postgresql.org>
Sent: Sunday, September 30, 2007 8:38 PM
Subject: Re: [HACKERS] adding operators


> On 10/1/07, Islam Hegazy <islheg@gmail.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 



Re: adding operators

От
Andrew Dunstan
Дата:

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


code documentation

От
"Islam Hegazy"
Дата:
Hi all

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

Regards
Islam Hegazy 



Re: code documentation

От
Alvaro Herrera
Дата:
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.


Re: code documentation

От
Uma Krishnan
Дата:
Also Doxygen docs are greatly help. You can generate them yourself for the latest or obtain them from <font
size="-1"><spanclass="a"><b>doxygen</b>.<b>postgres</b>ql.org. I found doxygen and the FAQ internals to be most
useful.<br/><br /><br /></span></font><br /><b><i>Alvaro Herrera <alvherre@commandprompt.com></i></b>
wrote:<blockquoteclass="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
IslamHegazy escribi�:<br />> Hi all<br />><br />> I wonder if there is a PostgreSQL code documentation that
mayhelp in <br />> understanding the code.<br /><br />Yes. There is the developer's FAQ, then there is the
"internals"<br/>chapter in the official docs, then there's the various README's<br />sprinkled throughout the code, and
finallythere's the comments in the<br />code itself.<br /><br />-- <br />Alvaro Herrera
http://www.CommandPrompt.com/<br/>The PostgreSQL Company - Command Prompt, Inc.<br /><br
/>---------------------------(endof broadcast)---------------------------<br />TIP 3: Have you checked our extensive
FAQ?<br/><br /> http://www.postgresql.org/docs/faq<br /></blockquote><br />