Re: Pl/Python -- current maintainer?

From: James William Pye <pgsql(at)jwp(dot)name>
To: Tino Wildenhain <tino(at)wildenhain(dot)de>
Cc: James Robinson <jlrobins(at)socialserve(dot)com>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Hackers Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Pl/Python -- current maintainer?
Date: 2006-02-25 20:21:34
Message-ID: 20060225202134.GB27635@lit.jwp.name
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 25, 2006 at 10:09:52AM +0100, Tino Wildenhain wrote:
> And with even more love the restricted python from zope could
> be ported so there could be a pl/python again :-)
>
> Ok, just haluzinating ;)

Not necessarily. ;)

From what I have seen of zope's restricted python, it does, or can, force its
restrictions by checking bytecode. I imagine a simple PL sitting on top of the
untrusted varient that merely implements a custom validator that checks the
bytecode produced by the untrusted PL's validator. The language handler would
remain the same:

<Create untrusted plpy...>

CREATE FUNCTION zope_restrict(oid) RETURNS VOID LANGUAGE python AS
$$
getcode = Postgres.CachedQuery("SELECT probin FROM pg_proc WHERE oid = $1")
getlangval = Postgres.CachedQuery("""
SELECT lanvalidator FROM pg_language WHERE
oid = (SELECT prolang FROM pg_proc WHERE oid = $1)
""")

langvaloid = getlangval(self.function.procid)
langval = Postgres.Function(langvaloid)

# produce the function's bytecode for checking
langval(args[0])

# get the function's newly created bytecode
code = getcode(args[0]).next()[0]

#
# XXX: do the zope restriction stuff, raise exception if necessary
#

Postgres.NOTICE(repr(code))
$$;

CREATE TRUSTED LANGUAGE plpyr HANDLER python.handler VALIDATOR zope_restrict;

[This almost works in plpy head, but I think I just found a bug ;]
--
Regards, James William Pye

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephan Szabo 2006-02-25 20:37:24 Re: constraints and sql92 information_schema compliance
Previous Message Clark C. Evans 2006-02-25 20:01:11 Re: constraints and sql92 information_schema compliance