Re: Oracle Style packages on postgres - Mailing list pgsql-hackers

From Thomas Hallgren
Subject Re: Oracle Style packages on postgres
Date
Msg-id thhal-0815cA1GfyicJ8zNpSue0JxA2rqxzGw@mailblocks.com
Whole thread Raw
In response to Re: Oracle Style packages on postgres  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian wrote:

>Thomas Hallgren wrote:
>  
>
>>Bruce Momjian wrote:
>>    
>>
>>>Josh Berkus wrote:
>>>
>>>      
>>>
>>>>I think that private variables and private functions need to be part of the 
>>>>definition.
>>>>        
>>>>
>>>OK, so it seems we need:
>>>
>>>    C static/private functions for schemas
>>>    C static/private variables for schemas
>>>
>>>Are private variables implemented via the temporary per-session schema?
>>>
>>>    nested schemas
>>>
>>>What does the standard say?
>>>
>>>      
>>>
>>The standard says that rather then using nested schemas or packages in 
>>conjunction with functions in order to group functions with data, use 
>>user defined types with attributes and methods. Methods can be STATIC, 
>>INSTANCE or CONSTRUCTOR.
>>    
>>
>
>So it sounds like you group the functions into user-defined types,
>rather than nested schemas.
>
Yes, you'd get <schema>.<type>.<method> as the fully qualified name.

>  So you assocate functions with a table?
>  
>
Not necessarily a table. A type is just a type. A type containing just 
static methods is not very different from an Oracle package. A table 
created from a type may of course have methods associated with it. That 
gets really interesting when you use INSTANCE methods. They act on a per 
row basis so that you can do things like:

SELECT x.someMethod() FROM someTable x;

rather than as today.

SELECT someFunction(x) FROM someTable x;

Regards,
Thomas Hallgren




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Cost of XLogInsert CRC calculations
Next
From: Bruce Momjian
Date:
Subject: Re: Cost of XLogInsert CRC calculations