PLV8 is a 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.

Supported features are:

* Functions can receive any arguments, and return a value or set of
  records.
* Execute any SQL commands with built-in plv8.execute() function.
* Automatic data conversion between PostgreSQL and JavaScript,
  including string, numbers, timestamps, arrays, and records.
* Records are converted to JSON which keys are column names.
* Other types are converted to strings.
* Partial support to write TRIGGER handlers.
* EXTENSION support.

This basically adds the ability to do schemaless or semi-structured
development with PostgreSQL, including the ability to index nested
subfields of json columns.  Most of the advantages of MongoDB (except
webscale!), while still retaining all of the typical SQL goodies like
transactions and simple aggregate calculations.

Building this was a bit tricky.  We don't have a v8 port, and I was
having a very hard time getting v8 to build, partially because it likes
to set -Werror but use printfs that cause warnings (at least on i386),
using Scons and gyp for building.  As the node port builds a version of
v8 that works, I decided to piggyback off that, building just the v8
libraries using the node distfile and some of the patches from our node
port.

One issue with plv8 is that it requires pthreads, and since we cannot
dlopen pthreaded libraries unless the executable is pthreaded, you
either have to link PostgreSQL with libpthread at build time, or use
LD_PRELOAD.  Since I didn't feel like adding a threaded FLAVOR to our
PostgreSQL port, I opted for a MESSAGE file in the plv8 port that
describes the login.conf entry that will setup LD_PRELOAD correctly for
users of rc.d.  I'm not sure if MESSAGE is the best way, it might make
more sense as a pkg-readme, I'm opening to changing that.

Regress tested and light manual testing on i386, compiles on amd64.
Looking for OKs or other feedback.

Thanks,
Jeremy

Attachment: postgresql-plv8.tar.gz
Description: application/tar-gz

Reply via email to