[Mono-list] GSoC Proposal: PL/Mono

Olexandr Melnyk omelnyk at gmail.com
Tue Mar 31 18:23:57 EDT 2009


Hello,

my name is Olexandr Melnyk and I am a third-year Ukrainian student. I
would like to present my proposal for Summer of Code "PL/Mono: a
procedural language for PostgreSQL". The objective of my project is to
add support for writing PostgreSQL functions in managed languages.
PostgreSQL functions are often referred to as "stored procedures", but
apart from that usage they serve a broad range of purposes (eg. they
are also used for implementing triggers).

So far I've found a couple of places, which I'm uncertain about and
would like to make clear before I submit an application.

1) I see three ways of specifying functions in CREATE FUNCTION statement:
- embedding C# code into the statement (PL/Python and PL/Perl do that):
    CREATE FUNCTION SUM(INT) RETURNS INT
    AS $$
        public static int Add(int x, int y)
        {
            return x + y;
        }
    $$ LANGUAGE PLMONO;
This approach is the easiest to use, but is C#-specific. And extra
(little) work is needed to add support for a new managed language.

- by specifying an assembly filename and a fully qualified function name:
    CREATE FUNCTION SUM(INT) RETURNS INT
    AS 'Library1.dll:Namespace2.Class3.Function4'
    LANGUAGE PLMONO;
Assemblies are searched in directories specified by a config variable,
or a full path should be provided.

- by a fully qualified function name (this approach is taken by
PL/Java and is my personal favorite):
    CREATE FUNCTION SUM(INT) RETURNS INT
    AS 'Namespace1.Class2.Function3'
    LANGUAGE PLMONO;
Functions are searched in assemblies from directories specified by a
config variable.

2) If we go with the approach 2 or 3, should all managed functions
exposed to PostgreSQL world be marked with some special attribute? For
example:

public static class FunctionLibrary
{
    [PostgresFunc]
    public static int Add(int x, int y)
    {
        return x + y;
    }
}

Requiring an attribute would mean that functions can be used from SQL,
only if they were really intended for that. However, this would also
mean that to use a harmless function from standard namespaces (like
System.Math.Abs), one would need to make a wrapper.

I have already briefly discussed my proposal on IRC, but would be glad
to get some more feedback.

-- 
Sincerely yours,
Olexandr Melnyk
http://omelnyk.net/


More information about the Mono-list mailing list