Re: half OOT, plv8js group created ^^

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Kiswono Prayogo <kiswono(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: half OOT, plv8js group created ^^
Date: 2009-10-30 11:44:52
Message-ID: e08cc0400910300444t658fe6b0y8b943c959320912@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/10/27 Andrew Dunstan <andrew(at)dunslane(dot)net>:
>
>
> Merlin Moncure wrote:
>>
>> On Mon, Oct 26, 2009 at 11:18 PM, Andrew Dunstan <andrew(at)dunslane(dot)net>
>> wrote:
>>
>>>
>>> Kiswono Prayogo wrote:
>>>
>>>>
>>>> plv8js is a procedural language add-on for PostgreSQL, which means you
>>>> can define Javascript functions that run inside a PostgreSQL server
>>>> using google V8 Engine.
>>>>
>>>> anyone who want to contribute in plv8js please visit this group ^^
>>>> http://code.google.com/p/plv8js/
>>>> i'm still new in postgresql and v8, need MASSIVELY LOT of study and
>>>> help ^^, thank you..
>>>>
>>>
>>> Well, I see you are apparently ignoring the advice we already gave you
>>> that
>>> V8 is not likely to be the best fit for a PostgreSQL JS procedural
>>> language,
>>> so that's not a good start.
>>>
>>
>> that's a little harsh...he was mostly given some vague advice
>> ("spidermonkey might be better...").  Maybe it isn't the best, but
>> that doesn't mean it's not worth trying!
>>
>>
>>
>
>
> Very well, if I was harsh I apologise, but maybe you should look at the
> embedding guide here <http://code.google.com/apis/v8/embed.html> and decide
> how well it is likely to work for PostgreSQL in pure C. The advice was not
> just "spidermonkey might be better". It was that a C++ oriented API like
> this (throwing exceptions among other things) was not likely to work, or at
> least to work as well as a pure C API.
>
> And, frankly, pure PL speed in a language like JS, that is likely to be used
> mainly as glue, is not likely to be a concern for most uses.

+1 for v8 is the best engine for PL so far. SpiderMonkey has yield
syntax which helps setof function to be made but quite slower than v8
in general purpose (and I want "fast" and flexible PL). Recent
JavaScriptCore from Apple is so fast, may be than v8, but its build
process is too complicated, it's because it is assumed that the engine
is a part of Webkit. Of course there are concerns about C++ exception
mechanism, annoying destructors, despite of that v8 is compact enough
to be embedded.

So, by chance, I have been working on plv8 for my own purpose and
query like below is done:

regression=# CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals
text[]) RETURNS text AS $$
var o = {};
for(var i=0; i<keys.length; i++){
o[keys[i]] = vals[i];
}
return JSON.stringify(o);
$$ LANGUAGE plv8 IMMUTABLE STRICT;
CREATE FUNCTION

regression=# SELECT plv8_test(ARRAY['name', 'age'], ARRAY['Tom', '29']);
plv8_test
---------------------------
{"name":"Tom","age":"29"}
(1 row)

There are still too many TODOs such like type conversion between JS
and SQL, build system, and memory allocation. If you want I'll send
you my code.

>
> If someone is going to work on a JS engine for PostgreSQL (which I think is
> a good idea, actually) I want them to work on one that is likely to succeed.
>

Yeah, through these researches I concluded that a JS engine written by
pure C is quite cool for PL. Most engines are assumed to be embedded
in system like web browsers where optimization is "page-oriented" for
example. And if we have such great feature like saving binary JSON in
disk format, which is not done by any engine, PL/JavaScript would be
the most powerful language.

> cheers
>
> andrew
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

Regards,

--
Hitoshi Harada

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shrish purohit 2009-10-30 12:25:32 Patch for automated partitioning
Previous Message Itagaki Takahiro 2009-10-30 08:25:49 CREATE TABLE ... INHERITS (parent INCLUDING xxx)