Thread: half OOT, plv8js group created ^^

half OOT, plv8js group created ^^

From
Kiswono Prayogo
Date:
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..

Regards,
GB


Re: half OOT, plv8js group created ^^

From
Andrew Dunstan
Date:

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.

cheers

andrew


Re: half OOT, plv8js group created ^^

From
Merlin Moncure
Date:
On Mon, Oct 26, 2009 at 11:18 PM, Andrew Dunstan <andrew@dunslane.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!

merlin


Re: half OOT, plv8js group created ^^

From
Andrew Dunstan
Date:

Merlin Moncure wrote:
> On Mon, Oct 26, 2009 at 11:18 PM, Andrew Dunstan <andrew@dunslane.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.

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.

cheers

andrew


Re: half OOT, plv8js group created ^^

From
Sam Mason
Date:
On Tue, Oct 27, 2009 at 08:30:16AM -0400, Andrew Dunstan wrote:
> 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.

The project (at the moment) just seems to be a set of pointers to code
I threw together a couple of years ago to experiment with extending
Postgres.  It's based on an oldish release of Spidermonkey and it'll
be interesting to see where things go with this.  It would be nice to
see it picked up by someone as priorities changed and I lost personal
interest in it.

--  Sam  http://samason.me.uk/


Re: half OOT, plv8js group created ^^

From
Hitoshi Harada
Date:
2009/10/27 Andrew Dunstan <andrew@dunslane.net>:
>
>
> Merlin Moncure wrote:
>>
>> On Mon, Oct 26, 2009 at 11:18 PM, Andrew Dunstan <andrew@dunslane.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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

Regards,

--
Hitoshi Harada


Re: half OOT, plv8js group created ^^

From
David Fetter
Date:
On Fri, Oct 30, 2009 at 08:44:52PM +0900, Hitoshi Harada wrote:
> 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.

Please send a patch! :) :) :)

Cheers,
David.
-- 
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


Re: half OOT, plv8js group created ^^

From
Hitoshi Harada
Date:
2009/10/31 David Fetter <david@fetter.org>:
> Please send a patch! :) :) :)

Here's my working directory. Kiswono, thanks for adding me to your
google code project. I prefer the license would be New BSD rather than
GPL.

>From instant README:

plv8 version 2009/11/01

* OVERVIEW

plv8 is shared library that provides a PostgreSQL procedual language
powered by V8 JavaScript Engine. With this program you can write in
JavaScript your function that is callable from SQL.


* REQUIREMENT
plv8 requires:
PG: version 8.4.x (maybe older are allowed)
V8: version 1.2
g++ and all tools that PG and V8 requires to be built.


* INSTALL

** Get PostgreSQL and V8 source
PG: http://www.postgresql.org/ftp/source/
v8: http://code.google.com/p/v8/wiki/Source

Build both of them. Note v8 build option requires mode=release and
library=shared. Edit Makefile in plv8 directory so that $(PGDIR) and
$(V8DIR) point their directories and type "make". If your prompt
doesn't say anything and you can find plv8.so, that's all.


* TEST

Copy plv8.so into $(PGHOME)/lib and libv8.so from v8 directory into
some path that PostgreSQL can read as a library such like /usr/lib/.
Then type below SQL in your psql;
CREATE FUNCTION plv8_call_handler() RETURNS language_handler AS
'$libdir/plv8' LANGUAGE C;
CREATE FUNCTION plv8_call_validator(Oid) RETURNS void AS
'$libdir/plv8' LANGUAGE C;
CREATE LANGUAGE plv8 HANDLER plv8_call_handler VALIDATOR plv8_call_validator;

-- create js function
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;

-- test
SELECT plv8_test(ARRAY['name', 'age'], ARRAY['Tom', '29']);

* CAVEATS
- This is WIP version.
- Tested on only CentOS 5 (x86), PostgreSQL 8.4 (8.5devel) and v8 1.2.
- There's no interface to call SPI.
- You must specify argument names in function declarations.
- 1-dim array can be put as arguments. Multi dimension array is not supported.
- And many, many bugs...

Any question and comment appreciated.

Regards,


--
Hitoshi Harada

Attachment