Re: [HACKERS] rule system, perl and other good stuff - Mailing list pgsql-hackers

From Vadim B. Mikheev
Subject Re: [HACKERS] rule system, perl and other good stuff
Date
Msg-id 34E15F24.CD8BC514@sable.krasnoyarsk.su
Whole thread Raw
In response to rule system, perl and other good stuff  (Brett McCormick <brett@work.chicken.org>)
Responses Re: [HACKERS] rule system, perl and other good stuff  (jwieck@debis.com (Jan Wieck))
List pgsql-hackers
Brett McCormick wrote:
>
> I don't see CREATE LANGUAGE in the grammar file...  are you asking if
> it is strictly compatible or if it uses the dynamic language interface?
> there's no reason it shouldn't be compatible..
...
> DOH -- that's another question I meant to ask, as I noticed some
> things in the new (6.3) code about it..  no, it isn't, it is hacked in
> just like fmgr_dynamic is..  what do I need to know about the create
> language interface..  any docs?
...
> okay... yes it can co-exist with CREATE LANGUAGE as long as it is
> coded into the server like fmgr_dynamic is.  it will not function as a
> CREATE LANGUAGE function.  this is because all that this functionality
> appears to do is associate a single function with a language.  but it
> does not pass the prosrc attribute (or probin for that matter) to the
> function, so no matter what you say for as 'insert code here', it
> never gets to the function, so the function has no idea what to do!

Sorry: CREATE PLangTrusted PROCEDURAL LANGUAGE...

PL handler function has to be created (via CREATE FUNCTION)
before language creation..

After that you are able to do something like this (having PL/tcl):

            create function overpaid_2 (EMP)
                returns bool as '
                    if {200000.0 < $EMP(salary)} {
                        return 't'
                    }
                    if {$EMP(age) < 30 && 100000.0 < $EMP(salary)} {
                        return 't'
                    }
                    return 'f'
                ' language 'pltcl';
                  ^^^^^^^^^^^^^^^^
                           ^^^^^^^ in addition to built-in languages!

Dynamic procedural language interface and support for TCL are
implemented by Jan (wieck@sapserv.debis.de) - please contact to him
to get more info (btw, there is create_language.l)...

It would be nice to have support for perl...

BTW, Mark, I don't see PLtcl in current sources.
It would be nice to have it under contrib/pl or, even better, under
src/pl (may be with flag USE_PLTCL in Makefile - like USE_TCL :), -
with automatical installation into template database by initdb).

Vadim

pgsql-hackers by date:

Previous
From: Brett McCormick
Date:
Subject: Re: [HACKERS] rule system, perl and other good stuff
Next
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] rule system, perl and other good stuff