Note about comparation PL/SQL packages and our schema/extensions

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Note about comparation PL/SQL packages and our schema/extensions
Date: 2015-11-05 06:36:38
Message-ID: CAFj8pRDAdUwJNANY9ZbK3Atp0NXt8hCKqo4=ybc+nutFer+bfA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I had talk about possibility to implement PL/SQL packages in Postgres.

The package concept is coming from ADA language and it is partially
foreign/redundant element in SQL world. Oracle needs it for modularization,
because schema plays different role there than in Postgres. My opinion
about packages in Postgres is clean - the concept of schemas and extension
is simple and just work. I don't see any big gap there. If we don't play
Oracle compatibility game, then we don't need to implement class like
Oracle package. But there are few features, that can help to PL/pgSQL
developers - generally or with porting from Oracle.

1. The encapsulation and local scope - all objects in schema are accessible
from other objects in schema by default (can be rewritten by explicit
granting). Local objects are visible only from objects in schema. This
needs enhancing of our search_path mechanism.

2. The schema variables - a server side session (can be emulated now) and
server side local schema session variables (doesn't exist) is pretty useful
for storing some temp data or high frequent change data - and can
significantly increase speed of some use cases. Now we emulate it via
PLPerl shared array, but the encapsulation is missing.

3. The initialization routines - the routines called when any object from
schema is used first time.

All three features we can emulate relative simply in C, and probably for
all mentioned points we have some workaround (less/more ugly) for PL/pgSQL.
Can be nice do it cleanly in PLpgSQL too.

I don't think we need ADA/ | PL/SQL Syntax - we can enhance our extension
mechanism to support mentioned points.

Comments, notes?

Regards

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2015-11-05 06:39:59 Re: [patch] Proposal for \rotate in psql
Previous Message Catalin Iacob 2015-11-05 06:24:45 Re: proposal: PL/Pythonu - function ereport