Re: Function valid only for one table - Mailing list pgsql-sql

From Tom Lane
Subject Re: Function valid only for one table
Date
Msg-id 18520.1084987999@sss.pgh.pa.us
Whole thread Raw
In response to Re: Function valid only for one table  (Martin Knipper <knipper@mk-os.de>)
Responses Re: Function valid only for one table
List pgsql-sql
Martin Knipper <knipper@mk-os.de> writes:
> I thought about a mixture of object orientation and a normal table
> for a relational database.
> someFunction() is a method for the object/table someTable.

Perhaps you could do what you want with functions accepting table
rowtypes.
create function someFunction(someTable) returns ...
select someFunction(t.*) from someTable t where ...-- works
select someFunction(t.*) from anotherTable t where ...-- fails
create function someFunction(anotherTable) returns ...
select someFunction(t.*) from someTable t where ...-- still works
select someFunction(t.*) from anotherTable t where ...-- now calls the second someFunction()

As of existing releases this doesn't scale well to large tables, because
passing a whole table row to a function leaks memory intraquery.  That
is fixed for 7.5 though.
        regards, tom lane


pgsql-sql by date:

Previous
From: Martin Knipper
Date:
Subject: Re: Function valid only for one table
Next
From: "Jie Liang"
Date:
Subject: rules